* [PATCH 0/2] erofs: misc fixes for erofs in fscache mode @ 2022-11-04 5:40 Jingbo Xu 2022-11-04 5:40 ` [PATCH 1/2] erofs: put metabuf in error path " Jingbo Xu 2022-11-04 5:40 ` [PATCH 2/2] erofs: get correct count for unmapped range " Jingbo Xu 0 siblings, 2 replies; 8+ messages in thread From: Jingbo Xu @ 2022-11-04 5:40 UTC (permalink / raw) To: xiang, chao, huyue2, linux-erofs; +Cc: zhujia.zj, yinxin.x, linux-kernel There are several minor fixes for the data path of the fscache mode. Jingbo Xu (2): erofs: put metabuf in error path in fscache mode erofs: get correct count for unmapped range in fscache mode fs/erofs/fscache.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.19.1.6.gb485710b ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] erofs: put metabuf in error path in fscache mode 2022-11-04 5:40 [PATCH 0/2] erofs: misc fixes for erofs in fscache mode Jingbo Xu @ 2022-11-04 5:40 ` Jingbo Xu 2022-11-04 10:03 ` Gao Xiang ` (2 more replies) 2022-11-04 5:40 ` [PATCH 2/2] erofs: get correct count for unmapped range " Jingbo Xu 1 sibling, 3 replies; 8+ messages in thread From: Jingbo Xu @ 2022-11-04 5:40 UTC (permalink / raw) To: xiang, chao, huyue2, linux-erofs; +Cc: zhujia.zj, yinxin.x, linux-kernel 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] erofs: put metabuf in error path in fscache mode 2022-11-04 5:40 ` [PATCH 1/2] erofs: put metabuf in error path " Jingbo Xu @ 2022-11-04 10:03 ` Gao Xiang 2022-11-07 14:41 ` [External] " Jia Zhu 2022-11-08 3:07 ` Chao Yu 2 siblings, 0 replies; 8+ messages in thread From: Gao Xiang @ 2022-11-04 10:03 UTC (permalink / raw) To: Jingbo Xu Cc: xiang, chao, huyue2, linux-erofs, zhujia.zj, yinxin.x, linux-kernel 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [External] [PATCH 1/2] erofs: put metabuf in error path in fscache mode 2022-11-04 5:40 ` [PATCH 1/2] erofs: put metabuf in error path " Jingbo Xu 2022-11-04 10:03 ` Gao Xiang @ 2022-11-07 14:41 ` Jia Zhu 2022-11-08 3:07 ` Chao Yu 2 siblings, 0 replies; 8+ messages in thread From: Jia Zhu @ 2022-11-07 14:41 UTC (permalink / raw) To: Jingbo Xu, xiang, chao, huyue2, linux-erofs; +Cc: yinxin.x, linux-kernel 在 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; ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] erofs: put metabuf in error path in fscache mode 2022-11-04 5:40 ` [PATCH 1/2] erofs: put metabuf in error path " Jingbo Xu 2022-11-04 10:03 ` Gao Xiang 2022-11-07 14:41 ` [External] " Jia Zhu @ 2022-11-08 3:07 ` Chao Yu 2 siblings, 0 replies; 8+ messages in thread From: Chao Yu @ 2022-11-08 3:07 UTC (permalink / raw) To: Jingbo Xu, xiang, huyue2, linux-erofs; +Cc: zhujia.zj, yinxin.x, linux-kernel 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, ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] erofs: get correct count for unmapped range in fscache mode 2022-11-04 5:40 [PATCH 0/2] erofs: misc fixes for erofs in fscache mode Jingbo Xu 2022-11-04 5:40 ` [PATCH 1/2] erofs: put metabuf in error path " Jingbo Xu @ 2022-11-04 5:40 ` Jingbo Xu 2022-11-04 10:03 ` Gao Xiang 2022-11-08 3:09 ` Chao Yu 1 sibling, 2 replies; 8+ messages in thread From: Jingbo Xu @ 2022-11-04 5:40 UTC (permalink / raw) To: xiang, chao, huyue2, linux-erofs; +Cc: zhujia.zj, yinxin.x, linux-kernel For unmapped range, the returned map.m_llen is zero, and thus the calculated count is unexpected zero. Prior to the refactoring introduced by commit 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode"), only the readahead routine suffers from this. With the refactoring of making .read_folio() and .readahead() calling one common routine, both read_folio and readahead have this issue now. Fix this by calculating count separately in unmapped condition. Fixes: c665b394b9e8 ("erofs: implement fscache-based data readahead") 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 83559008bfa8..260fa4737fc0 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -296,15 +296,16 @@ static int erofs_fscache_data_read(struct address_space *mapping, return PAGE_SIZE; } - count = min_t(size_t, map.m_llen - (pos - map.m_la), len); - DBG_BUGON(!count || count % PAGE_SIZE); - if (!(map.m_flags & EROFS_MAP_MAPPED)) { + count = len; iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count); iov_iter_zero(count, &iter); return count; } + count = min_t(size_t, map.m_llen - (pos - map.m_la), len); + DBG_BUGON(!count || count % PAGE_SIZE); + mdev = (struct erofs_map_dev) { .m_deviceid = map.m_deviceid, .m_pa = map.m_pa, -- 2.19.1.6.gb485710b ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] erofs: get correct count for unmapped range in fscache mode 2022-11-04 5:40 ` [PATCH 2/2] erofs: get correct count for unmapped range " Jingbo Xu @ 2022-11-04 10:03 ` Gao Xiang 2022-11-08 3:09 ` Chao Yu 1 sibling, 0 replies; 8+ messages in thread From: Gao Xiang @ 2022-11-04 10:03 UTC (permalink / raw) To: Jingbo Xu Cc: xiang, chao, huyue2, linux-erofs, zhujia.zj, yinxin.x, linux-kernel On Fri, Nov 04, 2022 at 01:40:28PM +0800, Jingbo Xu wrote: > For unmapped range, the returned map.m_llen is zero, and thus the > calculated count is unexpected zero. > > Prior to the refactoring introduced by commit 1ae9470c3e14 ("erofs: > clean up .read_folio() and .readahead() in fscache mode"), only the > readahead routine suffers from this. With the refactoring of making > .read_folio() and .readahead() calling one common routine, both > read_folio and readahead have this issue now. > > Fix this by calculating count separately in unmapped condition. > > Fixes: c665b394b9e8 ("erofs: implement fscache-based data readahead") > 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 | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c > index 83559008bfa8..260fa4737fc0 100644 > --- a/fs/erofs/fscache.c > +++ b/fs/erofs/fscache.c > @@ -296,15 +296,16 @@ static int erofs_fscache_data_read(struct address_space *mapping, > return PAGE_SIZE; > } > > - count = min_t(size_t, map.m_llen - (pos - map.m_la), len); > - DBG_BUGON(!count || count % PAGE_SIZE); > - > if (!(map.m_flags & EROFS_MAP_MAPPED)) { > + count = len; > iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count); > iov_iter_zero(count, &iter); > return count; > } > > + count = min_t(size_t, map.m_llen - (pos - map.m_la), len); > + DBG_BUGON(!count || count % PAGE_SIZE); > + > mdev = (struct erofs_map_dev) { > .m_deviceid = map.m_deviceid, > .m_pa = map.m_pa, > -- > 2.19.1.6.gb485710b ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] erofs: get correct count for unmapped range in fscache mode 2022-11-04 5:40 ` [PATCH 2/2] erofs: get correct count for unmapped range " Jingbo Xu 2022-11-04 10:03 ` Gao Xiang @ 2022-11-08 3:09 ` Chao Yu 1 sibling, 0 replies; 8+ messages in thread From: Chao Yu @ 2022-11-08 3:09 UTC (permalink / raw) To: Jingbo Xu, xiang, huyue2, linux-erofs; +Cc: zhujia.zj, yinxin.x, linux-kernel On 2022/11/4 13:40, Jingbo Xu wrote: > For unmapped range, the returned map.m_llen is zero, and thus the > calculated count is unexpected zero. > > Prior to the refactoring introduced by commit 1ae9470c3e14 ("erofs: > clean up .read_folio() and .readahead() in fscache mode"), only the > readahead routine suffers from this. With the refactoring of making > .read_folio() and .readahead() calling one common routine, both > read_folio and readahead have this issue now. > > Fix this by calculating count separately in unmapped condition. > > Fixes: c665b394b9e8 ("erofs: implement fscache-based data readahead") > 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, ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-11-08 3:09 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-11-04 5:40 [PATCH 0/2] erofs: misc fixes for erofs in fscache mode Jingbo Xu 2022-11-04 5:40 ` [PATCH 1/2] erofs: put metabuf in error path " Jingbo Xu 2022-11-04 10:03 ` Gao Xiang 2022-11-07 14:41 ` [External] " Jia Zhu 2022-11-08 3:07 ` Chao Yu 2022-11-04 5:40 ` [PATCH 2/2] erofs: get correct count for unmapped range " Jingbo Xu 2022-11-04 10:03 ` Gao Xiang 2022-11-08 3:09 ` Chao Yu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox