diff mbox

[3/3] Btrfs: use helper function to simplify code

Message ID 1340963995-32549-3-git-send-email-liubo2009@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

liubo June 29, 2012, 9:59 a.m. UTC
We've made a helper function for reading root, so just apply it.

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

Patch

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;