* [PATCH v2 1/2] btrfs-progs: Add missing devices check for mounted btrfs.
@ 2014-02-07 7:07 Qu Wenruo
0 siblings, 0 replies; only message in thread
From: Qu Wenruo @ 2014-02-07 7:07 UTC (permalink / raw)
To: linux-btrfs; +Cc: Anand Jain
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>
---
changelog:
v1->v2: fix a uninitialized variant int print_one_fs.
---
cmds-filesystem.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 384d1b9..c1bdab4 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 = 0;
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-07 7:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-07 7:07 [PATCH v2 1/2] btrfs-progs: Add missing devices check for mounted btrfs Qu Wenruo
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).