btrfs-progs: tree-stats: unify setting raw/bytes options

The long options now allow to pass the unit mode in the usual way, drop
the local variable for raw byte values.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-07-17 04:07:22 +02:00
parent 0eb8a65844
commit 44e190d25e
1 changed files with 3 additions and 4 deletions

View File

@ -40,7 +40,6 @@
#include "cmds/commands.h" #include "cmds/commands.h"
static int verbose = 0; static int verbose = 0;
static bool no_pretty = false;
struct seek { struct seek {
u64 distance; u64 distance;
@ -366,7 +365,7 @@ out_print:
stat.total_clusters = 1; stat.total_clusters = 1;
} }
if (no_pretty || size_fail) { if (unit_mode == UNITS_RAW || size_fail) {
pr_verbose(LOG_DEFAULT, "\tTotal size: %llu\n", stat.total_bytes); pr_verbose(LOG_DEFAULT, "\tTotal size: %llu\n", stat.total_bytes);
pr_verbose(LOG_DEFAULT, "\t\tInline data: %llu\n", stat.total_inline); pr_verbose(LOG_DEFAULT, "\t\tInline data: %llu\n", stat.total_inline);
pr_verbose(LOG_DEFAULT, "\tTotal seeks: %llu\n", stat.total_seeks); pr_verbose(LOG_DEFAULT, "\tTotal seeks: %llu\n", stat.total_seeks);
@ -451,7 +450,7 @@ static int cmd_inspect_tree_stats(const struct cmd_struct *cmd,
{ {
struct btrfs_key key = { .type = BTRFS_ROOT_ITEM_KEY }; struct btrfs_key key = { .type = BTRFS_ROOT_ITEM_KEY };
struct btrfs_root *root; struct btrfs_root *root;
unsigned int unit_mode; unsigned int unit_mode = UNITS_DEFAULT;
int opt; int opt;
int ret = 0; int ret = 0;
u64 tree_id = 0; u64 tree_id = 0;
@ -465,7 +464,7 @@ static int cmd_inspect_tree_stats(const struct cmd_struct *cmd,
verbose++; verbose++;
break; break;
case 'b': case 'b':
no_pretty = true; unit_mode = UNITS_RAW;
break; break;
case 't': case 't':
tree_id = arg_strtou64(optarg); tree_id = arg_strtou64(optarg);