[PATCH 1/2] erofs: put metabuf in error path in fscache mode

Jingbo Xu posted 2 patches 3 years, 5 months ago
[PATCH 1/2] erofs: put metabuf in error path in fscache mode
Posted by Jingbo Xu 3 years, 5 months ago
For tail packing layout, put metabuf when error is encountered.

Fixes: 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index fe05bc51f9f2..83559008bfa8 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -287,8 +287,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
 			return PTR_ERR(src);
 
 		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
-		if (copy_to_iter(src + offset, size, &iter) != size)
+		if (copy_to_iter(src + offset, size, &iter) != size) {
+			erofs_put_metabuf(&buf);
 			return -EFAULT;
+		}
 		iov_iter_zero(PAGE_SIZE - size, &iter);
 		erofs_put_metabuf(&buf);
 		return PAGE_SIZE;
-- 
2.19.1.6.gb485710b
Re: [PATCH 1/2] erofs: put metabuf in error path in fscache mode
Posted by Chao Yu 3 years, 5 months ago
On 2022/11/4 13:40, Jingbo Xu wrote:
> For tail packing layout, put metabuf when error is encountered.
> 
> Fixes: 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
Re: [External] [PATCH 1/2] erofs: put metabuf in error path in fscache mode
Posted by Jia Zhu 3 years, 5 months ago

在 2022/11/4 13:40, Jingbo Xu 写道:
> For tail packing layout, put metabuf when error is encountered.
> 
> Fixes: 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>
> ---
>   fs/erofs/fscache.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index fe05bc51f9f2..83559008bfa8 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -287,8 +287,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
>   			return PTR_ERR(src);
>   
>   		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
> -		if (copy_to_iter(src + offset, size, &iter) != size)
> +		if (copy_to_iter(src + offset, size, &iter) != size) {
> +			erofs_put_metabuf(&buf);
>   			return -EFAULT;
> +		}
>   		iov_iter_zero(PAGE_SIZE - size, &iter);
>   		erofs_put_metabuf(&buf);
>   		return PAGE_SIZE;
Re: [PATCH 1/2] erofs: put metabuf in error path in fscache mode
Posted by Gao Xiang 3 years, 5 months ago
On Fri, Nov 04, 2022 at 01:40:27PM +0800, Jingbo Xu wrote:
> For tail packing layout, put metabuf when error is encountered.
> 
> Fixes: 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Thanks,
Gao Xiang

> ---
>  fs/erofs/fscache.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index fe05bc51f9f2..83559008bfa8 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -287,8 +287,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
>  			return PTR_ERR(src);
>  
>  		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
> -		if (copy_to_iter(src + offset, size, &iter) != size)
> +		if (copy_to_iter(src + offset, size, &iter) != size) {
> +			erofs_put_metabuf(&buf);
>  			return -EFAULT;
> +		}
>  		iov_iter_zero(PAGE_SIZE - size, &iter);
>  		erofs_put_metabuf(&buf);
>  		return PAGE_SIZE;
> -- 
> 2.19.1.6.gb485710b