All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] erofs: split inline data reading and tail zeroing in fscache mode
@ 2022-12-01 10:58 Jingbo Xu
  0 siblings, 0 replies; only message in thread
From: Jingbo Xu @ 2022-12-01 10:58 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: linux-kernel

Prior to this patch, the INLINE routine will also zero the tail part of
the folio.  This is reasonable since currently for each file, only the
tail part over EROFS_BLKSIZ boundary is stored as tail packing format,
and thus the tail part in the same folio is treated as EOF and shall be
zeroed.

Since we have supported large folios now and
erofs_fscache_data_read_slice() can be called multiple times for each
folio or folio range, for tail packing format, we can defer zeroing the
EOF part to the UNMAPPED routine in the next calling of
erofs_fscache_data_read_slice().  This cleanup makes the INLINE routine
focusing on reading inline data, while zeroing is left to the UNMAPPED
routine.

Besides, make the naming consistent among INLINE/UNMAPPED/MAPPED
routines.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
v2: rename 'size' to 'count' to make git diff statistics more cleaner,
while v1 renames 'count' to 'size'

v1: https://lore.kernel.org/all/20221201075018.27925-1-jefflexu@linux.alibaba.com/
---
 fs/erofs/fscache.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index f14886c479bd..c9bf59aac5ac 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -214,35 +214,32 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary)
 	if (map.m_flags & EROFS_MAP_META) {
 		struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
 		erofs_blk_t blknr;
-		size_t offset, size;
+		size_t offset;
 		void *src;
 
 		/* For tail packing layout, the offset may be non-zero. */
 		offset = erofs_blkoff(map.m_pa);
 		blknr = erofs_blknr(map.m_pa);
-		size = map.m_llen;
+		count = map.m_llen;
 
 		src = erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP);
 		if (IS_ERR(src))
 			return PTR_ERR(src);
 
-		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
-		if (copy_to_iter(src + offset, size, &iter) != size) {
+		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count);
+		if (copy_to_iter(src + offset, count, &iter) != count) {
 			erofs_put_metabuf(&buf);
 			return -EFAULT;
 		}
-		iov_iter_zero(PAGE_SIZE - size, &iter);
 		erofs_put_metabuf(&buf);
-		primary->submitted += PAGE_SIZE;
-		return 0;
+		goto out;
 	}
 
 	count = primary->len - primary->submitted;
 	if (!(map.m_flags & EROFS_MAP_MAPPED)) {
 		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count);
 		iov_iter_zero(count, &iter);
-		primary->submitted += count;
-		return 0;
+		goto out;
 	}
 
 	count = min_t(size_t, map.m_llen - (pos - map.m_la), count);
@@ -263,6 +260,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary)
 	ret = erofs_fscache_read_folios_async(mdev.m_fscache->cookie,
 			req, mdev.m_pa + (pos - map.m_la), count);
 	erofs_fscache_req_put(req);
+out:
 	primary->submitted += count;
 	return ret;
 }
-- 
2.19.1.6.gb485710b


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-01 10:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 10:58 [PATCH v2] erofs: split inline data reading and tail zeroing in fscache mode Jingbo Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.