linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH V2 5/7] Btrfs: enhance btrfs_find_device_by_user_input() to check device path
Date: Tue,  6 Oct 2015 23:19:22 +0800	[thread overview]
Message-ID: <1444144764-2384-6-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1444144764-2384-1-git-send-email-anand.jain@oracle.com>

The operation of device replace and device delete follows same steps
upto some depth with in btrfs kernel, however they don't share codes.
This enhancement will help replace and delete to share codes.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: reword subject from
    Btrfs: check device_path in btrfs_find_device_by_user_input()

 fs/btrfs/dev-replace.c | 4 ----
 fs/btrfs/volumes.c     | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index c093f49..02df419 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -320,10 +320,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
 		return -EINVAL;
 	}
 
-	if ((args->start.srcdevid == 0 && args->start.srcdev_name[0] == '\0') ||
-	    args->start.tgtdev_name[0] == '\0')
-		return -EINVAL;
-
 	/* the disk copy procedure reuses the scrub code */
 	mutex_lock(&fs_info->volume_mutex);
 	ret = btrfs_find_device_by_user_input(root, args->start.srcdevid,
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index fbbe3fe..e929211 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2039,6 +2039,9 @@ int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid,
 		if (!*device)
 			ret = -ENOENT;
 	} else {
+		if (!srcdev_name || !srcdev_name[0])
+			return -EINVAL;
+
 		ret = btrfs_find_device_missing_or_by_path(root, srcdev_name,
 							   device);
 	}
-- 
2.4.1


  parent reply	other threads:[~2015-10-06 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 15:19 [PATCH 0/7] Introduce device delete by devid Anand Jain
2015-10-06 15:19 ` [PATCH V2 1/7] Btrfs: create helper function __check_raid_min_devices() Anand Jain
2015-10-06 15:19 ` [PATCH 2/7] Btrfs: clean up and optimize __check_raid_min_device() Anand Jain
2015-10-06 15:19 ` [PATCH V2 3/7] Btrfs: create helper btrfs_find_device_by_user_input() Anand Jain
2015-10-06 15:19 ` [PATCH 4/7] Btrfs: make use of btrfs_find_device_by_user_input() Anand Jain
2015-10-06 15:19 ` Anand Jain [this message]
2015-10-06 15:19 ` [PATCH V2 6/7] Btrfs: make use of btrfs_scratch_superblocks() in btrfs_rm_device() Anand Jain
2015-10-06 15:19 ` [PATCH V4 7/7] Btrfs: Introduce device delete by devid Anand Jain
2016-02-12 18:22 ` [PATCH 0/7] " David Sterba
2016-02-13  2:09   ` Anand Jain

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=1444144764-2384-6-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).