linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: weiping zhang <zhangweiping@didichuxing.com>
Cc: axboe@kernel.dk, jack@suse.cz, linux-block@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 1/4] bdi: add check for bdi_debug_root
Date: Mon, 30 Oct 2017 14:00:28 +0100	[thread overview]
Message-ID: <20171030130028.GG23278@quack2.suse.cz> (raw)
In-Reply-To: <883f8bb529fbde0d4adc2b78ba3bbda81e1ce6a0.1509038624.git.zhangweiping@didichuxing.com>

On Fri 27-10-17 01:35:36, weiping zhang wrote:
> this patch add a check for bdi_debug_root and do error handle for it.
> we should make sure it was created success, otherwise when add new
> block device's bdi folder(eg, 8:0) will be create a debugfs root directory.
> 
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> ---
>  mm/backing-dev.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)

These functions get called only on system boot - ENOMEM in those cases is
generally considered fatal and oopsing is acceptable result. So I don't
think this patch is needed.

								Honza

> 
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index 74b52dfd5852..5072be19d9b2 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -36,9 +36,12 @@ struct workqueue_struct *bdi_wq;
>  
>  static struct dentry *bdi_debug_root;
>  
> -static void bdi_debug_init(void)
> +static int bdi_debug_init(void)
>  {
>  	bdi_debug_root = debugfs_create_dir("bdi", NULL);
> +	if (!bdi_debug_root)
> +		return -ENOMEM;
> +	return 0;
>  }
>  
>  static int bdi_debug_stats_show(struct seq_file *m, void *v)
> @@ -126,8 +129,9 @@ static void bdi_debug_unregister(struct backing_dev_info *bdi)
>  	debugfs_remove(bdi->debug_dir);
>  }
>  #else
> -static inline void bdi_debug_init(void)
> +static inline int bdi_debug_init(void)
>  {
> +	return 0;
>  }
>  static inline void bdi_debug_register(struct backing_dev_info *bdi,
>  				      const char *name)
> @@ -229,12 +233,19 @@ ATTRIBUTE_GROUPS(bdi_dev);
>  
>  static __init int bdi_class_init(void)
>  {
> +	int ret;
> +
>  	bdi_class = class_create(THIS_MODULE, "bdi");
>  	if (IS_ERR(bdi_class))
>  		return PTR_ERR(bdi_class);
>  
>  	bdi_class->dev_groups = bdi_dev_groups;
> -	bdi_debug_init();
> +	ret = bdi_debug_init();
> +	if (ret) {
> +		class_destroy(bdi_class);
> +		bdi_class = NULL;
> +		return ret;
> +	}
>  
>  	return 0;
>  }
> -- 
> 2.14.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-10-30 13:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 17:35 [PATCH 0/4] add error handle for bdi debugfs register weiping zhang
2017-10-26 17:35 ` [PATCH 1/4] bdi: add check for bdi_debug_root weiping zhang
2017-10-30 13:00   ` Jan Kara [this message]
2017-10-31 10:30     ` weiping zhang
2017-10-26 17:35 ` [PATCH 2/4] bdi: convert bdi_debug_register to int weiping zhang
2017-10-30 13:01   ` Jan Kara
2017-10-26 17:36 ` [PATCH 3/4] bdi: add error handle for bdi_debug_register weiping zhang
2017-10-30 13:10   ` Jan Kara
2017-10-31 10:33     ` weiping zhang
2017-10-26 17:36 ` [PATCH 4/4] block: add WARN_ON if bdi register fail weiping zhang
2017-10-30 13:14   ` Jan Kara
2017-10-31 10:34     ` weiping zhang

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=20171030130028.GG23278@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhangweiping@didichuxing.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox