erofs: clean up erofs_show_options()
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Fri, 17 May 2024 09:56:52 +0000 (17:56 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Fri, 17 May 2024 17:42:18 +0000 (01:42 +0800)
Avoid unnecessary #ifdefs and simplify the code a bit.

Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240517095652.2282972-1-hongzhen@linux.alibaba.com
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/internal.h
fs/erofs/super.c

index 00bbb288c08caaae48a00683887d2215107d3923..c5254dc1f9653f537f802121b9a61a2a27d36da8 100644 (file)
@@ -64,15 +64,12 @@ enum {
 };
 
 struct erofs_mount_opts {
-#ifdef CONFIG_EROFS_FS_ZIP
        /* current strategy of how to use managed cache */
        unsigned char cache_strategy;
        /* strategy of sync decompression (0 - auto, 1 - force on, 2 - force off) */
        unsigned int sync_decompress;
-
        /* threshold for decompression synchronously */
        unsigned int max_sync_decompress_pages;
-#endif
        unsigned int mount_opt;
 };
 
index 348ef1660e50a413589a3d274b13748bbfe1d3b4..3013bfb2e9edc4fab0ddafa7e714e264afe1eba2 100644 (file)
@@ -943,26 +943,14 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
        struct erofs_sb_info *sbi = EROFS_SB(root->d_sb);
        struct erofs_mount_opts *opt = &sbi->opt;
 
-#ifdef CONFIG_EROFS_FS_XATTR
-       if (test_opt(opt, XATTR_USER))
-               seq_puts(seq, ",user_xattr");
-       else
-               seq_puts(seq, ",nouser_xattr");
-#endif
-#ifdef CONFIG_EROFS_FS_POSIX_ACL
-       if (test_opt(opt, POSIX_ACL))
-               seq_puts(seq, ",acl");
-       else
-               seq_puts(seq, ",noacl");
-#endif
-#ifdef CONFIG_EROFS_FS_ZIP
-       if (opt->cache_strategy == EROFS_ZIP_CACHE_DISABLED)
-               seq_puts(seq, ",cache_strategy=disabled");
-       else if (opt->cache_strategy == EROFS_ZIP_CACHE_READAHEAD)
-               seq_puts(seq, ",cache_strategy=readahead");
-       else if (opt->cache_strategy == EROFS_ZIP_CACHE_READAROUND)
-               seq_puts(seq, ",cache_strategy=readaround");
-#endif
+       if (IS_ENABLED(CONFIG_EROFS_FS_XATTR))
+               seq_puts(seq, test_opt(opt, XATTR_USER) ?
+                               ",user_xattr" : ",nouser_xattr");
+       if (IS_ENABLED(CONFIG_EROFS_FS_POSIX_ACL))
+               seq_puts(seq, test_opt(opt, POSIX_ACL) ? ",acl" : ",noacl");
+       if (IS_ENABLED(CONFIG_EROFS_FS_ZIP))
+               seq_printf(seq, ",cache_strategy=%s",
+                         erofs_param_cache_strategy[opt->cache_strategy].name);
        if (test_opt(opt, DAX_ALWAYS))
                seq_puts(seq, ",dax=always");
        if (test_opt(opt, DAX_NEVER))