From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2] btrfs-progs: scan /dev/mapper in filesystem show and device scan
Date: Thu, 8 Aug 2013 16:09:28 +0800 [thread overview]
Message-ID: <1375949368-23798-3-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1375949368-23798-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 (where 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 btrfs device scan and
btrfs filesystem show cli, when used will look for btrfs
devs under /dev/mapper and will use the links provided
under the /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 mapper path when present (along with /proc/partitions)
can be the default option to scan for the btrfs devs.
(/proc/partitions must be scanned as well because to
include the mapper blacklisted (from mapper) devs.)
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
cmds-device.c | 8 +++++++-
cmds-filesystem.c | 7 +++++--
man/btrfs.8.in | 22 ++++++++++++----------
utils.c | 3 +++
utils.h | 1 +
5 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/cmds-device.c b/cmds-device.c
index be2aaff..6d1b378 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -186,7 +186,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
};
@@ -203,6 +203,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 74ad30b..88cace3 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -371,7 +371,7 @@ static int btrfs_scan_kernel(void *input, int type)
}
static const char * const cmd_show_usage[] = {
- "btrfs filesystem show [--all-devices|--mapper|--kernel|<uuid>]",
+ "btrfs filesystem show [--all-devices|--mapper|--kernel] [<uuid>|<path>]",
"Show the structure of a filesystem",
"If no argument is given, structure of all present filesystems is shown.",
NULL
@@ -388,9 +388,12 @@ static int cmd_show(int argc, char **argv)
int searchstart = 1;
u8 processed[PATH_MAX];
- 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;
} else if (argc > 1 && !strcmp(argv[1], "--kernel")) {
where = 0;
searchstart += 1;
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index 6383469..821f138 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -25,7 +25,7 @@ btrfs \- control a btrfs filesystem
.PP
\fBbtrfs\fP \fBfilesystem df\fP\fI <path>\fP
.PP
-\fBbtrfs\fP \fBfilesystem show\fP\fI [--all-devices|--kernel] [\fI<uuid>|<path>]\fP\fP
+\fBbtrfs\fP \fBfilesystem show [\fP\fI--all-devices\fP|\fI--mapper\fP|\fI--kernel\fP] [\fI<uuid>\fP|\fI<path>\fP]
.PP
\fBbtrfs\fP \fBfilesystem sync\fP\fI <path> \fP
.PP
@@ -51,7 +51,7 @@ btrfs \- control a btrfs filesystem
.PP
\fBbtrfs\fP \fBdevice delete\fP \fI<device>\fP [\fI<device>...\fP] \fI<path>\fP
.PP
-\fBbtrfs\fP \fBdevice scan\fP [--all-devices|\fI<device> \fP[\fI<device>...\fP]
+\fBbtrfs\fP \fBdevice scan\fP [\fI--all-devices\fP|\fI--mapper\fP|\fI<device>\fP [\fI<device>...\fP]
.PP
\fBbtrfs\fP \fBdevice ready\fP\fI <device>\fP
.PP
@@ -254,12 +254,13 @@ Show information of a given subvolume in the \fI<path>\fR.
Show space usage information for a mount point.
.TP
-\fBfilesystem show\fR [--all-devices|--kernel] [\fI<uuid>|<path>]\fP\fP
-Show the btrfs filesystem with some additional info. If no \fIUUID\fP or
-\fIlabel\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;
+\fBfilesystem show\fR [\fI--all-devices\fP|\fI--mapper\fP|\fI--kernel\fP] [\fI<uuid>\fP|\fI<path>\fP]\fP
+Show the btrfs filesystem with some additional info. If no \fIuuid\fP
+is passed, it will show info of all the btrfs filesystem.
+If \fI--all-devices\fP is passed, all the devices under /dev are scanned;
+If \fI--mapper\fP is passed, the devices under /dev/mapper are scanned;
otherwise the devices list is extracted from the /proc/partitions file.
-The --kernel will scan the btrfs kernel for the mounted btrfs.
+The \fI--kernel\fP will scan the btrfs kernel for the mounted btrfs.
.TP
\fBfilesystem sync\fR\fI <path> \fR
@@ -390,11 +391,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 [--all-devices|\fI<device> \fP[\fI<device>...\fP]\fR
+\fBdevice scan\fR [\fI--all-devices\fP|\fI--mapper\fP|\fI<device>\fP...]\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
+If no devices are passed, then it will 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 \fI--mapper\fP is passed, all the devices under /dev/mapper are scanned
+Finally, if \fI--all-devices\fP is passed, all the devices under /dev are
scanned.
.TP
diff --git a/utils.c b/utils.c
index 038e599..382d102 100644
--- a/utils.c
+++ b/utils.c
@@ -1923,6 +1923,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 6419c3e..13e2fd5 100644
--- a/utils.h
+++ b/utils.h
@@ -27,6 +27,7 @@
#define BTRFS_SCAN_PROC 1
#define BTRFS_SCAN_DEV 2
+#define BTRFS_SCAN_MAPPER 3
#define BTRFS_ERR_STR_LEN 100
--
1.8.1.191.g414c78c
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo
next prev parent reply other threads:[~2013-08-08 8:03 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-10 14:56 [PATCH 0/9] btrfs-progs: coalesce of patches Anand Jain
2013-06-10 14:56 ` [PATCH 1/9] btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments Anand Jain
2013-06-10 20:00 ` Eric Sandeen
2013-06-11 13:15 ` anand jain
2013-06-10 14:56 ` [PATCH 2/9 v2] btrfs-progs: label option in btrfs filesystem show is not coded Anand Jain
2013-06-10 14:56 ` [PATCH 3/9 v2] btrfs-progs: update device scan usage Anand Jain
2013-06-10 14:56 ` [PATCH 4/9 v3] btrfs-progs: congregate dev scan Anand Jain
2013-06-10 14:56 ` [PATCH 5/9 v2] btrfs-progs: btrfs_scan_one_dir not to skip links when /dev/mapper is provided Anand Jain
2013-06-10 14:56 ` [PATCH 6/9 v2] btrfs-progs: scan /dev/mapper in filesystem show and device scan Anand Jain
2013-06-10 14:56 ` [PATCH 7/9 v3] btrfs-progs: device delete to get errors from the kernel Anand Jain
2013-06-10 14:56 ` [PATCH 8/9] btrfs-progs: get_label_mounted to return label instead of print Anand Jain
2013-06-21 7:41 ` [PATCH 08/13 v2] " Anand Jain
2013-06-10 14:56 ` [PATCH 9/9 v2] btrfs-progs: introduce btrfs filesystem show --kernel Anand Jain
2013-06-10 14:59 ` [PATCH 0/2] btrfs: coalesce of patches Anand Jain
2013-06-10 14:59 ` [PATCH 1/2] btrfs: device delete to get errors from the kernel Anand Jain
2013-06-10 14:59 ` [PATCH 2/2 v2] btrfs: add framework to read fs info and dev info " Anand Jain
2013-06-10 19:40 ` Josef Bacik
2013-06-11 13:10 ` anand jain
2013-06-11 13:15 ` Josef Bacik
2013-06-10 20:30 ` Zach Brown
2013-06-11 14:05 ` anand jain
2013-06-11 17:50 ` Zach Brown
2013-06-11 14:24 ` Josef Bacik
2013-06-21 7:02 ` Anand Jain
2013-06-21 7:32 ` [PATCH 2/2 v3] btrfs: obtain used_bytes in BTRFS_IOC_FS_INFO ioctl Anand Jain
2013-06-24 17:03 ` Josef Bacik
2013-06-25 3:00 ` Anand Jain
2013-07-08 7:39 ` [PATCH 13/13] btrfs-progs: fix memory leaks of device_list_add() Anand Jain
2013-07-15 4:58 ` Anand Jain
2013-07-15 5:30 ` [PATCH 00/11 v2 (resend)] btrfs-progs: coalesce of patches Anand Jain
2013-07-15 5:30 ` [PATCH 01/11] btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments Anand Jain
2013-07-15 5:30 ` [PATCH 02/11] btrfs-progs: label option in btrfs filesystem show is not coded Anand Jain
2013-07-15 5:30 ` [PATCH 03/11] btrfs-progs: update device scan usage Anand Jain
2013-07-15 5:30 ` [PATCH 04/11] btrfs-progs: congregate dev scan Anand Jain
2013-07-15 5:30 ` [PATCH 05/11] btrfs-progs: btrfs_scan_one_dir not to skip links when /dev/mapper is provided Anand Jain
2013-08-05 16:53 ` David Sterba
2013-07-15 5:30 ` [PATCH 06/11] btrfs-progs: scan /dev/mapper in filesystem show and device scan Anand Jain
2013-08-05 17:04 ` David Sterba
2013-08-13 4:07 ` anand jain
2013-07-15 5:30 ` [PATCH 07/11] btrfs-progs: device delete to get errors from the kernel Anand Jain
2013-07-15 5:30 ` [PATCH 08/11] btrfs-progs: get_label_mounted to return label instead of print Anand Jain
2013-07-15 5:30 ` [PATCH 09/11] btrfs-progs: move out print in cmd_df to another function Anand Jain
2013-07-15 5:30 ` [PATCH 10/11] btrfs-progs: get string for the group profile and type Anand Jain
2013-07-15 5:30 ` [PATCH 11/11] btrfs-progs: introduce btrfs filesystem show --kernel Anand Jain
2013-08-05 17:36 ` [PATCH 00/11 v2 (resend)] btrfs-progs: coalesce of patches David Sterba
2013-08-06 15:08 ` anand jain
2013-08-08 8:07 ` [PATCH 0/2 v2] introduce btrfs filesystem show --kernel Anand Jain
2013-08-08 8:07 ` [PATCH 1/2] btrfs-progs: move out print in cmd_df to another function Anand Jain
2013-08-08 8:07 ` [PATCH 2/2] btrfs-progs: introduce btrfs filesystem show --kernel Anand Jain
2013-08-08 18:08 ` Zach Brown
2013-08-09 10:57 ` anand jain
2013-08-09 18:03 ` Zach Brown
2013-08-08 8:09 ` [PATCH 0/2] scan /dev/mapper in filesystem show and device scan Anand Jain
2013-08-08 8:09 ` [PATCH 1/2] btrfs-progs: btrfs_scan_one_dir not to skip links when /dev/mapper is provided Anand Jain
2013-08-08 8:09 ` Anand Jain [this message]
2013-08-08 8:10 ` [PATCH 0/2] scan /dev/mapper in filesystem show and device scan 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=1375949368-23798-3-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).