From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Cc: Anand Jain <anand.jain@oracle.com>
Subject: [PATCH 1/2] btrfs-progs: Add missing devices check for mounted btrfs.
Date: Fri, 7 Feb 2014 14:45:59 +0800 [thread overview]
Message-ID: <1391755560-4721-1-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In btrfs/003 of xfstest, it will check whether btrfs fi show can find
missing devices.
But before the patch, btrfs-progs will not check whether device missing
if given a mounted btrfs mountpoint/block device.
This patch fixes the bug and will pass btrfs/003.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: Anand Jain <anand.jain@oracle.com>
---
cmds-filesystem.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 384d1b9..4c9933d 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -363,6 +363,8 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
char *label, char *path)
{
int i;
+ int fd;
+ int missing;
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
struct btrfs_ioctl_dev_info_args *tmp_dev_info;
int ret;
@@ -385,6 +387,14 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
for (i = 0; i < fs_info->num_devices; i++) {
tmp_dev_info = (struct btrfs_ioctl_dev_info_args *)&dev_info[i];
+
+ /* Add check for missing devices even mounted */
+ fd = open((char *)tmp_dev_info->path, O_RDONLY);
+ if (fd < 0) {
+ missing = 1;
+ continue;
+ }
+ close(fd);
printf("\tdevid %4llu size %s used %s path %s\n",
tmp_dev_info->devid,
pretty_size(tmp_dev_info->total_bytes),
@@ -392,6 +402,8 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
tmp_dev_info->path);
}
+ if (missing)
+ printf("\t*** Some devices missing\n");
printf("\n");
return 0;
}
--
1.8.5.4
next reply other threads:[~2014-02-07 7:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 6:45 Qu Wenruo [this message]
2014-02-07 6:46 ` [PATCH 2/2] btrfs-progs: Add -p/--print-missing options for btrfs fi show Qu Wenruo
2014-02-07 9:26 ` Anand Jain
2014-02-10 0:39 ` Qu Wenruo
2014-02-07 9:34 ` [PATCH 1/2] btrfs-progs: Add missing devices check for mounted btrfs Anand Jain
2014-02-10 0:36 ` Qu Wenruo
2014-04-09 3:04 ` Anand Jain
2014-04-09 3:26 ` Qu Wenruo
2014-04-09 4:33 ` Anand Jain
2014-04-09 6:55 ` Qu Wenruo
2014-04-09 9:12 ` 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=1391755560-4721-1-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=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).