diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-03-25 05:19:33 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-31 11:26:59 -0400 |
commit | b5230b56ee6caeb27cedb7753c0c319646383bb4 (patch) | |
tree | a8cb9730ba9d89346d3bd959393e72c84b36ce84 /kernel/trace/blktrace.c | |
parent | 6c051ce0307526adec32a847f0daa1af2124f0a9 (diff) |
blktrace: fix a race when creating blk_tree_root in debugfs
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>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r-- | 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 ee7a8bb8b1e8..95f89faca73e 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, | |||
426 | 426 | ||
427 | ret = -ENOENT; | 427 | ret = -ENOENT; |
428 | 428 | ||
429 | mutex_lock(&blk_tree_mutex); | ||
429 | if (!blk_tree_root) { | 430 | if (!blk_tree_root) { |
430 | blk_tree_root = debugfs_create_dir("block", NULL); | 431 | blk_tree_root = debugfs_create_dir("block", NULL); |
431 | if (!blk_tree_root) | 432 | if (!blk_tree_root) { |
433 | mutex_unlock(&blk_tree_mutex); | ||
432 | goto err; | 434 | goto err; |
435 | } | ||
433 | } | 436 | } |
437 | mutex_unlock(&blk_tree_mutex); | ||
434 | 438 | ||
435 | dir = debugfs_create_dir(buts->name, blk_tree_root); | 439 | dir = debugfs_create_dir(buts->name, blk_tree_root); |
436 | 440 | ||