All of lore.kernel.org
 help / color / mirror / Atom feed
From: chao@kernel.org (Chao Yu)
Subject: [PATCH 2/7] staging: erofs: code cleanup for option parsing of fault_injection
Date: Fri, 14 Sep 2018 23:22:50 +0800	[thread overview]
Message-ID: <fac1ec54-8a23-c1c4-d0ea-db6e5e88ef26@kernel.org> (raw)
In-Reply-To: <c9b83793-b630-8172-6953-60604c81893a@gmx.com>

On 2018/9/13 13:46, cgxu519 wrote:
> On 09/13/2018 10:15 AM, Chao Yu wrote:
>> On 2018/9/12 13:10, Chengguang Xu wrote:
>>> 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: Chengguang Xu <cgxu519 at gmx.com>
>>> ---
>>> ? drivers/staging/erofs/super.c | 33 ++++++++++++++++++++++-----------
>>> ? 1 file changed, 22 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
>>> index 1aec509c805f..14dbb6517b8d 100644
>>> --- a/drivers/staging/erofs/super.c
>>> +++ b/drivers/staging/erofs/super.c
>>> @@ -144,18 +144,33 @@ char *erofs_fault_name[FAULT_MAX] = {
>>> ????? [FAULT_KMALLOC]??????? = "kmalloc",
>>> ? };
>>> ? -static void erofs_build_fault_attr(struct erofs_sb_info *sbi,
>>> -??????????????????????? unsigned int rate)
>>> +static int erofs_build_fault_attr(struct erofs_sb_info *sbi,
>>> +??????????????????? substring_t *args)
>>> ? {
>>> ????? struct erofs_fault_info *ffi = &sbi->fault_info;
>>> +??? int rate = 0;
>>> +
>>> +??? if (args->from && match_int(args, &rate))
>>> +??????? return -EINVAL;
>>> ? ????? if (rate) {
>>> ????????? atomic_set(&ffi->inject_ops, 0);
>>> ????????? ffi->inject_rate = rate;
>>> ????????? ffi->inject_type = (1 << FAULT_MAX) - 1;
>>> +??????? set_opt(sbi, FAULT_INJECTION);
>>> ????? } else {
>>> ????????? memset(ffi, 0, sizeof(struct erofs_fault_info));
>>> +??????? clear_opt(sbi, FAULT_INJECTION);
>> Hmmm, if user mounts/remounts image with -o fault_injection=0, user can not
>> check such info in anywhere, as we skip showing this option due to lack of
>> EROFS_MOUNT_FAULT_INJECTION bit. How about keeping this bit?
>>
> 
> IIUC, the purpose of fault_injection=0 is for disabling fault injection function,
> so isn't it the same as default? Should we distinguish explicit setting value 0

IMO, if user set fault_injection=0 during mount, it means user want to enable
this feature but currently user want to set the rate to zero, later user may
change it to non-zero. And with EROFS_MOUNT_FAULT_INJECTION being set, user can
check current rate value via ->show_options.

Thanks,

> and default value 0?
> 
> Thanks,
> Chengguang
> 
> 
> 
> 
> 
> 

  reply	other threads:[~2018-09-14 15:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12  5:10 [PATCH 0/7] staging: erofs: option validation for remount and some code cleanups Chengguang Xu
2018-09-12  5:10 ` [PATCH 1/7] staging: erofs: code cleanup for erofs_kmalloc() Chengguang Xu
2018-09-13  2:04   ` Chao Yu
2018-09-13  5:37     ` cgxu519
2018-09-12  5:10 ` [PATCH 2/7] staging: erofs: code cleanup for option parsing of fault_injection Chengguang Xu
2018-09-13  2:15   ` Chao Yu
2018-09-13  5:46     ` cgxu519
2018-09-14 15:22       ` Chao Yu [this message]
2018-09-17 13:52         ` cgxu519
2018-09-17 14:28           ` Chao Yu
2018-09-12  5:10 ` [PATCH 3/7] staging: erofs: introduce a new helper __erofs_build_fault_attr() Chengguang Xu
2018-09-12 11:22   ` Gao Xiang
2018-09-12 14:23     ` cgxu519
2018-09-12 14:50       ` Gao Xiang
2018-09-12 15:01         ` cgxu519
2018-09-12  5:10 ` [PATCH 4/7] staging: erofs: return -EINVAL when specifying fault rate to 0 Chengguang Xu
2018-09-12  9:16   ` Dan Carpenter
2018-09-12 14:05     ` cgxu519
2018-09-12 14:25       ` Dan Carpenter
2018-09-12 14:41         ` cgxu519
2018-09-12  5:10 ` [PATCH 5/7] staging: erofs: introduce a new helper erofs_get_fault_rate() Chengguang Xu
2018-09-12  5:10 ` [PATCH 6/7] staging: erofs: code cleanup for erofs_show_options() Chengguang Xu
2018-09-12  5:10 ` [PATCH 7/7] staging: erofs: option validation in remount Chengguang Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fac1ec54-8a23-c1c4-d0ea-db6e5e88ef26@kernel.org \
    --to=chao@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.