mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] erofs: remove the constraint of 4KB blksize for fscache mode
@ 2023-02-21  9:17 Jingbo Xu
  2023-02-21  9:17 ` [PATCH 1/2] erofs: pass accurate blob size to prepare_ondemand_read() Jingbo Xu
  2023-02-21  9:17 ` [PATCH 2/2] erofs: set blksize to on-disk blksize for fscache mode Jingbo Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-02-21  9:17 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, zhujia.zj, linux-kernel

Make erofs in fscache mode support PAGE_SIZE larger than 4KB.  After
that we can remove the constraint of 4KB blksize for fscache mode.

This relies on some improvement to fscache/cachefiles sent soon.

Jingbo Xu (2):
  erofs: pass accurate blob size to prepare_ondemand_read()
  erofs: set blksize to on-disk blksize for fscache mode

 fs/erofs/fscache.c | 13 +++++++++++--
 fs/erofs/super.c   | 38 ++++++++++++++++++++------------------
 2 files changed, 31 insertions(+), 20 deletions(-)

-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] erofs: pass accurate blob size to prepare_ondemand_read()
  2023-02-21  9:17 [PATCH 0/2] erofs: remove the constraint of 4KB blksize for fscache mode Jingbo Xu
@ 2023-02-21  9:17 ` Jingbo Xu
  2023-02-21  9:17 ` [PATCH 2/2] erofs: set blksize to on-disk blksize for fscache mode Jingbo Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-02-21  9:17 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, zhujia.zj, linux-kernel

To make fscache mode support PAGE_SIZE larger than 4KB, the blob image
size may be small than the multiples of PAGE_SIZE (as erofs block size
is no larger than 4KB), while the file range of the blob requested to
read is multiples of PAGE_SIZE and may be larger than the blob image
size.

Therefore we need the accurate blob size, so that the EOF part could be
distinguished and zero-filled then.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 87ff35bff8d5..f7a1e147d0f4 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -125,7 +125,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 
 	DBG_BUGON(len > req->len - req->submitted);
 
-	ret = fscache_begin_read_operation(cres, cookie);
+	ret = fscache_begin_wait_operation(cres, cookie, FSCACHE_WANT_READ);
 	if (ret)
 		return ret;
 
@@ -134,8 +134,17 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 		size_t slen = len - done;
 		unsigned long flags = 1 << NETFS_SREQ_ONDEMAND;
 
+		if (sstart >= cookie->object_size) {
+			iov_iter_xarray(&iter, ITER_DEST, &req->mapping->i_pages,
+					lstart + done, slen);
+			iov_iter_zero(slen, &iter);
+			done += slen;
+			continue;
+		}
+
+		slen = min_t(size_t, slen, cookie->object_size - sstart);
 		source = cres->ops->prepare_ondemand_read(cres,
-				sstart, &slen, LLONG_MAX, &flags, 0);
+				sstart, &slen, cookie->object_size, &flags, 0);
 		if (WARN_ON(slen == 0))
 			source = NETFS_INVALID_READ;
 		if (source != NETFS_READ_FROM_CACHE) {
-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] erofs: set blksize to on-disk blksize for fscache mode
  2023-02-21  9:17 [PATCH 0/2] erofs: remove the constraint of 4KB blksize for fscache mode Jingbo Xu
  2023-02-21  9:17 ` [PATCH 1/2] erofs: pass accurate blob size to prepare_ondemand_read() Jingbo Xu
@ 2023-02-21  9:17 ` Jingbo Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-02-21  9:17 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, zhujia.zj, linux-kernel

Since fscache mode has supported PAGE_SIZE other than 4KB, remove the
constraint and set to on-disk blksize.

We need to initialize the fscache context for the bootstrap before
setting the initial blksize as it will also update anonymous inode's
i_blkbits for the bootstrap.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/super.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 89011a4ed274..130e0f6db3c7 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -709,6 +709,17 @@ static int erofs_fc_fill_pseudo_super(struct super_block *sb, struct fs_context
 	return simple_fill_super(sb, EROFS_SUPER_MAGIC, &empty_descr);
 }
 
+static bool erofs_set_block_size(struct super_block *sb, unsigned int blkszbits)
+{
+	if (!erofs_is_fscache_mode(sb))
+		return sb_set_blocksize(sb, 1 << blkszbits);
+
+	sb->s_blocksize = 1 << blkszbits;
+	sb->s_blocksize_bits = blkszbits;
+	EROFS_SB(sb)->s_fscache->inode->i_blkbits = blkszbits;
+	return true;
+}
+
 static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *inode;
@@ -734,11 +745,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 	sbi->domain_id = ctx->domain_id;
 	ctx->domain_id = NULL;
 
-	sbi->blkszbits = PAGE_SHIFT;
 	if (erofs_is_fscache_mode(sb)) {
-		sb->s_blocksize = PAGE_SIZE;
-		sb->s_blocksize_bits = PAGE_SHIFT;
-
 		err = erofs_fscache_register_fs(sb);
 		if (err)
 			return err;
@@ -747,29 +754,24 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 		if (err)
 			return err;
 	} else {
-		if (!sb_set_blocksize(sb, PAGE_SIZE)) {
-			errorfc(fc, "failed to set initial blksize");
-			return -EINVAL;
-		}
-
 		sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev,
 						  &sbi->dax_part_off,
 						  NULL, NULL);
 	}
 
+	if (!erofs_set_block_size(sb, PAGE_SHIFT)) {
+		errorfc(fc, "failed to set initial blksize");
+		return -EINVAL;
+	}
+
 	err = erofs_read_superblock(sb);
 	if (err)
 		return err;
 
-	if (sb->s_blocksize_bits != sbi->blkszbits) {
-		if (erofs_is_fscache_mode(sb)) {
-			errorfc(fc, "unsupported blksize for fscache mode");
-			return -EINVAL;
-		}
-		if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
-			errorfc(fc, "failed to set erofs blksize");
-			return -EINVAL;
-		}
+	if (sb->s_blocksize_bits != sbi->blkszbits &&
+	    !erofs_set_block_size(sb, sbi->blkszbits)) {
+		errorfc(fc, "failed to set erofs blksize");
+		return -EINVAL;
 	}
 
 	if (test_opt(&sbi->opt, DAX_ALWAYS)) {
-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-21  9:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21  9:17 [PATCH 0/2] erofs: remove the constraint of 4KB blksize for fscache mode Jingbo Xu
2023-02-21  9:17 ` [PATCH 1/2] erofs: pass accurate blob size to prepare_ondemand_read() Jingbo Xu
2023-02-21  9:17 ` [PATCH 2/2] erofs: set blksize to on-disk blksize for fscache mode Jingbo Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®