erofs: convert to use the new mount fs_context api
PATCH v6 1/1 erofs: convert to use the new mount fs_context api
From: Chao Yu <[email protected]>
Convert the erofs to use new internal mount API as the old one will be obsoleted and removed. This allows greater flexibility in communication of mount parameters between userspace, the VFS and the filesystem.
See Documentation/filesystems/mount_api.txt for more information.
Cc Al Viro <[email protected]>
Cc David Howells <[email protected]>
Signed-off-by Chao Yu <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
---
changes since v5:
- rebased on the top of erofs dev branch as Al said [1].
[1] https://lore.kernel.org/r/[email protected]
fs/erofs/internal.h | 27 +++-- fs/erofs/super.c | 253 ++++++++++++++++++++------------------------ fs/erofs/xattr.c | 4 +- fs/erofs/zdata.c | 4 +- 4 files changed, 132 insertions(+), 156 deletions(-)
fs/erofs/internal.h +16 -11
@@ -46,6 +46,17 @@ typedef u64 erofs_off_t;/* data type for filesystem-wide blocks number */ typedef u32 erofs_blk_t ; +struct erofs_fs_context { +#ifdef CONFIG_EROFS_FS_ZIP +/* current strategy of how to use managed cache */ +unsigned char cache_strategy; + +/* threshold for decompression synchronously */ +unsigned int max_sync_decompress_pages; +#endif +unsigned int mount_opt; +}; +struct erofs_sb_info {#ifdef CONFIG_EROFS_FS_ZIP /* list for all registered superblocks, mainly for shrinker */
@@ -55,14 +66,8 @@ struct erofs_sb_info {/* managed XArray arranged in physical block number */ struct xarray managed_pslots; -/* threshold for decompression synchronously */ -unsigned int max_sync_decompress_pages; -unsigned int shrinker_run_no; -/* current strategy of how to use managed cache */ -unsigned char cache_strategy; -/* pseudo inode to manage cached pages */ struct inode *managed_cache;#endif /* CONFIG_EROFS_FS_ZIP */
@@ -88,7 +93,7 @@ struct erofs_sb_info {u32 feature_compat;u32 feature_incompat; -unsigned int mount_opt; +struct erofs_fs_context ctx;/* options */ };#define EROFS_SB (sb) ((struct erofs_sb_info *)(sb)->s_fs_info)
@@ -98,17 +103,17 @@ struct erofs_sb_info {#define EROFS_MOUNT_XATTR_USER 0x00000010#define EROFS_MOUNT_POSIX_ACL 0x00000020 -#define clear_opt (sbi, option) ((sbi)->mount_opt &= ~EROFS_MOUNT_##option) -#define set_opt (sbi, option) ((sbi)->mount_opt |= EROFS_MOUNT_##option) -#define test_opt (sbi, option) ((sbi)->mount_opt & EROFS_MOUNT_##option) +#define clear_opt (ctx, option) ((ctx)->mount_opt &= ~EROFS_MOUNT_##option) +#define set_opt (ctx, option) ((ctx)->mount_opt |= EROFS_MOUNT_##option) +#define test_opt (ctx, option) ((ctx)->mount_opt & EROFS_MOUNT_##option) -#ifdef CONFIG_EROFS_FS_ZIP enum {EROFS_ZIP_CACHE_DISABLED ,EROFS_ZIP_CACHE_READAHEAD ,EROFS_ZIP_CACHE_READAROUND }; +#ifdef CONFIG_EROFS_FS_ZIP #define EROFS_LOCKED_MAGIC (INT_MIN | 0xE0F510CCL)/* basic unit of the workstation of a super_block */
fs/erofs/super.c +112 -141
355 lines not on this page · raw message
fs/erofs/xattr.c +2 -2
@@ -422,7 +422,7 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)static bool erofs_xattr_user_list (struct dentry *dentry) { -return test_opt (EROFS_SB (dentry->d_sb),XATTR_USER ); +return test_opt (&EROFS_SB (dentry->d_sb)->ctx,XATTR_USER ); }static bool erofs_xattr_trusted_list (struct dentry *dentry)
@@ -469,7 +469,7 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,switch (handler->flags) {case EROFS_XATTR_INDEX_USER : -if (!test_opt (sbi,XATTR_USER )) +if (!test_opt (&sbi->ctx,XATTR_USER ))return -EOPNOTSUPP ;break ;case EROFS_XATTR_INDEX_TRUSTED :
fs/erofs/zdata.c +2 -2
@@ -615,7 +615,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, goto err_out;/* preload all compressed pages (maybe downgrade role if necessary) */ -if (should_alloc_managed_pages (fe, sbi->cache_strategy, map->m_la)) +if (should_alloc_managed_pages (fe, sbi->ctx.cache_strategy, map->m_la)) cache_strategy =DELAYEDALLOC ;else cache_strategy =DONTALLOC ;
@@ -1302,7 +1302,7 @@ static int z_erofs_readpage(struct file *file, struct page *page)static bool should_decompress_synchronously (struct erofs_sb_info *sbi,unsigned int nr) { -return nr <= sbi->max_sync_decompress_pages; +return nr <= sbi->ctx.max_sync_decompress_pages; } static int z_erofs_readpages(struct file *filp, struct address_space *mapping,
Signature · 1 line
2.18.1