Replace mount option "f2fs_injection" by injection attributes in sysfs.
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/f2fs.h | 24 ++++++++++++++++++------ fs/f2fs/super.c | 15 --------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e18390b..81e3fad 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -60,15 +60,28 @@ struct f2fs_fault_info { }; extern struct f2fs_fault_info f2fs_fault; -extern u32 f2fs_fault_rate; -extern atomic_t f2fs_ops; extern char *fault_name[FAULT_MAX]; static inline bool time_to_inject(int type) { - atomic_inc(&f2fs_ops); - if (f2fs_fault_rate && (atomic_read(&f2fs_ops) >= f2fs_fault_rate)) { - atomic_set(&f2fs_ops, 0); + if (!f2fs_fault.inject_rate) + return false; + if (type == FAULT_KMALLOC && !f2fs_fault.inject_kmalloc) + return false; + else if (type == FAULT_PAGE_ALLOC && !f2fs_fault.inject_page_alloc) + return false; + else if (type == FAULT_ALLOC_NID && !f2fs_fault.inject_nid_alloc) + return false; + else if (type == FAULT_ORPHAN && !f2fs_fault.inject_orphan) + return false; + else if (type == FAULT_BLOCK && !f2fs_fault.inject_block) + return false; + else if (type == FAULT_DIR_DEPTH && !f2fs_fault.inject_dir_depth) + return false; + + atomic_inc(&f2fs_fault.inject_ops); + if (atomic_read(&f2fs_fault.inject_ops) >= f2fs_fault.inject_rate) { + atomic_set(&f2fs_fault.inject_ops, 0); printk("%sF2FS-fs : inject %s in %pF\n", KERN_INFO, fault_name[type], @@ -98,7 +111,6 @@ static inline bool time_to_inject(int type) #define F2FS_MOUNT_EXTENT_CACHE 0x00002000 #define F2FS_MOUNT_FORCE_FG_GC 0x00004000 #define F2FS_MOUNT_DATA_FLUSH 0x00008000 -#define F2FS_MOUNT_FAULT_INJECTION 0x00010000 #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option) #define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index a9066e4..1dfd854 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -41,8 +41,6 @@ static struct kset *f2fs_kset; #ifdef CONFIG_F2FS_FAULT_INJECTION struct f2fs_fault_info f2fs_fault; -u32 f2fs_fault_rate = 0; -atomic_t f2fs_ops; char *fault_name[FAULT_MAX] = { [FAULT_KMALLOC] = "kmalloc", @@ -89,7 +87,6 @@ enum { Opt_noextent_cache, Opt_noinline_data, Opt_data_flush, - Opt_fault_injection, Opt_err, }; @@ -115,7 +112,6 @@ static match_table_t f2fs_tokens = { {Opt_noextent_cache, "noextent_cache"}, {Opt_noinline_data, "noinline_data"}, {Opt_data_flush, "data_flush"}, - {Opt_fault_injection, "fault_injection=%u"}, {Opt_err, NULL}, }; @@ -501,17 +497,6 @@ static int parse_options(struct super_block *sb, char *options) case Opt_data_flush: set_opt(sbi, DATA_FLUSH); break; - case Opt_fault_injection: - if (args->from && match_int(args, &arg)) - return -EINVAL; -#ifdef CONFIG_F2FS_FAULT_INJECTION - f2fs_fault_rate = arg; - atomic_set(&f2fs_ops, 0); -#else - f2fs_msg(sb, KERN_INFO, - "FAULT_INJECTION was not selected"); -#endif - break; default: f2fs_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" or missing value", -- 2.7.1 ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel