diff mbox series

[1/2] btrfs-progs: fi show: Print missing device for a mounted file system

Message ID 20220329083042.1248264-1-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series [1/2] btrfs-progs: fi show: Print missing device for a mounted file system | expand

Commit Message

Nikolay Borisov March 29, 2022, 8:30 a.m. UTC
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(-)

--
2.17.1

Comments

Nikolay Borisov June 7, 2022, 8:35 a.m. UTC | #1
On 29.03.22 г. 11:30 ч., Nikolay Borisov wrote:
> 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>


Ping
David Sterba July 18, 2022, 3:59 p.m. UTC | #2
On Tue, Jun 07, 2022 at 11:35:45AM +0300, Nikolay Borisov wrote:
> 
> 
> On 29.03.22 г. 11:30 ч., Nikolay Borisov wrote:
> > 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>
> 
> 
> Ping

Sorry for late reponse, added to devel, thanks.
diff mbox series

Patch

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;
 }