Re: [PATCH v3] btrfs-progs: make btrfs qgroups show human readable sizes

2015-01-18 Thread Wang Shilong
Hello,


 
 add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
 make columns which show sizes align to right. Others aligned to left.
 
 example:
 qgroupid rfer excl max_rfer max_excl parent  child
      --  -
 0/5 299.58MiB299.58MiB300.00MiB300.00MiB 1/1 ---
 0/265   299.58MiB 16.00KiB400.00MiB0.00B 1/1 ---
 0/266   299.58MiB 16.00KiB350.00MiB0.00B --- ---
 1/1 599.16MiB299.59MiB800.00MiB0.00B --- 0/5,0/265
 
 Signed-off-by: Fan Chengniang fancn.f...@cn.fujitsu.com
 ---
 v2:
 - change -h option to --human-readable
 - merge need_print and human_readable into format
 - add print_group_size function
 v3:
 - remove --human-readable option
 - add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
 - by default, sizes are shown in human readable format

Oh, really...
Have you run with this patch with xfstests?

I am not sure whether some qgroup tests could pass this, if not
you need keep default raw output, or please modify xfstests to make
it pass.


 - make columns which show sizes align to right. Othersligned to left.
 
 Documentation/btrfs-qgroup.txt | 14 
 cmds-qgroup.c  | 56 --
 qgroup.c   | 77 --
 qgroup.h   |  1 +
 4 files changed, 113 insertions(+), 35 deletions(-)
 
 diff --git a/Documentation/btrfs-qgroup.txt b/Documentation/btrfs-qgroup.txt
 index 3e13373..89dbd6c 100644
 --- a/Documentation/btrfs-qgroup.txt
 +++ b/Documentation/btrfs-qgroup.txt
 @@ -73,6 +73,20 @@ print max exclusive size of qgroup.
 list all qgroups which impact the given path(include ancestral qgroups)
 -f
 list all qgroups which impact the given path(exclude ancestral qgroups)
 +--raw
 +raw numbers in bytes, without the 'B' suffix.
 +--iec
 +select the 1024 base for the following options, according to the IEC 
 standard.
 +--si
 +select the 1000 base for the following options, according to the SI standard.
 +--kbytes
 +show sizes in KiB, or kB with --si.
 +--mbytes
 +show sizes in MiB, or MB with --si.
 +--gbytes
 +show sizes in GiB, or GB with --si.
 +--tbytes
 +show sizes in TiB, or TB with --si.
 --sort=[\+/-]attr[,[+/-]attr]...
 list qgroups in order of attr.
 +
 diff --git a/cmds-qgroup.c b/cmds-qgroup.c
 index 957fbc9..2474251 100644
 --- a/cmds-qgroup.c
 +++ b/cmds-qgroup.c
 @@ -208,19 +208,26 @@ static const char * const cmd_qgroup_show_usage[] = {
   btrfs qgroup show -pcreFf 
   [--sort=qgroupid,rfer,excl,max_rfer,max_excl] path,
   Show subvolume quota groups.,
 - -p print parent qgroup id,
 - -c print child qgroup id,
 - -r print max referenced size of qgroup,
 - -e print max exclusive size of qgroup,
 - -F list all qgroups which impact the given path
 + -p print parent qgroup id,
 + -c print child qgroup id,
 + -r print max referenced size of qgroup,
 + -e print max exclusive size of qgroup,
 + -F list all qgroups which impact the given path
   (include ancestral qgroups),
 - -f list all qgroups which impact the given path
 + -f list all qgroups which impact the given path
   (exclude ancestral qgroups),
 + --raw  raw numbers in bytes,
 + --iec  use 1024 as a base (KiB, MiB, GiB, TiB),
 + --si   use 1000 as a base (kB, MB, GB, TB),
 + --kbytes   show sizes in KiB, or kB with --si,
 + --mbytes   show sizes in MiB, or MB with --si,
 + --gbytes   show sizes in GiB, or GB with --si,
 + --tbytes   show sizes in TiB, or TB with --si,
   --sort=qgroupid,rfer,excl,max_rfer,max_excl,
 -list qgroups in order of qgroupid,
 +list qgroups in order of qgroupid,
   rfer,max_rfer or max_excl,
 -you can use '+' or '-' in front of each item.,
 -(+:ascending, -:descending, ascending default),
 +you can use '+' or '-' in front of each item.,
 +(+:ascending, -:descending, ascending default),
   NULL
 };
 
 @@ -234,6 +241,8 @@ static int cmd_qgroup_show(int argc, char **argv)
   int c;
   u64 qgroupid;
   int filter_flag = 0;
 + int option_index = 0;
 + unsigned unit_mode = UNITS_DEFAULT;
 
   struct btrfs_qgroup_comparer_set *comparer_set;
   struct btrfs_qgroup_filter_set *filter_set;
 @@ -241,16 +250,41 @@ static int cmd_qgroup_show(int argc, char **argv)
   comparer_set = btrfs_qgroup_alloc_comparer_set();
   struct option long_options[] = {
   {sort, 1, NULL, 'S'},
 + {raw, 

Re: [PATCH v3] btrfs-progs: make btrfs qgroups show human readable sizes

2015-01-18 Thread Fan Chengniang/樊成酿


在 2015年01月19日 15:31, Wang Shilong 写道:

Hello,



add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
make columns which show sizes align to right. Others aligned to left.

example:
qgroupid rfer excl max_rfer max_excl parent  child
     --  -
0/5 299.58MiB299.58MiB300.00MiB300.00MiB 1/1 ---
0/265   299.58MiB 16.00KiB400.00MiB0.00B 1/1 ---
0/266   299.58MiB 16.00KiB350.00MiB0.00B --- ---
1/1 599.16MiB299.59MiB800.00MiB0.00B --- 0/5,0/265

Signed-off-by: Fan Chengniang fancn.f...@cn.fujitsu.com
---
v2:
- change -h option to --human-readable
- merge need_print and human_readable into format
- add print_group_size function
v3:
- remove --human-readable option
- add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
- by default, sizes are shown in human readable format

Oh, really...
Have you run with this patch with xfstests?

I am not sure whether some qgroup tests could pass this, if not
you need keep default raw output, or please modify xfstests to make
it pass.


I will test and repair it.thanx

- make columns which show sizes align to right. Othersligned to left.

Documentation/btrfs-qgroup.txt | 14 
cmds-qgroup.c  | 56 --
qgroup.c   | 77 --
qgroup.h   |  1 +
4 files changed, 113 insertions(+), 35 deletions(-)

diff --git a/Documentation/btrfs-qgroup.txt b/Documentation/btrfs-qgroup.txt
index 3e13373..89dbd6c 100644
--- a/Documentation/btrfs-qgroup.txt
+++ b/Documentation/btrfs-qgroup.txt
@@ -73,6 +73,20 @@ print max exclusive size of qgroup.
list all qgroups which impact the given path(include ancestral qgroups)
-f
list all qgroups which impact the given path(exclude ancestral qgroups)
+--raw
+raw numbers in bytes, without the 'B' suffix.
+--iec
+select the 1024 base for the following options, according to the IEC standard.
+--si
+select the 1000 base for the following options, according to the SI standard.
+--kbytes
+show sizes in KiB, or kB with --si.
+--mbytes
+show sizes in MiB, or MB with --si.
+--gbytes
+show sizes in GiB, or GB with --si.
+--tbytes
+show sizes in TiB, or TB with --si.
--sort=[\+/-]attr[,[+/-]attr]...
list qgroups in order of attr.
+
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 957fbc9..2474251 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -208,19 +208,26 @@ static const char * const cmd_qgroup_show_usage[] = {
btrfs qgroup show -pcreFf 
[--sort=qgroupid,rfer,excl,max_rfer,max_excl] path,
Show subvolume quota groups.,
-   -pprint parent qgroup id,
-   -cprint child qgroup id,
-   -rprint max referenced size of qgroup,
-   -eprint max exclusive size of qgroup,
-   -Flist all qgroups which impact the given path
+   -p print parent qgroup id,
+   -c print child qgroup id,
+   -r print max referenced size of qgroup,
+   -e print max exclusive size of qgroup,
+   -F list all qgroups which impact the given path
(include ancestral qgroups),
-   -flist all qgroups which impact the given path
+   -f list all qgroups which impact the given path
(exclude ancestral qgroups),
+   --raw  raw numbers in bytes,
+   --iec  use 1024 as a base (KiB, MiB, GiB, TiB),
+   --si   use 1000 as a base (kB, MB, GB, TB),
+   --kbytes   show sizes in KiB, or kB with --si,
+   --mbytes   show sizes in MiB, or MB with --si,
+   --gbytes   show sizes in GiB, or GB with --si,
+   --tbytes   show sizes in TiB, or TB with --si,
--sort=qgroupid,rfer,excl,max_rfer,max_excl,
- list qgroups in order of qgroupid,
+  list qgroups in order of qgroupid,
rfer,max_rfer or max_excl,
- you can use '+' or '-' in front of each item.,
- (+:ascending, -:descending, ascending default),
+  you can use '+' or '-' in front of each item.,
+  (+:ascending, -:descending, ascending default),
NULL
};

@@ -234,6 +241,8 @@ static int cmd_qgroup_show(int argc, char **argv)
int c;
u64 qgroupid;
int filter_flag = 0;
+   int option_index = 0;
+   unsigned unit_mode = UNITS_DEFAULT;

struct btrfs_qgroup_comparer_set *comparer_set;
struct btrfs_qgroup_filter_set *filter_set;
@@ -241,16 +250,41 @@ static int cmd_qgroup_show(int argc, char **argv)
comparer_set = btrfs_qgroup_alloc_comparer_set();
struct option long_options[] = {

[PATCH v3] btrfs-progs: make btrfs qgroups show human readable sizes

2015-01-18 Thread Fan Chengniang
add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
make columns which show sizes align to right. Others aligned to left.

example:
qgroupid rfer excl max_rfer max_excl parent  child
     --  -
0/5 299.58MiB299.58MiB300.00MiB300.00MiB 1/1 ---
0/265   299.58MiB 16.00KiB400.00MiB0.00B 1/1 ---
0/266   299.58MiB 16.00KiB350.00MiB0.00B --- ---
1/1 599.16MiB299.59MiB800.00MiB0.00B --- 0/5,0/265

Signed-off-by: Fan Chengniang fancn.f...@cn.fujitsu.com
---
v2:
- change -h option to --human-readable
- merge need_print and human_readable into format
- add print_group_size function
v3:
- remove --human-readable option
- add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
- by default, sizes are shown in human readable format
- make columns which show sizes align to right. Others aligned to left.

 Documentation/btrfs-qgroup.txt | 14 
 cmds-qgroup.c  | 56 --
 qgroup.c   | 77 --
 qgroup.h   |  1 +
 4 files changed, 113 insertions(+), 35 deletions(-)

diff --git a/Documentation/btrfs-qgroup.txt b/Documentation/btrfs-qgroup.txt
index 3e13373..89dbd6c 100644
--- a/Documentation/btrfs-qgroup.txt
+++ b/Documentation/btrfs-qgroup.txt
@@ -73,6 +73,20 @@ print max exclusive size of qgroup.
 list all qgroups which impact the given path(include ancestral qgroups)
 -f
 list all qgroups which impact the given path(exclude ancestral qgroups)
+--raw
+raw numbers in bytes, without the 'B' suffix.
+--iec
+select the 1024 base for the following options, according to the IEC standard.
+--si
+select the 1000 base for the following options, according to the SI standard.
+--kbytes
+show sizes in KiB, or kB with --si.
+--mbytes
+show sizes in MiB, or MB with --si.
+--gbytes
+show sizes in GiB, or GB with --si.
+--tbytes
+show sizes in TiB, or TB with --si.
 --sort=[\+/-]attr[,[+/-]attr]...
 list qgroups in order of attr.
 +
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 957fbc9..2474251 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -208,19 +208,26 @@ static const char * const cmd_qgroup_show_usage[] = {
btrfs qgroup show -pcreFf 
[--sort=qgroupid,rfer,excl,max_rfer,max_excl] path,
Show subvolume quota groups.,
-   -p print parent qgroup id,
-   -c print child qgroup id,
-   -r print max referenced size of qgroup,
-   -e print max exclusive size of qgroup,
-   -F list all qgroups which impact the given path
+   -p print parent qgroup id,
+   -c print child qgroup id,
+   -r print max referenced size of qgroup,
+   -e print max exclusive size of qgroup,
+   -F list all qgroups which impact the given path
(include ancestral qgroups),
-   -f list all qgroups which impact the given path
+   -f list all qgroups which impact the given path
(exclude ancestral qgroups),
+   --raw  raw numbers in bytes,
+   --iec  use 1024 as a base (KiB, MiB, GiB, TiB),
+   --si   use 1000 as a base (kB, MB, GB, TB),
+   --kbytes   show sizes in KiB, or kB with --si,
+   --mbytes   show sizes in MiB, or MB with --si,
+   --gbytes   show sizes in GiB, or GB with --si,
+   --tbytes   show sizes in TiB, or TB with --si,
--sort=qgroupid,rfer,excl,max_rfer,max_excl,
-  list qgroups in order of qgroupid,
+  list qgroups in order of qgroupid,
rfer,max_rfer or max_excl,
-  you can use '+' or '-' in front of each item.,
-  (+:ascending, -:descending, ascending default),
+  you can use '+' or '-' in front of each item.,
+  (+:ascending, -:descending, ascending default),
NULL
 };
 
@@ -234,6 +241,8 @@ static int cmd_qgroup_show(int argc, char **argv)
int c;
u64 qgroupid;
int filter_flag = 0;
+   int option_index = 0;
+   unsigned unit_mode = UNITS_DEFAULT;
 
struct btrfs_qgroup_comparer_set *comparer_set;
struct btrfs_qgroup_filter_set *filter_set;
@@ -241,16 +250,41 @@ static int cmd_qgroup_show(int argc, char **argv)
comparer_set = btrfs_qgroup_alloc_comparer_set();
struct option long_options[] = {
{sort, 1, NULL, 'S'},
+   {raw, no_argument, NULL, 0},
+   {kbytes, no_argument, NULL, 0},
+   {mbytes, no_argument, NULL, 0},
+   {gbytes, no_argument, NULL, 0},
+   {tbytes, no_argument, NULL, 0},
+