From: Li Zefan <lizf@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Jens Axboe <jens.axboe@oracle.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] blktrace: fix a race when creating blk_tree_root in debugfs
Date: Wed, 25 Mar 2009 17:19:33 +0800 [thread overview]
Message-ID: <49C9F725.9080409@cn.fujitsu.com> (raw)
In-Reply-To: <49C9F700.9070609@cn.fujitsu.com>
t1 t2
------ ------
do_blk_trace_setup() do_blk_trace_setup()
if (!blk_tree_root) {
if (!blk_tree_root)
blk_tree_root = create_dir()
blk_tree_root = create_dir();
(now blk_tree_root == NULL)
...
dir = create_dir(name, blk_tree_root);
Due to this race, t1 will create 'dir' in /debugfs but not /debugfs/block.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/trace/blktrace.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index ee7a8bb..95f89fa 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -426,11 +426,15 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
ret = -ENOENT;
+ mutex_lock(&blk_tree_mutex);
if (!blk_tree_root) {
blk_tree_root = debugfs_create_dir("block", NULL);
- if (!blk_tree_root)
+ if (!blk_tree_root) {
+ mutex_unlock(&blk_tree_mutex);
goto err;
+ }
}
+ mutex_unlock(&blk_tree_mutex);
dir = debugfs_create_dir(buts->name, blk_tree_root);
--
1.5.4.rc3
next prev parent reply other threads:[~2009-03-25 9:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 9:18 [PATCH 1/3] blktrace: fix timestamp in binary output Li Zefan
2009-03-25 9:19 ` Li Zefan [this message]
2009-03-25 11:54 ` [tip:tracing/blktrace] blktrace: fix a race when creating blk_tree_root in debugfs Li Zefan
2009-03-25 9:21 ` [PATCH 3/3] blktrace: fix the original blktrace Li Zefan
2009-03-25 10:14 ` Ingo Molnar
2009-03-25 10:17 ` Jens Axboe
2009-03-25 11:47 ` Ingo Molnar
2009-03-25 13:51 ` Arnaldo Carvalho de Melo
2009-03-25 13:56 ` Jens Axboe
2009-03-25 14:07 ` Arnaldo Carvalho de Melo
2009-03-26 2:13 ` Li Zefan
2009-03-26 8:29 ` Jens Axboe
2009-03-26 13:37 ` Ingo Molnar
2009-03-26 15:14 ` Arnaldo Carvalho de Melo
2009-03-26 15:44 ` Jens Axboe
2009-03-26 17:07 ` Arnaldo Carvalho de Melo
2009-03-27 0:21 ` Li Zefan
2009-03-25 11:54 ` [tip:tracing/blktrace] " Li Zefan
2009-03-25 11:54 ` [tip:tracing/blktrace] blktrace: fix timestamp in binary output Li Zefan
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=49C9F725.9080409@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=acme@redhat.com \
--cc=fweisbec@gmail.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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.