Commit db2c2ca2 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba
Browse files

btrfs: hold a ref on the root in prepare_to_merge



We look up the reloc roots corresponding root, we need to hold a ref on
that root.

Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0b530bc5
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -2521,6 +2521,7 @@ int prepare_to_merge(struct reloc_control *rc, int err)


		root = read_fs_root(fs_info, reloc_root->root_key.offset);
		root = read_fs_root(fs_info, reloc_root->root_key.offset);
		BUG_ON(IS_ERR(root));
		BUG_ON(IS_ERR(root));
		BUG_ON(!btrfs_grab_fs_root(root));
		BUG_ON(root->reloc_root != reloc_root);
		BUG_ON(root->reloc_root != reloc_root);


		/*
		/*
@@ -2532,6 +2533,7 @@ int prepare_to_merge(struct reloc_control *rc, int err)
		btrfs_update_reloc_root(trans, root);
		btrfs_update_reloc_root(trans, root);


		list_add(&reloc_root->root_list, &reloc_roots);
		list_add(&reloc_root->root_list, &reloc_roots);
		btrfs_put_fs_root(root);
	}
	}


	list_splice(&reloc_roots, &rc->reloc_roots);
	list_splice(&reloc_roots, &rc->reloc_roots);