All of lore.kernel.org
 help / color / mirror / Atom feed
From: yuchao0@huawei.com (Chao Yu)
Subject: [PATCH 1/7] staging: erofs: code cleanup for erofs_kmalloc()
Date: Thu, 13 Sep 2018 10:04:11 +0800	[thread overview]
Message-ID: <d6e3cc1c-2bb3-20ee-867c-b69893405b14@huawei.com> (raw)
In-Reply-To: <20180912051034.3463-2-cgxu519@gmx.com>

On 2018/9/12 13:10, Chengguang Xu wrote:
> Define a dummy function of time_to_inject(), so that we don't
> have to check macro CONFIG_EROFS_FAULT_INJECTION in calling place.
> Base on above adjustment, do proper code cleanup for erofs_kmalloc().
> 
> Signed-off-by: Chengguang Xu <cgxu519 at gmx.com>
> ---
>  drivers/staging/erofs/internal.h | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
> index 367b39fe46e5..1bb2e9e96143 100644
> --- a/drivers/staging/erofs/internal.h
> +++ b/drivers/staging/erofs/internal.h
> @@ -42,12 +42,12 @@
>  #define DBG_BUGON(...)          ((void)0)
>  #endif
>  
> -#ifdef CONFIG_EROFS_FAULT_INJECTION
>  enum {
>  	FAULT_KMALLOC,
>  	FAULT_MAX,
>  };
>  
> +#ifdef CONFIG_EROFS_FAULT_INJECTION
>  extern char *erofs_fault_name[FAULT_MAX];
>  #define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type)))
>  
> @@ -139,21 +139,25 @@ static inline bool time_to_inject(struct erofs_sb_info *sbi, int type)
>  	atomic_inc(&ffi->inject_ops);
>  	if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
>  		atomic_set(&ffi->inject_ops, 0);
> +		erofs_show_injection_info(type);

I prefer to show injection info in original place, where we can show real
caller of time_to_inject().

Thanks,

>  		return true;
>  	}
>  	return false;
>  }
> +
> +#else
> +static inline bool time_to_inject(struct erofs_sb_info *sbi, int type)
> +{
> +	return false;
> +}
>  #endif
>  
>  static inline void *erofs_kmalloc(struct erofs_sb_info *sbi,
>  					size_t size, gfp_t flags)
>  {
> -#ifdef CONFIG_EROFS_FAULT_INJECTION
> -	if (time_to_inject(sbi, FAULT_KMALLOC)) {
> -		erofs_show_injection_info(FAULT_KMALLOC);
> +	if (time_to_inject(sbi, FAULT_KMALLOC))
>  		return NULL;
> -	}
> -#endif
> +
>  	return kmalloc(size, flags);
>  }
>  
> 

  reply	other threads:[~2018-09-13  2:04 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 [this message]
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
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=d6e3cc1c-2bb3-20ee-867c-b69893405b14@huawei.com \
    --to=yuchao0@huawei.com \
    /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.