All of lore.kernel.org
 help / color / mirror / Atom feed
From: weiping zhang <zhangweiping@didichuxing.com>
To: axboe@kernel.dk, jack@suse.cz
Cc: linux-mm@kvack.org
Subject: [PATCH] bdi: add check before create debugfs dir or files
Date: Wed, 25 Oct 2017 23:23:18 +0800	[thread overview]
Message-ID: <20171025152312.GA23944@source.didichuxing.com> (raw)

we should make sure parents directory exist, and then create dir or
files under that.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 mm/backing-dev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 74b52dfd5852..81f4a86ebbed 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -115,9 +115,11 @@ static const struct file_operations bdi_debug_stats_fops = {
 
 static void bdi_debug_register(struct backing_dev_info *bdi, const char *name)
 {
-	bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root);
-	bdi->debug_stats = debugfs_create_file("stats", 0444, bdi->debug_dir,
-					       bdi, &bdi_debug_stats_fops);
+	if (bdi_debug_root)
+		bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root);
+	if (bdi->debug_dir)
+		bdi->debug_stats = debugfs_create_file("stats", 0444,
+				bdi->debug_dir, bdi, &bdi_debug_stats_fops);
 }
 
 static void bdi_debug_unregister(struct backing_dev_info *bdi)
-- 
2.14.2

--
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-25 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 15:23 weiping zhang [this message]
2017-10-26 13:54 ` [PATCH] bdi: add check before create debugfs dir or files Jan Kara
2017-10-26 14:33   ` 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=20171025152312.GA23944@source.didichuxing.com \
    --to=zhangweiping@didichuxing.com \
    --cc=axboe@kernel.dk \
    --cc=jack@suse.cz \
    --cc=linux-mm@kvack.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.