aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2007-11-21 06:25:41 -0500
committerJens Axboe <jens.axboe@oracle.com>2007-11-27 03:19:39 -0500
commit35fc51e7a5056889421270c1fb63d8ec45fbccf4 (patch)
tree775462a1cc541b5442648343293f50263f5beb45 /block
parent8c27eba54970c6ebbb408186e5baa2274435e869 (diff)
blktrace: Make sure BLKTRACETEARDOWN does the full cleanup.
if blktrace program segfault it will not be able to call BLKTRACETEARDOWN. Now if we run the blktrace again that would result in a failure to create the block/<device> debugfs directory.This will result in blk_remove_root() to be called which will set blk_tree_root to NULL. But the debugfs block dir still exist because it contain subdirectory. Now if we try to fix it using BLKTRACETEARDOWN it won't work because blk_tree_root is NULL. Fix the same. Tested as below root@qemu-image:/home/kvaneesh/blktrace# ./blktrace -d /dev/hdc Segmentation fault root@qemu-image:/home/kvaneesh/blktrace# ./blktrace -d /dev/hdc BLKTRACESETUP: No such file or directory Failed to start trace on /dev/hdc root@qemu-image:/home/kvaneesh/blktrace# ./blktrace -k /dev/hdc root@qemu-image:/home/kvaneesh/blktrace# ./blktrace -d /dev/hdc Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/blktrace.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index d00ac3993c18..498a0a54a6aa 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -202,6 +202,7 @@ static void blk_remove_tree(struct dentry *dir)
202static struct dentry *blk_create_tree(const char *blk_name) 202static struct dentry *blk_create_tree(const char *blk_name)
203{ 203{
204 struct dentry *dir = NULL; 204 struct dentry *dir = NULL;
205 int created = 0;
205 206
206 mutex_lock(&blk_tree_mutex); 207 mutex_lock(&blk_tree_mutex);
207 208
@@ -209,13 +210,17 @@ static struct dentry *blk_create_tree(const char *blk_name)
209 blk_tree_root = debugfs_create_dir("block", NULL); 210 blk_tree_root = debugfs_create_dir("block", NULL);
210 if (!blk_tree_root) 211 if (!blk_tree_root)
211 goto err; 212 goto err;
213 created = 1;
212 } 214 }
213 215
214 dir = debugfs_create_dir(blk_name, blk_tree_root); 216 dir = debugfs_create_dir(blk_name, blk_tree_root);
215 if (dir) 217 if (dir)
216 root_users++; 218 root_users++;
217 else 219 else {
218 blk_remove_root(); 220 /* Delete root only if we created it */
221 if (created)
222 blk_remove_root();
223 }
219 224
220err: 225err:
221 mutex_unlock(&blk_tree_mutex); 226 mutex_unlock(&blk_tree_mutex);