Commit fd79d43b authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: hold a ref on the root in scrub_print_warning_inode

We look up the root for the bytenr that is failing, so we need to hold a
ref on the root for that operation.
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 0b2dee5c
...@@ -658,6 +658,10 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root, ...@@ -658,6 +658,10 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
ret = PTR_ERR(local_root); ret = PTR_ERR(local_root);
goto err; goto err;
} }
if (!btrfs_grab_fs_root(local_root)) {
ret = -ENOENT;
goto err;
}
/* /*
* this makes the path point to (inum INODE_ITEM ioff) * this makes the path point to (inum INODE_ITEM ioff)
...@@ -668,6 +672,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root, ...@@ -668,6 +672,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0); ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0);
if (ret) { if (ret) {
btrfs_put_fs_root(local_root);
btrfs_release_path(swarn->path); btrfs_release_path(swarn->path);
goto err; goto err;
} }
...@@ -688,6 +693,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root, ...@@ -688,6 +693,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
ipath = init_ipath(4096, local_root, swarn->path); ipath = init_ipath(4096, local_root, swarn->path);
memalloc_nofs_restore(nofs_flag); memalloc_nofs_restore(nofs_flag);
if (IS_ERR(ipath)) { if (IS_ERR(ipath)) {
btrfs_put_fs_root(local_root);
ret = PTR_ERR(ipath); ret = PTR_ERR(ipath);
ipath = NULL; ipath = NULL;
goto err; goto err;
...@@ -711,6 +717,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root, ...@@ -711,6 +717,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
min(isize - offset, (u64)PAGE_SIZE), nlink, min(isize - offset, (u64)PAGE_SIZE), nlink,
(char *)(unsigned long)ipath->fspath->val[i]); (char *)(unsigned long)ipath->fspath->val[i]);
btrfs_put_fs_root(local_root);
free_ipath(ipath); free_ipath(ipath);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment