* [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands
@ 2014-12-18 14:27 David Sterba
2014-12-18 14:27 ` [PATCH 1/6] btrfs-progs: fi usage, change option for tabular output to T David Sterba
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Copy from 'fi df' to 'fi usage' and 'dev usage'.
David Sterba (6):
btrfs-progs: fi usage, change option for tabular output to T
btrfs-progs: fi usage, add switches to set output units
btrfs-progs: fi usage, update manpage
btrfs-progs: dev usage, add switches to set output units
btrfs-progs: dev usage, update manpage
btrfs-progs: unify unit mode parameters and variables
Documentation/btrfs-device.txt | 26 ++++++++
Documentation/btrfs-filesystem.txt | 28 ++++++++
cmds-device.c | 66 ++++++++++++++----
cmds-fi-disk_usage.c | 133 ++++++++++++++++++++++++-------------
cmds-fi-disk_usage.h | 4 +-
5 files changed, 197 insertions(+), 60 deletions(-)
--
2.1.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/6] btrfs-progs: fi usage, change option for tabular output to T
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
@ 2014-12-18 14:27 ` David Sterba
2014-12-18 14:27 ` [PATCH 2/6] btrfs-progs: fi usage, add switches to set output units David Sterba
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We're going to use -t for tera- units prefix, same as 'fi df' does.
Signed-off-by: David Sterba <dsterba@suse.cz>
---
cmds-fi-disk_usage.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 6a33b5d1da51..77ab8b4c1604 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -848,7 +848,7 @@ const char * const cmd_filesystem_usage_usage[] = {
"Show in which disk the chunks are allocated.",
"",
"-b\tSet byte as unit",
- "-t\tShow data in tabular format",
+ "-T\tShow data in tabular format",
NULL
};
@@ -861,7 +861,7 @@ int cmd_filesystem_usage(int argc, char **argv)
optind = 1;
while (1) {
- int c = getopt(argc, argv, "bt");
+ int c = getopt(argc, argv, "bT");
if (c < 0)
break;
@@ -870,7 +870,7 @@ int cmd_filesystem_usage(int argc, char **argv)
case 'b':
mode = UNITS_RAW;
break;
- case 't':
+ case 'T':
tabular = 1;
break;
default:
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/6] btrfs-progs: fi usage, add switches to set output units
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
2014-12-18 14:27 ` [PATCH 1/6] btrfs-progs: fi usage, change option for tabular output to T David Sterba
@ 2014-12-18 14:27 ` David Sterba
2014-12-18 14:27 ` [PATCH 3/6] btrfs-progs: fi usage, update manpage David Sterba
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Same set of options as 'fi df': binary and decimal bases, human readable
options etc.
Signed-off-by: David Sterba <dsterba@suse.cz>
---
cmds-fi-disk_usage.c | 64 +++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 53 insertions(+), 11 deletions(-)
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 77ab8b4c1604..b3b70cc23fd1 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -21,6 +21,7 @@
#include <sys/ioctl.h>
#include <errno.h>
#include <stdarg.h>
+#include <getopt.h>
#include "utils.h"
#include "kerncompat.h"
@@ -844,31 +845,72 @@ out:
}
const char * const cmd_filesystem_usage_usage[] = {
- "btrfs filesystem usage [-b][-t] <path> [<path>..]",
- "Show in which disk the chunks are allocated.",
- "",
- "-b\tSet byte as unit",
- "-T\tShow data in tabular format",
+ "btrfs filesystem usage [options] <path> [<path>..]",
+ "Show detailed information about internal filesystem usage .",
+ "-b|--raw raw numbers in bytes",
+ "-h human friendly numbers, base 1024 (default)",
+ "-H human friendly numbers, base 1000",
+ "--iec use 1024 as a base (KiB, MiB, GiB, TiB)",
+ "--si use 1000 as a base (kB, MB, GB, TB)",
+ "-k|--kbytes show sizes in KiB, or kB with --si",
+ "-m|--mbytes show sizes in MiB, or MB with --si",
+ "-g|--gbytes show sizes in GiB, or GB with --si",
+ "-t|--tbytes show sizes in TiB, or TB with --si",
+ "-T show data in tabular format",
NULL
};
int cmd_filesystem_usage(int argc, char **argv)
{
- int mode = UNITS_HUMAN;
+ unsigned unit_mode = UNITS_DEFAULT;
int ret = 0;
int i, more_than_one = 0;
int tabular = 0;
optind = 1;
while (1) {
- int c = getopt(argc, argv, "bT");
+ int long_index;
+ static const struct option long_options[] = {
+ { "raw", no_argument, NULL, 'b'},
+ { "kbytes", no_argument, NULL, 'k'},
+ { "mbytes", no_argument, NULL, 'm'},
+ { "gbytes", no_argument, NULL, 'g'},
+ { "tbytes", no_argument, NULL, 't'},
+ { "si", no_argument, NULL, 256},
+ { "iec", no_argument, NULL, 257},
+ };
+ int c = getopt_long(argc, argv, "bhHkmgtT", long_options,
+ &long_index);
if (c < 0)
break;
-
switch (c) {
case 'b':
- mode = UNITS_RAW;
+ unit_mode = UNITS_RAW;
+ break;
+ case 'k':
+ units_set_base(&unit_mode, UNITS_KBYTES);
+ break;
+ case 'm':
+ units_set_base(&unit_mode, UNITS_MBYTES);
+ break;
+ case 'g':
+ units_set_base(&unit_mode, UNITS_GBYTES);
+ break;
+ case 't':
+ units_set_base(&unit_mode, UNITS_TBYTES);
+ break;
+ case 'h':
+ unit_mode = UNITS_HUMAN_BINARY;
+ break;
+ case 'H':
+ unit_mode = UNITS_HUMAN_DECIMAL;
+ break;
+ case 256:
+ units_set_mode(&unit_mode, UNITS_DECIMAL);
+ break;
+ case 257:
+ units_set_mode(&unit_mode, UNITS_BINARY);
break;
case 'T':
tabular = 1;
@@ -905,12 +947,12 @@ int cmd_filesystem_usage(int argc, char **argv)
goto cleanup;
ret = print_filesystem_usage_overall(fd, chunkinfo, chunkcount,
- devinfo, devcount, argv[i], mode);
+ devinfo, devcount, argv[i], unit_mode);
if (ret)
goto cleanup;
printf("\n");
ret = print_filesystem_usage_by_chunk(fd, chunkinfo, chunkcount,
- devinfo, devcount, argv[i], mode, tabular);
+ devinfo, devcount, argv[i], unit_mode, tabular);
cleanup:
close_file_or_dir(fd, dirstream);
free(chunkinfo);
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/6] btrfs-progs: fi usage, update manpage
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
2014-12-18 14:27 ` [PATCH 1/6] btrfs-progs: fi usage, change option for tabular output to T David Sterba
2014-12-18 14:27 ` [PATCH 2/6] btrfs-progs: fi usage, add switches to set output units David Sterba
@ 2014-12-18 14:27 ` David Sterba
2014-12-19 5:04 ` Satoru Takeuchi
2014-12-18 14:27 ` [PATCH 4/6] btrfs-progs: dev usage, add switches to set output units David Sterba
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Signed-off-by: David Sterba <dsterba@suse.cz>
---
Documentation/btrfs-filesystem.txt | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/Documentation/btrfs-filesystem.txt b/Documentation/btrfs-filesystem.txt
index a8f2972a0e1a..85a94eb52569 100644
--- a/Documentation/btrfs-filesystem.txt
+++ b/Documentation/btrfs-filesystem.txt
@@ -123,6 +123,34 @@ Show or update the label of a filesystem.
If a newlabel optional argument is passed, the label is changed.
NOTE: the maximum allowable length shall be less than 256 chars
+*usage* [options] <path> [<path>...]::
+Show detailed information about internal filesystem usage.
++
+`Options`
++
+-b|--raw::::
+raw numbers in bytes, without the 'B' suffix
+-h::::
+print human friendly numbers, base 1024, this is the default
+-H::::
+print human friendly numbers, base 1000
+--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
+-k|--kbytes::::
+show sizes in KiB, or kB with --si
+-m|--mbytes::::
+show sizes in MiB, or MB with --si
+-g|--gbytes::::
+show sizes in GiB, or GB with --si
+-t|--tbytes::::
+show sizes in TiB, or TB with --si
+-T::::
+show data in tabular format
+
+If conflicting options are passed, the last one takes precedence.
+
EXIT STATUS
-----------
*btrfs filesystem* returns a zero exit status if it succeeds. Non zero is
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/6] btrfs-progs: dev usage, add switches to set output units
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
` (2 preceding siblings ...)
2014-12-18 14:27 ` [PATCH 3/6] btrfs-progs: fi usage, update manpage David Sterba
@ 2014-12-18 14:27 ` David Sterba
2014-12-18 14:27 ` [PATCH 5/6] btrfs-progs: dev usage, update manpage David Sterba
2014-12-18 14:28 ` [PATCH 6/6] btrfs-progs: unify unit mode parameters and variables David Sterba
5 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Same set of options as 'fi df': binary and decimal bases, human readable
options etc.
Signed-off-by: David Sterba <dsterba@suse.cz>
---
cmds-device.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 50 insertions(+), 10 deletions(-)
diff --git a/cmds-device.c b/cmds-device.c
index 33f1311a546c..13458d850c26 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -451,10 +451,17 @@ out:
}
const char * const cmd_device_usage_usage[] = {
- "btrfs device usage [-b] <path> [<path>..]",
- "Show which chunks are in a device.",
- "",
- "-b\tSet byte as unit",
+ "btrfs device usage [options] <path> [<path>..]",
+ "Show detailed information about internal allocations in devices.",
+ "-b|--raw raw numbers in bytes",
+ "-h human friendly numbers, base 1024 (default)",
+ "-H human friendly numbers, base 1000",
+ "--iec use 1024 as a base (KiB, MiB, GiB, TiB)",
+ "--si use 1000 as a base (kB, MB, GB, TB)",
+ "-k|--kbytes show sizes in KiB, or kB with --si",
+ "-m|--mbytes show sizes in MiB, or MB with --si",
+ "-g|--gbytes show sizes in GiB, or GB with --si",
+ "-t|--tbytes show sizes in TiB, or TB with --si",
NULL
};
@@ -489,21 +496,54 @@ out:
int cmd_device_usage(int argc, char **argv)
{
-
- int mode = UNITS_HUMAN;
+ unsigned unit_mode = UNITS_DEFAULT;
int ret = 0;
int i, more_than_one = 0;
optind = 1;
while (1) {
- int c = getopt(argc, argv, "b");
+ int long_index;
+ static const struct option long_options[] = {
+ { "raw", no_argument, NULL, 'b'},
+ { "kbytes", no_argument, NULL, 'k'},
+ { "mbytes", no_argument, NULL, 'm'},
+ { "gbytes", no_argument, NULL, 'g'},
+ { "tbytes", no_argument, NULL, 't'},
+ { "si", no_argument, NULL, 256},
+ { "iec", no_argument, NULL, 257},
+ };
+ int c = getopt_long(argc, argv, "bhHkmgt", long_options,
+ &long_index);
if (c < 0)
break;
-
switch (c) {
case 'b':
- mode = UNITS_RAW;
+ unit_mode = UNITS_RAW;
+ break;
+ case 'k':
+ units_set_base(&unit_mode, UNITS_KBYTES);
+ break;
+ case 'm':
+ units_set_base(&unit_mode, UNITS_MBYTES);
+ break;
+ case 'g':
+ units_set_base(&unit_mode, UNITS_GBYTES);
+ break;
+ case 't':
+ units_set_base(&unit_mode, UNITS_TBYTES);
+ break;
+ case 'h':
+ unit_mode = UNITS_HUMAN_BINARY;
+ break;
+ case 'H':
+ unit_mode = UNITS_HUMAN_DECIMAL;
+ break;
+ case 256:
+ units_set_mode(&unit_mode, UNITS_DECIMAL);
+ break;
+ case 257:
+ units_set_mode(&unit_mode, UNITS_BINARY);
break;
default:
usage(cmd_device_usage_usage);
@@ -527,7 +567,7 @@ int cmd_device_usage(int argc, char **argv)
goto out;
}
- ret = _cmd_device_usage(fd, argv[i], mode);
+ ret = _cmd_device_usage(fd, argv[i], unit_mode);
close_file_or_dir(fd, dirstream);
if (ret)
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/6] btrfs-progs: dev usage, update manpage
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
` (3 preceding siblings ...)
2014-12-18 14:27 ` [PATCH 4/6] btrfs-progs: dev usage, add switches to set output units David Sterba
@ 2014-12-18 14:27 ` David Sterba
2014-12-18 14:28 ` [PATCH 6/6] btrfs-progs: unify unit mode parameters and variables David Sterba
5 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Signed-off-by: David Sterba <dsterba@suse.cz>
---
Documentation/btrfs-device.txt | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/Documentation/btrfs-device.txt b/Documentation/btrfs-device.txt
index 46c54b94413c..4cd633fe6c03 100644
--- a/Documentation/btrfs-device.txt
+++ b/Documentation/btrfs-device.txt
@@ -98,6 +98,32 @@ identified by <path> or for a single <device>.
-z::::
Reset stats to zero after reading them.
+*usage* [options] <path> [<path>...]::
+Show detailed information about internal allocations in devices.
++
+`Options`
++
+-b|--raw::::
+raw numbers in bytes, without the 'B' suffix
+-h::::
+print human friendly numbers, base 1024, this is the default
+-H::::
+print human friendly numbers, base 1000
+--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
+-k|--kbytes::::
+show sizes in KiB, or kB with --si
+-m|--mbytes::::
+show sizes in MiB, or MB with --si
+-g|--gbytes::::
+show sizes in GiB, or GB with --si
+-t|--tbytes::::
+show sizes in TiB, or TB with --si
+
+If conflicting options are passed, the last one takes precedence.
+
EXIT STATUS
-----------
*btrfs device* returns a zero exit status if it succeeds. Non zero is
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/6] btrfs-progs: unify unit mode parameters and variables
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
` (4 preceding siblings ...)
2014-12-18 14:27 ` [PATCH 5/6] btrfs-progs: dev usage, update manpage David Sterba
@ 2014-12-18 14:28 ` David Sterba
5 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2014-12-18 14:28 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use unsigned type and a common name everywhere.
Signed-off-by: David Sterba <dsterba@suse.cz>
---
cmds-device.c | 6 ++---
cmds-fi-disk_usage.c | 69 ++++++++++++++++++++++++++--------------------------
cmds-fi-disk_usage.h | 4 +--
3 files changed, 40 insertions(+), 39 deletions(-)
diff --git a/cmds-device.c b/cmds-device.c
index 13458d850c26..9dd52a4b9fac 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -465,7 +465,7 @@ const char * const cmd_device_usage_usage[] = {
NULL
};
-static int _cmd_device_usage(int fd, char *path, int mode)
+static int _cmd_device_usage(int fd, char *path, unsigned unit_mode)
{
int i;
int ret = 0;
@@ -481,9 +481,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
for (i = 0; i < devcount; i++) {
printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
- print_device_sizes(fd, &devinfo[i], mode);
+ print_device_sizes(fd, &devinfo[i], unit_mode);
print_device_chunks(fd, &devinfo[i], chunkinfo, chunkcount,
- mode);
+ unit_mode);
printf("\n");
}
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index b3b70cc23fd1..d81f01155e6c 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -310,7 +310,7 @@ static void get_raid56_used(int fd, struct chunk_info *chunks, int chunkcount,
#define MIN_UNALOCATED_THRESH (16 * 1024 * 1024)
static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
int chunkcount, struct device_info *devinfo, int devcount,
- char *path, int mode)
+ char *path, unsigned unit_mode)
{
struct btrfs_ioctl_space_args *sargs = 0;
int i;
@@ -450,30 +450,30 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
free_min += r_total_unused / max_data_ratio;
}
- if (mode != UNITS_HUMAN)
+ if (unit_mode != UNITS_HUMAN)
width = 18;
printf("Overall:\n");
printf(" Device size:\t\t%*s\n", width,
- pretty_size_mode(r_total_size, mode));
+ pretty_size_mode(r_total_size, unit_mode));
printf(" Device allocated:\t\t%*s\n", width,
- pretty_size_mode(r_total_chunks, mode));
+ pretty_size_mode(r_total_chunks, unit_mode));
printf(" Device unallocated:\t\t%*s\n", width,
- pretty_size_mode(r_total_unused, mode));
+ pretty_size_mode(r_total_unused, unit_mode));
printf(" Used:\t\t\t%*s\n", width,
- pretty_size_mode(r_total_used, mode));
+ pretty_size_mode(r_total_used, unit_mode));
printf(" Free (estimated):\t\t%*s\t(",
width,
- pretty_size_mode(free_estimated, mode));
- printf("min: %s)\n", pretty_size_mode(free_min, mode));
+ pretty_size_mode(free_estimated, unit_mode));
+ printf("min: %s)\n", pretty_size_mode(free_min, unit_mode));
printf(" Data ratio:\t\t\t%*.2f\n",
width, data_ratio);
printf(" Metadata ratio:\t\t%*.2f\n",
width, metadata_ratio);
printf(" Global reserve:\t\t%*s\t(used: %s)\n", width,
- pretty_size_mode(l_global_reserve, mode),
- pretty_size_mode(l_global_reserve_used, mode));
+ pretty_size_mode(l_global_reserve, unit_mode),
+ pretty_size_mode(l_global_reserve_used, unit_mode));
exit:
@@ -601,7 +601,7 @@ static u64 calc_chunk_size(struct chunk_info *ci)
* This function print the results of the command "btrfs fi usage"
* in tabular format
*/
-static void _cmd_filesystem_usage_tabular(int mode,
+static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
struct btrfs_ioctl_space_args *sargs,
struct chunk_info *chunks_info_ptr,
int chunks_info_count,
@@ -678,7 +678,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
if (size)
table_printf(matrix, col, i+3,
- ">%s", pretty_size_mode(size, mode));
+ ">%s", pretty_size_mode(size, unit_mode));
else
table_printf(matrix, col, i+3, ">-");
@@ -690,7 +690,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
- total_allocated;
table_printf(matrix, sargs->total_spaces + 1, i + 3,
- ">%s", pretty_size_mode(unused, mode));
+ ">%s", pretty_size_mode(unused, unit_mode));
total_unused += unused;
}
@@ -702,15 +702,15 @@ static void _cmd_filesystem_usage_tabular(int mode,
table_printf(matrix, 0, device_info_count + 4, "<Total");
for (i = 0; i < sargs->total_spaces; i++)
table_printf(matrix, 1 + i, device_info_count + 4, ">%s",
- pretty_size_mode(sargs->spaces[i].total_bytes, mode));
+ pretty_size_mode(sargs->spaces[i].total_bytes, unit_mode));
table_printf(matrix, sargs->total_spaces + 1, device_info_count + 4,
- ">%s", pretty_size_mode(total_unused, mode));
+ ">%s", pretty_size_mode(total_unused, unit_mode));
table_printf(matrix, 0, device_info_count + 5, "<Used");
for (i = 0; i < sargs->total_spaces; i++)
table_printf(matrix, 1 + i, device_info_count+5, ">%s",
- pretty_size_mode(sargs->spaces[i].used_bytes, mode));
+ pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode));
table_dump(matrix);
table_free(matrix);
@@ -723,7 +723,7 @@ static void print_unused(struct chunk_info *info_ptr,
int info_count,
struct device_info *device_info_ptr,
int device_info_count,
- int mode)
+ unsigned unit_mode)
{
int i;
for (i = 0; i < device_info_count; i++) {
@@ -736,7 +736,8 @@ static void print_unused(struct chunk_info *info_ptr,
printf(" %s\t%10s\n",
device_info_ptr[i].path,
- pretty_size_mode(device_info_ptr[i].size - total, mode));
+ pretty_size_mode(device_info_ptr[i].size - total,
+ unit_mode));
}
}
@@ -748,7 +749,7 @@ static void print_chunk_device(u64 chunk_type,
int chunks_info_count,
struct device_info *device_info_ptr,
int device_info_count,
- int mode)
+ unsigned unit_mode)
{
int i;
@@ -770,7 +771,7 @@ static void print_chunk_device(u64 chunk_type,
if (total > 0)
printf(" %s\t%10s\n",
device_info_ptr[i].path,
- pretty_size_mode(total, mode));
+ pretty_size_mode(total, unit_mode));
}
}
@@ -778,7 +779,7 @@ static void print_chunk_device(u64 chunk_type,
* This function print the results of the command "btrfs fi usage"
* in linear format
*/
-static void _cmd_filesystem_usage_linear(int mode,
+static void _cmd_filesystem_usage_linear(unsigned unit_mode,
struct btrfs_ioctl_space_args *sargs,
struct chunk_info *info_ptr,
int info_count,
@@ -802,23 +803,23 @@ static void _cmd_filesystem_usage_linear(int mode,
description,
r_mode,
pretty_size_mode(sargs->spaces[i].total_bytes,
- mode));
+ unit_mode));
printf("Used:%s\n",
- pretty_size_mode(sargs->spaces[i].used_bytes, mode));
+ pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode));
print_chunk_device(flags, info_ptr, info_count,
- device_info_ptr, device_info_count, mode);
+ device_info_ptr, device_info_count, unit_mode);
printf("\n");
}
printf("Unallocated:\n");
print_unused(info_ptr, info_count, device_info_ptr, device_info_count,
- mode);
+ unit_mode);
}
static int print_filesystem_usage_by_chunk(int fd,
struct chunk_info *chunkinfo, int chunkcount,
struct device_info *devinfo, int devcount,
- char *path, int mode, int tabular)
+ char *path, unsigned unit_mode, int tabular)
{
struct btrfs_ioctl_space_args *sargs;
int ret = 0;
@@ -833,10 +834,10 @@ static int print_filesystem_usage_by_chunk(int fd,
}
if (tabular)
- _cmd_filesystem_usage_tabular(mode, sargs, chunkinfo,
+ _cmd_filesystem_usage_tabular(unit_mode, sargs, chunkinfo,
chunkcount, devinfo, devcount);
else
- _cmd_filesystem_usage_linear(mode, sargs, chunkinfo,
+ _cmd_filesystem_usage_linear(unit_mode, sargs, chunkinfo,
chunkcount, devinfo, devcount);
free(sargs);
@@ -969,7 +970,7 @@ out:
void print_device_chunks(int fd, struct device_info *devinfo,
struct chunk_info *chunks_info_ptr,
- int chunks_info_count, int mode)
+ int chunks_info_count, unsigned unit_mode)
{
int i;
u64 allocated = 0;
@@ -992,21 +993,21 @@ void print_device_chunks(int fd, struct device_info *devinfo,
description,
r_mode,
(int)(20 - strlen(description) - strlen(r_mode)), "",
- pretty_size_mode(size, mode));
+ pretty_size_mode(size, unit_mode));
allocated += size;
}
printf(" Unallocated: %*s%10s\n",
(int)(20 - strlen("Unallocated")), "",
- pretty_size_mode(devinfo->size - allocated, mode));
+ pretty_size_mode(devinfo->size - allocated, unit_mode));
}
-void print_device_sizes(int fd, struct device_info *devinfo, int mode)
+void print_device_sizes(int fd, struct device_info *devinfo, unsigned unit_mode)
{
printf(" Device size: %*s%10s\n",
(int)(20 - strlen("Device size")), "",
- pretty_size_mode(devinfo->device_size, mode));
+ pretty_size_mode(devinfo->device_size, unit_mode));
#if 0
/*
* The term has not seen an agreement and we don't want to change it
@@ -1014,6 +1015,6 @@ void print_device_sizes(int fd, struct device_info *devinfo, int mode)
*/
printf(" FS occupied: %*s%10s\n",
(int)(20 - strlen("FS occupied")), "",
- pretty_size_mode(devinfo->size, mode));
+ pretty_size_mode(devinfo->size, unit_mode));
#endif
}
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index 8a0c60f011e4..a76e77bf8c31 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -48,7 +48,7 @@ int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo,
int *chunkcount, struct device_info **devinfo, int *devcount);
void print_device_chunks(int fd, struct device_info *devinfo,
struct chunk_info *chunks_info_ptr,
- int chunks_info_count, int mode);
-void print_device_sizes(int fd, struct device_info *devinfo, int mode);
+ int chunks_info_count, unsigned unit_mode);
+void print_device_sizes(int fd, struct device_info *devinfo, unsigned unit_mode);
#endif
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] btrfs-progs: fi usage, update manpage
2014-12-18 14:27 ` [PATCH 3/6] btrfs-progs: fi usage, update manpage David Sterba
@ 2014-12-19 5:04 ` Satoru Takeuchi
2014-12-19 9:56 ` Satoru Takeuchi
0 siblings, 1 reply; 11+ messages in thread
From: Satoru Takeuchi @ 2014-12-19 5:04 UTC (permalink / raw)
To: David Sterba, linux-btrfs
Hi David,
On 2014/12/18 23:27, David Sterba wrote:
> Signed-off-by: David Sterba <dsterba@suse.cz>
> ---
> Documentation/btrfs-filesystem.txt | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/Documentation/btrfs-filesystem.txt b/Documentation/btrfs-filesystem.txt
> index a8f2972a0e1a..85a94eb52569 100644
> --- a/Documentation/btrfs-filesystem.txt
> +++ b/Documentation/btrfs-filesystem.txt
> @@ -123,6 +123,34 @@ Show or update the label of a filesystem.
> If a newlabel optional argument is passed, the label is changed.
> NOTE: the maximum allowable length shall be less than 256 chars
>
> +*usage* [options] <path> [<path>...]::
> +Show detailed information about internal filesystem usage.
Options from "-b" to "-t" are the completely same as "btrfs fi df"'s ones.
So how about pointing the df's options as follows?
===============================================================================
...
+
`Options`
+
-T::::
Show data in tabular format
+
There are some option to set unit. See description of *df*'s options
from '-b' to '-t'.
+
If conflicting options are passed, the last one takes precedence.
...
===============================================================================
I consider it can prevent mistakes caused by further changes.
Thanks,
Satoru
> ++
> +`Options`
> ++
> +-b|--raw::::
> +raw numbers in bytes, without the 'B' suffix
> +-h::::
> +print human friendly numbers, base 1024, this is the default
> +-H::::
> +print human friendly numbers, base 1000
> +--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
> +-k|--kbytes::::
> +show sizes in KiB, or kB with --si
> +-m|--mbytes::::
> +show sizes in MiB, or MB with --si
> +-g|--gbytes::::
> +show sizes in GiB, or GB with --si
> +-t|--tbytes::::
> +show sizes in TiB, or TB with --si
> +-T::::
> +show data in tabular format
> +
> +If conflicting options are passed, the last one takes precedence.
> +
> EXIT STATUS
> -----------
> *btrfs filesystem* returns a zero exit status if it succeeds. Non zero is
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] btrfs-progs: fi usage, update manpage
2014-12-19 5:04 ` Satoru Takeuchi
@ 2014-12-19 9:56 ` Satoru Takeuchi
2014-12-19 13:36 ` David Sterba
0 siblings, 1 reply; 11+ messages in thread
From: Satoru Takeuchi @ 2014-12-19 9:56 UTC (permalink / raw)
To: David Sterba, linux-btrfs
Hi David,
> On 2014/12/18 23:27, David Sterba wrote:
>> Signed-off-by: David Sterba <dsterba@suse.cz>
>> ---
>> Documentation/btrfs-filesystem.txt | 28 ++++++++++++++++++++++++++++
>> 1 file changed, 28 insertions(+)
>>
>> diff --git a/Documentation/btrfs-filesystem.txt b/Documentation/btrfs-filesystem.txt
>> index a8f2972a0e1a..85a94eb52569 100644
>> --- a/Documentation/btrfs-filesystem.txt
>> +++ b/Documentation/btrfs-filesystem.txt
>> @@ -123,6 +123,34 @@ Show or update the label of a filesystem.
>> If a newlabel optional argument is passed, the label is changed.
>> NOTE: the maximum allowable length shall be less than 256 chars
>>
>> +*usage* [options] <path> [<path>...]::
>> +Show detailed information about internal filesystem usage.
>
> Options from "-b" to "-t" are the completely same as "btrfs fi df"'s ones.
> So how about pointing the df's options as follows?
>
> ===============================================================================
> ...
> +
> `Options`
> +
> -T::::
> Show data in tabular format
> +
> There are some option to set unit. See description of *df*'s options
> from '-b' to '-t'.
> +
> If conflicting options are passed, the last one takes precedence.
> ...
> ===============================================================================
>
> I consider it can prevent mistakes caused by further changes.
This patch seems to already be in devel/integration-20141218.
Here is the patch example.
---
From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Subject: [PATCH] btrfs-progs: Cleanup: Fix the redundancy of btrfs-filesystem.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
Documentation/btrfs-filesystem.txt | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/Documentation/btrfs-filesystem.txt b/Documentation/btrfs-filesystem.txt
index 85a94eb..a8e7431 100644
--- a/Documentation/btrfs-filesystem.txt
+++ b/Documentation/btrfs-filesystem.txt
@@ -128,27 +128,12 @@ Show detailed information about internal filesystem usage.
+
`Options`
+
--b|--raw::::
-raw numbers in bytes, without the 'B' suffix
--h::::
-print human friendly numbers, base 1024, this is the default
--H::::
-print human friendly numbers, base 1000
---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
--k|--kbytes::::
-show sizes in KiB, or kB with --si
--m|--mbytes::::
-show sizes in MiB, or MB with --si
--g|--gbytes::::
-show sizes in GiB, or GB with --si
--t|--tbytes::::
-show sizes in TiB, or TB with --si
-T::::
show data in tabular format
+There are some options to set unit. See the description of *df* subcommand
+from '-b' option to '-t' option.
+
If conflicting options are passed, the last one takes precedence.
EXIT STATUS
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] btrfs-progs: fi usage, update manpage
2014-12-19 9:56 ` Satoru Takeuchi
@ 2014-12-19 13:36 ` David Sterba
2014-12-21 23:25 ` Satoru Takeuchi
0 siblings, 1 reply; 11+ messages in thread
From: David Sterba @ 2014-12-19 13:36 UTC (permalink / raw)
To: Satoru Takeuchi; +Cc: linux-btrfs
On Fri, Dec 19, 2014 at 06:56:43PM +0900, Satoru Takeuchi wrote:
> +There are some options to set unit. See the description of *df* subcommand
> +from '-b' option to '-t' option.
The unit options exist only for very few subcommands so I found it more
convenient to list all of them near to the command itself rather than
pointing somewhere else.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] btrfs-progs: fi usage, update manpage
2014-12-19 13:36 ` David Sterba
@ 2014-12-21 23:25 ` Satoru Takeuchi
0 siblings, 0 replies; 11+ messages in thread
From: Satoru Takeuchi @ 2014-12-21 23:25 UTC (permalink / raw)
To: dsterba, linux-btrfs
On 2014/12/19 22:36, David Sterba wrote:
> On Fri, Dec 19, 2014 at 06:56:43PM +0900, Satoru Takeuchi wrote:
>> +There are some options to set unit. See the description of *df* subcommand
>> +from '-b' option to '-t' option.
>
> The unit options exist only for very few subcommands so I found it more
> convenient to list all of them near to the command itself rather than
> pointing somewhere else.
>
OK, got it.
Thanks,
Satoru
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-12-21 23:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 14:27 [PATCH 0/6] Btrfs-progs, add units to 'usage' subcommands David Sterba
2014-12-18 14:27 ` [PATCH 1/6] btrfs-progs: fi usage, change option for tabular output to T David Sterba
2014-12-18 14:27 ` [PATCH 2/6] btrfs-progs: fi usage, add switches to set output units David Sterba
2014-12-18 14:27 ` [PATCH 3/6] btrfs-progs: fi usage, update manpage David Sterba
2014-12-19 5:04 ` Satoru Takeuchi
2014-12-19 9:56 ` Satoru Takeuchi
2014-12-19 13:36 ` David Sterba
2014-12-21 23:25 ` Satoru Takeuchi
2014-12-18 14:27 ` [PATCH 4/6] btrfs-progs: dev usage, add switches to set output units David Sterba
2014-12-18 14:27 ` [PATCH 5/6] btrfs-progs: dev usage, update manpage David Sterba
2014-12-18 14:28 ` [PATCH 6/6] btrfs-progs: unify unit mode parameters and variables David Sterba
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).