Btrfs: don't save the inode cache in non-FS roots
authorliubo <liubo2009@cn.fujitsu.com>
Wed, 1 Jun 2011 09:42:49 +0000 (09:42 +0000)
committerChris Mason <chris.mason@oracle.com>
Sat, 4 Jun 2011 12:03:44 +0000 (08:03 -0400)
This adds extra checks to make sure the inode map we are caching really
belongs to a FS root instead of a special relocation tree.  It
prevents crashes during balancing operations.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/inode-map.c

index 3262cd17a12f89192ce0c3e5394d5936ce003049..04f7199facb4ec38800af7f4fb23dc319a8952ba 100644 (file)
@@ -388,6 +388,12 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
        int prealloc;
        bool retry = false;
 
+       /* only fs tree and subvol/snap needs ino cache */
+       if (root->root_key.objectid != BTRFS_FS_TREE_OBJECTID &&
+           (root->root_key.objectid < BTRFS_FIRST_FREE_OBJECTID ||
+            root->root_key.objectid > BTRFS_LAST_FREE_OBJECTID))
+               return 0;
+
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;