All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Bo <liubo2009@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 3/3] Btrfs: use helper function to simplify code
Date: Fri, 29 Jun 2012 17:59:55 +0800	[thread overview]
Message-ID: <1340963995-32549-3-git-send-email-liubo2009@cn.fujitsu.com> (raw)
In-Reply-To: <1340963995-32549-1-git-send-email-liubo2009@cn.fujitsu.com>

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 --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


      parent reply	other threads:[~2012-06-29  9:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29  9:59 [PATCH 1/3] Btrfs: add default support for subvol getflags Liu Bo
2012-06-29  9:59 ` [PATCH 2/3] Btrfs: update subvol_getflags/setflags to know new args from user Liu Bo
2012-07-03 11:27   ` Alexander Block
2012-07-03 12:04     ` Liu Bo
2012-07-03 12:09       ` Alexander Block
2012-07-03 16:08       ` Josef Bacik
2012-07-04  0:57         ` Liu Bo
2012-06-29  9:59 ` Liu Bo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340963995-32549-3-git-send-email-liubo2009@cn.fujitsu.com \
    --to=liubo2009@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.