Commit fc8b235f authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: simplify error handling in btrfs_lookup_dentry

In btrfs_lookup_dentry releasing the reference of the sub_root and the
running orphan cleanup should only happen if the dentry found actually
represents a subvolume. This can only be true in the 'else' branch as
otherwise either fixup_tree_root_location returned an ENOENT error, in
which case sub_root wouldn't have been changed or if we got a different
errno this means btrfs_get_fs_root couldn't have executed successfully
again meaning sub_root will equal to root. So simplify all the branches
by moving the code into the 'else'.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0d8869fb
...@@ -5866,14 +5866,14 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) ...@@ -5866,14 +5866,14 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
if (ret != -ENOENT) if (ret != -ENOENT)
inode = ERR_PTR(ret); inode = ERR_PTR(ret);
else else
inode = new_simple_dir(dir->i_sb, &location, sub_root); inode = new_simple_dir(dir->i_sb, &location, root);
} else { } else {
inode = btrfs_iget(dir->i_sb, location.objectid, sub_root); inode = btrfs_iget(dir->i_sb, location.objectid, sub_root);
}
if (root != sub_root)
btrfs_put_root(sub_root); btrfs_put_root(sub_root);
if (!IS_ERR(inode) && root != sub_root) { if (IS_ERR(inode))
return inode;
down_read(&fs_info->cleanup_work_sem); down_read(&fs_info->cleanup_work_sem);
if (!sb_rdonly(inode->i_sb)) if (!sb_rdonly(inode->i_sb))
ret = btrfs_orphan_cleanup(sub_root); ret = btrfs_orphan_cleanup(sub_root);
......
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