We've made a helper function for reading root, so just apply it.

Signed-off-by: Liu Bo <liubo2...@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f9c2180..9b93fda 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2844,7 +2844,6 @@ static long btrfs_ioctl_default_subvol(struct file *file, 
void __user *argp)
        struct btrfs_dir_item *di;
        struct btrfs_trans_handle *trans;
        struct btrfs_path *path;
-       struct btrfs_key location;
        struct btrfs_disk_key disk_key;
        struct btrfs_super_block *disk_super;
        u64 features;
@@ -2857,20 +2856,10 @@ static long btrfs_ioctl_default_subvol(struct file 
*file, void __user *argp)
        if (copy_from_user(&objectid, argp, sizeof(objectid)))
                return -EFAULT;
 
-       if (!objectid)
-               objectid = root->root_key.objectid;
-
-       location.objectid = objectid;
-       location.type = BTRFS_ROOT_ITEM_KEY;
-       location.offset = (u64)-1;
-
-       new_root = btrfs_read_fs_root_no_name(root->fs_info, &location);
+       new_root = __btrfs_subvol_get_root(root, objectid);
        if (IS_ERR(new_root))
                return PTR_ERR(new_root);
 
-       if (btrfs_root_refs(&new_root->root_item) == 0)
-               return -ENOENT;
-
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;
-- 
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to