Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=35fc51e7a5056889421270c1fb63d8ec45fbccf4
Commit:     35fc51e7a5056889421270c1fb63d8ec45fbccf4
Parent:     8c27eba54970c6ebbb408186e5baa2274435e869
Author:     Aneesh Kumar K.V <[EMAIL PROTECTED]>
AuthorDate: Wed Nov 21 12:25:41 2007 +0100
Committer:  Jens Axboe <[EMAIL PROTECTED]>
CommitDate: Tue Nov 27 09:19:39 2007 +0100

    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
    
    [EMAIL PROTECTED]:/home/kvaneesh/blktrace# ./blktrace  -d /dev/hdc
    Segmentation fault
    [EMAIL PROTECTED]:/home/kvaneesh/blktrace# ./blktrace  -d /dev/hdc
    BLKTRACESETUP: No such file or directory
    Failed to start trace on /dev/hdc
    [EMAIL PROTECTED]:/home/kvaneesh/blktrace# ./blktrace  -k /dev/hdc
    [EMAIL PROTECTED]:/home/kvaneesh/blktrace# ./blktrace  -d /dev/hdc
    
    Signed-off-by: Aneesh Kumar K.V <[EMAIL PROTECTED]>
    Signed-off-by: Jens Axboe <[EMAIL PROTECTED]>
---
 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);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to