All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: fi show: Print missing device for a mounted file system
@ 2021-09-02 10:06 Nikolay Borisov
  2021-09-02 10:06 ` [PATCH 2/2] btrfs-progs: tests: Add test for fi show Nikolay Borisov
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Nikolay Borisov @ 2021-09-02 10:06 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Currently when a device is missing for a mounted filesystem the output
that is produced is unhelpful:

Label: none  uuid: 139ef309-021f-4b98-a3a8-ce230a83b1e2
	Total devices 2 FS bytes used 128.00KiB
	devid    1 size 5.00GiB used 1.26GiB path /dev/loop0
	*** Some devices missing

While the context which prints this is perfectly capable of showing
which device exactly is missing, like so:

Label: none  uuid: 4a85a40b-9b79-4bde-8e52-c65a550a176b
	Total devices 2 FS bytes used 128.00KiB
	devid    1 size 5.00GiB used 1.26GiB path /dev/loop0
	devid    2 size 0 used 0 path /dev/loop1 ***MISSING***

This is a lot more usable output as it presents the user with the id
of the missing device and its path.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 cmds/filesystem.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/cmds/filesystem.c b/cmds/filesystem.c
index db8433ba3542..ff13de6ac990 100644
--- a/cmds/filesystem.c
+++ b/cmds/filesystem.c
@@ -295,7 +295,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 {
 	int i;
 	int fd;
-	int missing = 0;
 	char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
 	struct btrfs_ioctl_dev_info_args *tmp_dev_info;
 	int ret;
@@ -325,8 +324,10 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 		/* Add check for missing devices even mounted */
 		fd = open((char *)tmp_dev_info->path, O_RDONLY);
 		if (fd < 0) {
-			missing = 1;
+			printf("\tdevid %4llu size 0 used 0 path %s ***MISSING***\n",
+					tmp_dev_info->devid,tmp_dev_info->path);
 			continue;
+
 		}
 		close(fd);
 		canonical_path = path_canonicalize((char *)tmp_dev_info->path);
@@ -339,8 +340,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 		free(canonical_path);
 	}
 
-	if (missing)
-		printf("\t*** Some devices missing\n");
 	printf("\n");
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread
* [PATCH 1/2] btrfs-progs: fi show: Print missing device for a mounted file system
@ 2022-03-29  8:30 Nikolay Borisov
  2022-06-07  8:35 ` Nikolay Borisov
  0 siblings, 1 reply; 23+ messages in thread
From: Nikolay Borisov @ 2022-03-29  8:30 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Currently when a device is missing for a mounted filesystem the output
that is produced is unhelpful:

Label: none  uuid: 139ef309-021f-4b98-a3a8-ce230a83b1e2
	Total devices 2 FS bytes used 128.00KiB
	devid    1 size 5.00GiB used 1.26GiB path /dev/loop0
	*** Some devices missing

While the context which prints this is perfectly capable of showing
which device exactly is missing, like so:

Label: none  uuid: 4a85a40b-9b79-4bde-8e52-c65a550a176b
	Total devices 2 FS bytes used 128.00KiB
	devid    1 size 5.00GiB used 1.26GiB path /dev/loop0
	devid    2 size 0 used 0 path /dev/loop1 ***MISSING***

This is a lot more usable output as it presents the user with the id
of the missing device and its path.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

Resending this series as it seems to have fallen through the cracks.


 cmds/filesystem.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/cmds/filesystem.c b/cmds/filesystem.c
index 7cd08fcd5f62..fe32838a25bf 100644
--- a/cmds/filesystem.c
+++ b/cmds/filesystem.c
@@ -296,7 +296,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 {
 	int i;
 	int fd;
-	int missing = 0;
 	char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
 	struct btrfs_ioctl_dev_info_args *tmp_dev_info;
 	int ret;
@@ -326,8 +325,10 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 		/* Add check for missing devices even mounted */
 		fd = open((char *)tmp_dev_info->path, O_RDONLY);
 		if (fd < 0) {
-			missing = 1;
+			printf("\tdevid %4llu size 0 used 0 path %s MISSING\n",
+					tmp_dev_info->devid, tmp_dev_info->path);
 			continue;
+
 		}
 		close(fd);
 		canonical_path = path_canonicalize((char *)tmp_dev_info->path);
@@ -340,8 +341,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 		free(canonical_path);
 	}

-	if (missing)
-		printf("\t*** Some devices missing\n");
 	printf("\n");
 	return 0;
 }
--
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-07-18 16:04 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 10:06 [PATCH 1/2] btrfs-progs: fi show: Print missing device for a mounted file system Nikolay Borisov
2021-09-02 10:06 ` [PATCH 2/2] btrfs-progs: tests: Add test for fi show Nikolay Borisov
2021-09-02 10:27 ` [PATCH 1/2] btrfs-progs: fi show: Print missing device for a mounted file system Qu Wenruo
2021-09-02 10:41   ` Nikolay Borisov
2021-09-02 10:46     ` Qu Wenruo
2021-09-02 10:59       ` Nikolay Borisov
2021-09-02 12:17         ` Qu Wenruo
2021-09-06 16:47           ` g.btrfs
2021-09-06 23:24             ` Anand Jain
2021-09-07  6:03             ` Nikolay Borisov
2021-09-07  8:59               ` Graham Cobb
2021-09-07  9:15                 ` Nikolay Borisov
2021-09-07 16:28             ` Goffredo Baroncelli
2021-09-02 11:44 ` Anand Jain
2021-09-02 14:28   ` Nikolay Borisov
2021-09-03  5:12     ` Anand Jain
2021-09-03  6:58       ` Nikolay Borisov
2021-09-07 13:50 ` David Sterba
2021-09-07 14:18   ` Nikolay Borisov
2021-09-08 11:17   ` Nikolay Borisov
2022-03-29  8:30 Nikolay Borisov
2022-06-07  8:35 ` Nikolay Borisov
2022-07-18 15:59   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.