summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-01-24 15:32:41 +0100
committerDavid Sterba <dsterba@suse.com>2020-03-23 17:01:29 +0100
commit442b1ac5244ea2dc09d8aa688b41e0a0c4634b0a (patch)
tree2feea2107322b439498bcc7a757a197c906f75f9 /fs/btrfs/relocation.c
parentbtrfs: hold a ref on the root in merge_reloc_roots (diff)
downloadlinux-442b1ac5244ea2dc09d8aa688b41e0a0c4634b0a.tar.xz
linux-442b1ac5244ea2dc09d8aa688b41e0a0c4634b0a.zip
btrfs: hold a ref on the root in record_reloc_root_in_trans
We are recording this root in the transaction, so we need to hold a ref on it until we do that. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 679dd3958ff2..0336a48d7d96 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2648,15 +2648,19 @@ static int record_reloc_root_in_trans(struct btrfs_trans_handle *trans,
{
struct btrfs_fs_info *fs_info = reloc_root->fs_info;
struct btrfs_root *root;
+ int ret;
if (reloc_root->last_trans == trans->transid)
return 0;
root = read_fs_root(fs_info, reloc_root->root_key.offset);
BUG_ON(IS_ERR(root));
+ BUG_ON(!btrfs_grab_fs_root(root));
BUG_ON(root->reloc_root != reloc_root);
+ ret = btrfs_record_root_in_trans(trans, root);
+ btrfs_put_fs_root(root);
- return btrfs_record_root_in_trans(trans, root);
+ return ret;
}
static noinline_for_stack