]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: don't save the inode cache if we are deleting this root
authorJosef Bacik <josef@redhat.com>
Tue, 31 May 2011 19:33:33 +0000 (19:33 +0000)
committerChris Mason <chris.mason@oracle.com>
Sat, 4 Jun 2011 12:03:45 +0000 (08:03 -0400)
With xfstest 254 I can panic the box every time with the inode number caching
stuff on.  This is because we clean the inodes out when we delete the subvolume,
but then we write out the inode cache which adds an inode to the subvolume inode
tree, and then when it gets evicted again the root gets added back on the dead
roots list and is deleted again, so we have a double free.  To stop this from
happening just return 0 if refs is 0 (and we're not the tree root since tree
root always has refs of 0).  With this fix 254 no longer panics.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Tested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/inode-map.c

index 04f7199facb4ec38800af7f4fb23dc319a8952ba..2d0d50067a7b47449837783607d634eb15d8fb55 100644 (file)
@@ -394,6 +394,11 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
             root->root_key.objectid > BTRFS_LAST_FREE_OBJECTID))
                return 0;
 
+       /* Don't save inode cache if we are deleting this root */
+       if (btrfs_root_refs(&root->root_item) == 0 &&
+           root != root->fs_info->tree_root)
+               return 0;
+
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;