Commit 01e4ae4b authored by Chengguang Xu's avatar Chengguang Xu Committed by Greg Kroah-Hartman

staging: erofs: code cleanup for option parsing of fault_injection

Define a dummpy function of erofs_build_fault_attr() when macro
CONFIG_EROFS_FAULT_INJECTION is disabled, so that we don't have to
check the macro in calling place. Based on above adjustment,
do proper code cleanup for option parsing of fault_injection.
Signed-off-by: default avatarChengguang Xu <cgxu519@gmx.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Reviewed-by: default avatarGao Xiang <gaoxiang25@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6614f765
...@@ -145,10 +145,14 @@ char *erofs_fault_name[FAULT_MAX] = { ...@@ -145,10 +145,14 @@ char *erofs_fault_name[FAULT_MAX] = {
[FAULT_KMALLOC] = "kmalloc", [FAULT_KMALLOC] = "kmalloc",
}; };
static void erofs_build_fault_attr(struct erofs_sb_info *sbi, static int erofs_build_fault_attr(struct erofs_sb_info *sbi,
unsigned int rate) substring_t *args)
{ {
struct erofs_fault_info *ffi = &sbi->fault_info; struct erofs_fault_info *ffi = &sbi->fault_info;
int rate = 0;
if (args->from && match_int(args, &rate))
return -EINVAL;
if (rate) { if (rate) {
atomic_set(&ffi->inject_ops, 0); atomic_set(&ffi->inject_ops, 0);
...@@ -157,6 +161,16 @@ static void erofs_build_fault_attr(struct erofs_sb_info *sbi, ...@@ -157,6 +161,16 @@ static void erofs_build_fault_attr(struct erofs_sb_info *sbi,
} else { } else {
memset(ffi, 0, sizeof(struct erofs_fault_info)); memset(ffi, 0, sizeof(struct erofs_fault_info));
} }
set_opt(sbi, FAULT_INJECTION);
return 0;
}
#else
static int erofs_build_fault_attr(struct erofs_sb_info *sbi,
substring_t *args)
{
infoln("fault_injection options not supported");
return 0;
} }
#endif #endif
...@@ -198,7 +212,7 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -198,7 +212,7 @@ static int parse_options(struct super_block *sb, char *options)
{ {
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
char *p; char *p;
int arg = 0; int err;
if (!options) if (!options)
return 0; return 0;
...@@ -243,18 +257,12 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -243,18 +257,12 @@ static int parse_options(struct super_block *sb, char *options)
infoln("noacl options not supported"); infoln("noacl options not supported");
break; break;
#endif #endif
#ifdef CONFIG_EROFS_FAULT_INJECTION
case Opt_fault_injection: case Opt_fault_injection:
if (args->from && match_int(args, &arg)) err = erofs_build_fault_attr(EROFS_SB(sb), args);
return -EINVAL; if (err)
erofs_build_fault_attr(EROFS_SB(sb), arg); return err;
set_opt(EROFS_SB(sb), FAULT_INJECTION);
break; break;
#else
case Opt_fault_injection:
infoln("fault_injection options not supported");
break;
#endif
default: default:
errln("Unrecognized mount option \"%s\" " errln("Unrecognized mount option \"%s\" "
"or missing value", p); "or missing value", p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment