linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blktrace: Make sure BLKTRACETEARDOWN does the full cleanup.
@ 2007-10-28 11:49 Aneesh Kumar K.V
  2007-10-29 19:48 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Aneesh Kumar K.V @ 2007-10-28 11:49 UTC (permalink / raw)
  To: linux-btrace

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>
---
 block/blktrace.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/block/blktrace.c b/block/blktrace.c
index d00ac39..498a0a5 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -202,6 +202,7 @@ static void blk_remove_tree(struct dentry *dir)
 static struct dentry *blk_create_tree(const char *blk_name)
 {
 	struct dentry *dir = NULL;
+	int created = 0;
 
 	mutex_lock(&blk_tree_mutex);
 
@@ -209,13 +210,17 @@ static struct dentry *blk_create_tree(const char *blk_name)
 		blk_tree_root = debugfs_create_dir("block", NULL);
 		if (!blk_tree_root)
 			goto err;
+		created = 1;
 	}
 
 	dir = debugfs_create_dir(blk_name, blk_tree_root);
 	if (dir)
 		root_users++;
-	else
-		blk_remove_root();
+	else {
+		/* Delete root only if we created it */
+		if (created)
+			blk_remove_root();
+	}
 
 err:
 	mutex_unlock(&blk_tree_mutex);
-- 
1.5.3.4.383.gd90a7-dirty


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] blktrace: Make sure BLKTRACETEARDOWN does the full cleanup.
  2007-10-28 11:49 [PATCH] blktrace: Make sure BLKTRACETEARDOWN does the full cleanup Aneesh Kumar K.V
@ 2007-10-29 19:48 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2007-10-29 19:48 UTC (permalink / raw)
  To: linux-btrace

On Sun, Oct 28 2007, Aneesh Kumar K.V wrote:
> 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

Looks good, will apply tomorrow after some brief testing.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-29 19:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-28 11:49 [PATCH] blktrace: Make sure BLKTRACETEARDOWN does the full cleanup Aneesh Kumar K.V
2007-10-29 19:48 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).