aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorliubo <liubo2009@cn.fujitsu.com>2011-06-01 05:42:49 -0400
committerChris Mason <chris.mason@oracle.com>2011-06-04 08:03:44 -0400
commitca456ae280c0646e1e571c3b9a3834c55e90adfe (patch)
tree945f70453e07c59739c02808f69598f637d35dfa /fs
parent211f96c24f117fcc6e9e2431e40d92f4de22625e (diff)
Btrfs: don't save the inode cache in non-FS roots
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/inode-map.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index 3262cd17a12..04f7199facb 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -388,6 +388,12 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
388 int prealloc; 388 int prealloc;
389 bool retry = false; 389 bool retry = false;
390 390
391 /* only fs tree and subvol/snap needs ino cache */
392 if (root->root_key.objectid != BTRFS_FS_TREE_OBJECTID &&
393 (root->root_key.objectid < BTRFS_FIRST_FREE_OBJECTID ||
394 root->root_key.objectid > BTRFS_LAST_FREE_OBJECTID))
395 return 0;
396
391 path = btrfs_alloc_path(); 397 path = btrfs_alloc_path();
392 if (!path) 398 if (!path)
393 return -ENOMEM; 399 return -ENOMEM;