Message ID | 20211227125444.21187-13-jefflexu@linux.alibaba.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fscache,erofs: fscache-based demand-read semantics | expand |
Hi Jeffle,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on dhowells-fs/fscache-next]
[cannot apply to xiang-erofs/dev-test ceph-client/for-linus linus/master v5.16-rc7 next-20211224]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jeffle-Xu/fscache-erofs-fscache-based-demand-read-semantics/20211227-205742
base: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-next
config: m68k-defconfig (https://download.01.org/0day-ci/archive/20211228/202112280115.O0H8Ow1Q-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c3453b91df3b4e89c3336453437f761d6cb6bca3
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeffle-Xu/fscache-erofs-fscache-based-demand-read-semantics/20211227-205742
git checkout c3453b91df3b4e89c3336453437f761d6cb6bca3
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>, old ones prefixed by <<):
ERROR: modpost: "netfs_subreq_terminated" [fs/erofs/erofs.ko] undefined!
>> ERROR: modpost: "netfs_readpage" [fs/erofs/erofs.ko] undefined!
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Jeffle, Thank you for the patch! Yet something to improve: [auto build test ERROR on dhowells-fs/fscache-next] [cannot apply to xiang-erofs/dev-test ceph-client/for-linus linus/master v5.16-rc7 next-20211224] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Jeffle-Xu/fscache-erofs-fscache-based-demand-read-semantics/20211227-205742 base: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-next config: x86_64-randconfig-a014-20211227 (https://download.01.org/0day-ci/archive/20211228/202112280132.0kJ8Vjql-lkp@intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/c3453b91df3b4e89c3336453437f761d6cb6bca3 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Jeffle-Xu/fscache-erofs-fscache-based-demand-read-semantics/20211227-205742 git checkout c3453b91df3b4e89c3336453437f761d6cb6bca3 # save the config file to linux build tree mkdir build_dir make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): vmlinux.o: warning: objtool: do_machine_check()+0x89f: call to queue_task_work() leaves .noinstr.text section vmlinux.o: warning: objtool: enter_from_user_mode()+0x4e: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode()+0x59: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare()+0x4e: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode()+0x4e: call to on_thread_stack() leaves .noinstr.text section ld: fs/erofs/fscache.o: in function `erofs_issue_op': fs/erofs/fscache.c:27: undefined reference to `netfs_subreq_terminated' ld: fs/erofs/fscache.o: in function `erofs_readpage_from_fscache': >> fs/erofs/fscache.c:59: undefined reference to `netfs_readpage' vim +59 fs/erofs/fscache.c 35 36 struct page *erofs_readpage_from_fscache(struct erofs_cookie_ctx *ctx, 37 pgoff_t index) 38 { 39 struct folio *folio; 40 struct page *page; 41 struct super_block *sb = ctx->inode->i_sb; 42 int ret; 43 44 page = find_or_create_page(ctx->inode->i_mapping, index, GFP_KERNEL); 45 if (unlikely(!page)) { 46 erofs_err(sb, "failed to allocate page"); 47 return ERR_PTR(-ENOMEM); 48 } 49 50 /* The content is already buffered in the address space */ 51 if (PageUptodate(page)) { 52 unlock_page(page); 53 return page; 54 } 55 56 /* Or a new page cache is created, then read the content from fscache */ 57 folio = page_folio(page); 58 > 59 ret = netfs_readpage(NULL, folio, &erofs_req_ops, ctx->cookie); 60 if (unlikely(ret || !PageUptodate(page))) { 61 erofs_err(sb, "failed to read from fscache"); 62 return ERR_PTR(-EINVAL); 63 } 64 65 return page; 66 } 67 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 61fa431d0713..f0857c285fac 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -19,8 +19,8 @@ struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr) page = read_cache_page_gfp(mapping, blkaddr, mapping_gfp_constraint(mapping, ~__GFP_FS)); } else { - /* TODO: data path in nodev mode */ - page = ERR_PTR(-EINVAL); + page = erofs_readpage_from_fscache(EROFS_SB(sb)->bootstrap, + blkaddr); } /* should already be PageUptodate */ diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 4dfca7c95710..325f5663836b 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -6,6 +6,65 @@ static struct fscache_volume *volume; +static int erofs_begin_cache_operation(struct netfs_read_request *rreq) +{ + return fscache_begin_read_operation(&rreq->cache_resources, + rreq->netfs_priv); +} + +static void erofs_priv_cleanup(struct address_space *mapping, void *netfs_priv) +{ +} + +static void erofs_issue_op(struct netfs_read_subrequest *subreq) +{ + /* + * TODO: implement demand-read logic later. + * We rely on user daemon to prepare blob files under corresponding + * directory, and we can reach here if blob files don't exist. + */ + + netfs_subreq_terminated(subreq, -EOPNOTSUPP, false); +} + +const struct netfs_read_request_ops erofs_req_ops = { + .begin_cache_operation = erofs_begin_cache_operation, + .cleanup = erofs_priv_cleanup, + .issue_op = erofs_issue_op, +}; + +struct page *erofs_readpage_from_fscache(struct erofs_cookie_ctx *ctx, + pgoff_t index) +{ + struct folio *folio; + struct page *page; + struct super_block *sb = ctx->inode->i_sb; + int ret; + + page = find_or_create_page(ctx->inode->i_mapping, index, GFP_KERNEL); + if (unlikely(!page)) { + erofs_err(sb, "failed to allocate page"); + return ERR_PTR(-ENOMEM); + } + + /* The content is already buffered in the address space */ + if (PageUptodate(page)) { + unlock_page(page); + return page; + } + + /* Or a new page cache is created, then read the content from fscache */ + folio = page_folio(page); + + ret = netfs_readpage(NULL, folio, &erofs_req_ops, ctx->cookie); + if (unlikely(ret || !PageUptodate(page))) { + erofs_err(sb, "failed to read from fscache"); + return ERR_PTR(-EINVAL); + } + + return page; +} + static int erofs_fscache_init_cookie(struct erofs_cookie_ctx *ctx, char *path) { struct fscache_cookie *cookie; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 4ee4ff6774ba..10fb7ef26ddf 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -585,6 +585,9 @@ struct erofs_cookie_ctx *erofs_fscache_get_ctx(struct super_block *sb, char *path); void erofs_fscache_put_ctx(struct erofs_cookie_ctx *ctx); +struct page *erofs_readpage_from_fscache(struct erofs_cookie_ctx *ctx, + pgoff_t index); + #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ #endif /* __EROFS_INTERNAL_H */ diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 141cabd01d32..0e5964d8b24b 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -334,25 +334,22 @@ static int erofs_init_devices(struct super_block *sb, static int erofs_read_superblock(struct super_block *sb) { - struct erofs_sb_info *sbi; + struct erofs_sb_info *sbi = EROFS_SB(sb); struct page *page; struct erofs_super_block *dsb; unsigned int blkszbits; void *data; int ret; - /* TODO: metadata path in nodev mode */ if (sb->s_bdev) page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL); else - page = ERR_PTR(-EOPNOTSUPP); + page = erofs_readpage_from_fscache(sbi->bootstrap, 0); if (IS_ERR(page)) { erofs_err(sb, "cannot read erofs superblock"); return PTR_ERR(page); } - sbi = EROFS_SB(sb); - data = kmap(page); dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
This patch implements the data plane of reading metadata from bootstrap blob file over fscache. Be noted that currently it only supports the scenario where the backing file has no hole. Once it hits a hole of the backing file, erofs will fail the IO with -EOPNOTSUPP for now. The following patch will fix this issue, i.e. implementing the demand reading mode. Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com> --- fs/erofs/data.c | 4 +-- fs/erofs/fscache.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ fs/erofs/internal.h | 3 +++ fs/erofs/super.c | 7 ++---- 4 files changed, 66 insertions(+), 7 deletions(-)