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
Subject: [PATCH 6/6 v2] btrfs-progs: scan /dev/mapper in filesystem show and device scan
Date: Thu, 30 May 2013 11:40:26 +0800	[thread overview]
Message-ID: <1369885226-3640-7-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1369885226-3640-1-git-send-email-anand.jain@oracle.com>

Currently, btrsf fi show and btrfs dev scan uses
/proc/partitions (by default) (which gives priority
to dm-<x> over sd<y> paths) and with --all-devices it
will scan /dev only (when it skips links under /dev/mapper).

However using /dev/mapper paths are in common practice
with mount, fstab, and lvm, so its better to be consistent
with them.

This patch adds --mapper option to device scan and
filesystem show cli, when used will look for btrfs
dev under /dev/mapper and will use the links provided
under /dev/mapper.

eg:
btrfs fi show --mapper
Label: none  uuid: 0a621111-ad84-4d80-842a-dd9c1c60bf51
        Total devices 2 FS bytes used 1.17MB
        devid    1 size 44.99GB used 2.04GB path /dev/mapper/mpathe
        devid    2 size 48.23GB used 2.03GB path /dev/mapper/mpathd

Label: none  uuid: bad9105f-bdc6-4626-9ba7-80bd97aebe19
        Total devices 1 FS bytes used 28.00KB
        devid    1 size 15.00GB used 2.04GB path /dev/mapper/mpathbp1

In the long run I want the usage of /dev/mapper path
along with /proc/partitions be the default option to
scan for the btrfs devs. /proc/partitions must be scanned
as well because to include the mapper blacklisted devs.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 cmds-device.c     |  8 +++++++-
 cmds-filesystem.c |  7 +++++--
 man/btrfs.8.in    | 12 +++++++-----
 utils.c           |  3 +++
 utils.h           |  5 +++--
 5 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index b6ecb3b..ef6bc60 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -178,7 +178,7 @@ static int cmd_rm_dev(int argc, char **argv)
 }
 
 static const char * const cmd_scan_dev_usage[] = {
-	"btrfs device scan [<--all-devices>|<device> [<device>...]]",
+	"btrfs device scan [<--all-devices>|<--mapper>|<device> [<device>...]]",
 	"Scan devices for a btrfs filesystem",
 	NULL
 };
@@ -195,6 +195,12 @@ static int cmd_scan_dev(int argc, char **argv)
 
 		where = BTRFS_SCAN_DEV;
 		devstart += 1;
+	} else if( argc > 1 && !strcmp(argv[1],"--mapper")){
+		if (check_argc_max(argc, 2))
+			usage(cmd_scan_dev_usage);
+
+		where = BTRFS_SCAN_MAPPER;
+		devstart += 1;
 	}
 
 	if(argc<=devstart){
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 0d76d58..9b7bcf1 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -232,7 +232,7 @@ static void print_one_uuid(struct btrfs_fs_devices *fs_devices)
 }
 
 static const char * const cmd_show_usage[] = {
-	"btrfs filesystem show [--all-devices|<uuid>]",
+	"btrfs filesystem show [--all-devices|--mapper|<uuid>]",
 	"Show the structure of a filesystem",
 	"If no argument is given, structure of all present filesystems is shown.",
 	NULL
@@ -248,9 +248,12 @@ static int cmd_show(int argc, char **argv)
 	int where = BTRFS_SCAN_PROC;
 	int searchstart = 1;
 
-	if( argc > 1 && !strcmp(argv[1],"--all-devices")){
+	if (argc > 1 && !strcmp(argv[1],"--all-devices")) {
 		where = BTRFS_SCAN_DEV;
 		searchstart += 1;
+	} else if (argc > 1 && !strcmp(argv[1],"--mapper")) {
+		where = BTRFS_SCAN_MAPPER;
+		searchstart += 1;
 	}
 
 	if (check_argc_max(argc, searchstart + 1))
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index ae984f8..8988b16 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -31,11 +31,11 @@ btrfs \- control a btrfs filesystem
 .PP
 \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP
 .PP
-\fBbtrfs\fP \fBfilesystem show\fP\fI [--all-devices|<uuid>]\fP
+\fBbtrfs\fP \fBfilesystem show\fP\fI [--all-devices|--mapper|<uuid>]\fP
 .PP
 \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP
 .PP
-\fBbtrfs\fP \fBdevice scan\fP\fI [--all-devices|<device> [<device>...]]\fP
+\fBbtrfs\fP \fBdevice scan\fP\fI [--all-devices|--mapper|<device> [<device>...]]\fP
 .PP
 \fBbtrfs\fP \fBdevice stats\fP [-z] {\fI<path>\fP|\fI<device>\fP}
 .PP
@@ -282,10 +282,11 @@ NOTE: Currently there are the following limitations:
 - the filesystem should not have more than one device.
 .TP
 
-\fBfilesystem show\fR [--all-devices|<uuid>]\fR
+\fBfilesystem show\fR [--all-devices|--mapper|<uuid>]\fR
 Show the btrfs filesystem with some additional info. If no \fIUUID\fP
 is passed, \fBbtrfs\fR show info of all the btrfs filesystem.
 If \fB--all-devices\fP is passed, all the devices under /dev are scanned;
+If \fB--mapper\fP is passed, all the devices under /dev/mapper are scanned;
 otherwise the devices list is extracted from the /proc/partitions file.
 .TP
 
@@ -314,11 +315,12 @@ Add device(s) to the filesystem identified by \fI<path>\fR.
 Remove device(s) from a filesystem identified by \fI<path>\fR.
 .TP
 
-\fBdevice scan\fR \fI[--all-devices|<device> [<device>...]\fR
+\fBdevice scan\fR \fI[--all-devices|--mapper|<device> [<device>...]\fR
 If one or more devices are passed, these are scanned for a btrfs filesystem. 
 If no devices are passed, \fBbtrfs\fR scans all the block devices listed
 in the /proc/partitions file.
-Finally, if \fB--all-devices\fP is passed, all the devices under /dev are 
+If \fB--all-devices\fP is passed, all the devices under /dev are 
+Finally, if \fB--mapper\fP is passed, all the devices under /dev/mapper are 
 scanned.
 .TP
 
diff --git a/utils.c b/utils.c
index 6ac7c73..afec980 100644
--- a/utils.c
+++ b/utils.c
@@ -1825,6 +1825,9 @@ int scan_for_btrfs(int where, int update_kernel)
 	case BTRFS_SCAN_DEV:
 		ret = btrfs_scan_one_dir("/dev", update_kernel);
 		break;
+	case BTRFS_SCAN_MAPPER:
+		ret = btrfs_scan_one_dir("/dev/mapper", update_kernel);
+		break;
 	}
 	return ret;
 }
diff --git a/utils.h b/utils.h
index 78f3a65..733d13b 100644
--- a/utils.h
+++ b/utils.h
@@ -24,8 +24,9 @@
 
 #define BTRFS_MKFS_SYSTEM_GROUP_SIZE (4 * 1024 * 1024)
 
-#define BTRFS_SCAN_PROC	1
-#define BTRFS_SCAN_DEV	2
+#define BTRFS_SCAN_PROC      1
+#define BTRFS_SCAN_DEV       2
+#define BTRFS_SCAN_MAPPER    3
 
 int make_btrfs(int fd, const char *device, const char *label,
 	       u64 blocks[6], u64 num_bytes, u32 nodesize,
-- 
1.8.1.227.g44fe835


      parent reply	other threads:[~2013-05-30  3:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17 10:54 [PATCH 0/4] a structure for the disks scan for btrfs Anand Jain
2013-05-17 10:54 ` [PATCH 1/4] btrfs-progs: replace filesystem show --all-devices with -d option Anand Jain
2013-05-17 10:54 ` [PATCH 2/4] btrfs-progs: label option in btrfs filesystem show is not coded Anand Jain
2013-05-17 10:54 ` [PATCH 3/4] btrfs-progs: use /dev/mapper to find the btrfs disks Anand Jain
2013-05-17 10:54 ` [PATCH 4/4] btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments Anand Jain
2013-05-17 11:21 ` [PATCH 0/4] a structure for the disks scan for btrfs Gabriel de Perthuis
2013-05-17 11:25   ` Gabriel de Perthuis
2013-05-18  4:35   ` anand jain
2013-05-30  3:40 ` [PATCH 0/6 v2] btrfs-progs: " Anand Jain
2013-05-30  3:40   ` [PATCH 1/6 v2] btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments Anand Jain
2013-05-30  3:40   ` [PATCH 2/6 v2] btrfs-progs: label option in btrfs filesystem show is not coded Anand Jain
2013-05-30  3:40   ` [PATCH 3/6 v2] btrfs-progs: update device scan usage Anand Jain
2013-05-30  3:40   ` [PATCH 4/6 v2] btrfs-progs: congregate dev scan Anand Jain
2013-05-31  8:17     ` [PATCH 4/6 v3] " Anand Jain
2013-05-30  3:40   ` [PATCH 5/6 v2] btrfs-progs: btrfs_scan_one_dir not to skip links when /dev/mapper is provided Anand Jain
2013-05-30  3:40   ` Anand Jain [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=1369885226-3640-7-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.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 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).