erofs: remove the constraint of 4KB blksize for fscache mode
cover erofs: remove the constraint of 4KB blksize for fscache mode
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(-)
Signature · 1 line
2.19.1.6.gb485710b
PATCH 1/2 erofs: pass accurate blob size to prepare_ondemand_read()
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.
--- fs/erofs/fscache.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/erofs/fscache.c +11 -2
@@ -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 ) {
Signature · 1 line
2.19.1.6.gb485710b
PATCH 2/2 erofs: set blksize to on-disk blksize for fscache mode
In reply to Jingbo XuSince 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.
--- fs/erofs/super.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-)
fs/erofs/super.c +20 -18
@@ -709,6 +709,17 @@ static int erofs_fc_fill_pseudo_super(struct super_block *sb, struct fs_contextreturn 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 )) {
Signature · 1 line
2.19.1.6.gb485710b