Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca456ae2 authored by liubo's avatar liubo Committed by Chris Mason
Browse files

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: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 211f96c2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;