btrfs-progs: Some fix for fi usage
v2 cover btrfs-progs: Some fix for fi usage
v1->v2
These were sent several months ago, just rebased to current devel branch.
Patch 1 and 2 aims to fix the "fi du" to include the information of "fi df" even when running without root privilege.
Patch 3 is an independent cleanup.
Tomohiro Misono (3):
btrfs-progs: fi usage: change warning message more appropriately
btrfs-progs: fi usage: change to output more info without root privilege
btrfs-progs: fi usage: cleanup unnecessary permission error check
cmds-fi-usage.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
Signature · 1 line
2.14.3
PATCH v2 1/3 btrfs-progs: fi usage: change warning message more appropriately
"fi usage" shows the warning "RAID5/6 numbers will be incorrect" when running without root privilege even if raid5/6 is not used. What happens is it cannot get the per device profile usage info, so change the message more appropriately.
--- cmds-fi-usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-fi-usage.c +1 -1
@@ -629,7 +629,7 @@ int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo, ret =load_chunk_info (fd, chunkinfo, chunkcount);if (ret == -EPERM ) {warning ( -"cannot read detailed chunk info, RAID5/6 numbers will be incorrect, run as root" ); +"cannot read detailed chunk info. per device usage will not be shown, run as root" ); }else if (ret) {return ret; }
Signature · 1 line
2.14.3
Re: [PATCH v2 1/3] btrfs-progs: fi usage: change warning message more appropriately
Quoted 16 lines · Misono Tomohiro
"fi usage" shows the warning "RAID5/6 numbers will be incorrect" when running without root privilege even if raid5/6 is not used. What happens is it cannot get the per device profile usage info, so change the message more appropriately.
Reviewed-by Qu Wenruo <[email protected]>Signed-off-by Tomohiro Misono <[email protected]>--- cmds-fi-usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmds-fi-usage.c +0
-0
cmds-fi-usage.c int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo, · line 632
Quoted 5 lines
cmds-fi-usage.c +1
-1@@ -629,7 +629,7 @@ int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo, ret =load_chunk_info (fd, chunkinfo, chunkcount);if (ret == -EPERM ) {warning ( -"cannot read detailed chunk info, RAID5/6 numbers will be incorrect, run as root" ); +"cannot read detailed chunk info. per device usage will not be shown, run as root" );
^^^
nit: New sentences must start with a capital letter :)
Quoted 4 lines
cmds-fi-usage.c +0
-0}else if (ret) {return ret; }
PATCH v2 2/3 btrfs-progs: fi usage: change to output more info without root privilege
In reply to Misono TomohiroAlthough per device usage cannot be shown without root privilege, per profile usage can be shown.
To achieve this, we just basically need to remove the check of nullness of chunkinfo in print_filesystem_usage_by_chunk(), because other functions except print_unused() properly handles chunkinfo by chunkcount, which is 0 if chunkinfo is null.
As a result, "fi usage" always includes the information of "fi df".
--- cmds-fi-usage.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
cmds-fi-usage.c +5 -6
@@ -923,9 +923,11 @@ static void _cmd_filesystem_usage_linear(unsigned unit_mode,printf ("\n" ); } -printf ("Unallocated:\n" ); -print_unused (info_ptr, info_count, device_info_ptr, device_info_count, - unit_mode |UNITS_NEGATIVE ); +if (info_count) { +printf ("Unallocated:\n" ); +print_unused (info_ptr, info_count, device_info_ptr, + device_info_count, unit_mode |UNITS_NEGATIVE ); + } } static int print_filesystem_usage_by_chunk(int fd,
@@ -936,9 +938,6 @@ static int print_filesystem_usage_by_chunk(int fd,struct btrfs_ioctl_space_args *sargs;int ret =0 ; -if (!chunkinfo) -return 0 ; - sargs =load_space_info (fd, path);if (!sargs) { ret =1 ;
Signature · 1 line
2.14.3
PATCH v2 3/3 btrfs-progs: fi usage: cleanup unnecessary permission error check
In reply to Misono TomohiroSince BTRFS_IOC_FS_INFO does not require root privilege, there is no need to check EPERM error.
--- cmds-fi-usage.c | 7 ------- 1 file changed, 7 deletions(-)
cmds-fi-usage.c +0 -7
@@ -549,8 +549,6 @@ static int load_device_info(int fd, struct device_info **device_info_ptr, ret =ioctl (fd,BTRFS_IOC_FS_INFO , &fi_args);if (ret <0 ) { -if (errno ==EPERM ) -return -errno;error ("cannot get filesystem info: %m" );return 1 ; }
@@ -635,11 +633,6 @@ int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo, } ret =load_device_info (fd, devinfo, devcount); -if (ret == -EPERM ) { -warning ( -"cannot get filesystem info from ioctl(FS_INFO), run as root" ); - ret =0 ; - }return ret; }
Signature · 1 line
2.14.3
Re: [PATCH v2 3/3] btrfs-progs: fi usage: cleanup unnecessary permission error check
Quoted 2 lines · Misono Tomohiro
Since
BTRFS_IOC_FS_INFOdoes not require root privilege, there is no need to check EPERM error.
Well, this has been changed in 3.16, but there's still 3.2 longterm kernel. It does not hurt to have the check and verbose message so we may need to keep it for a few more years.
Quoted 6 lines · Misono Tomohiro
v1->v2
These were sent several months ago, just rebased to current devel branch.Patch 1 and 2 aims to fix the "fi du" to include the information of "fi df" even when running without root privilege.
Quoted 6 lines
Patch 3 is an independent cleanup.
Tomohiro Misono (3):
btrfs-progs: fi usage: change warning message more appropriately
btrfs-progs: fi usage: change to output more info without root privilege
btrfs-progs: fi usage: cleanup unnecessary permission error check
1-2 applied, thanks.