mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-17 02:06:51 +00:00
btrfs-progs: fi usage: do not print global block reserve
Global block reserve is inherently part of metadata and should not be listed separately in the output of 'fi usage' in the tabular output. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
c1cbf59ef6
commit
a0c78dca8f
@ -622,8 +622,12 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
|
|||||||
u64 total_unused = 0;
|
u64 total_unused = 0;
|
||||||
struct string_table *matrix = 0;
|
struct string_table *matrix = 0;
|
||||||
int ncols, nrows;
|
int ncols, nrows;
|
||||||
|
int col;
|
||||||
|
int unallocated_col;
|
||||||
|
|
||||||
ncols = sargs->total_spaces + 2;
|
/* data/metadata/system, unallocated */
|
||||||
|
ncols = sargs->total_spaces + 1;
|
||||||
|
/* 2 for header, empty line, devices, ===, total, used */
|
||||||
nrows = 2 + 1 + device_info_count + 1 + 2;
|
nrows = 2 + 1 + device_info_count + 1 + 2;
|
||||||
|
|
||||||
matrix = table_create(ncols, nrows);
|
matrix = table_create(ncols, nrows);
|
||||||
@ -632,8 +636,13 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have to skip the global block reserve everywhere as it's an
|
||||||
|
* artificial blockgroup
|
||||||
|
*/
|
||||||
|
|
||||||
/* header */
|
/* header */
|
||||||
for (i = 0; i < sargs->total_spaces; i++) {
|
for (i = 0, col = 1; i < sargs->total_spaces; i++) {
|
||||||
const char *description;
|
const char *description;
|
||||||
u64 flags = sargs->spaces[i].flags;
|
u64 flags = sargs->spaces[i].flags;
|
||||||
|
|
||||||
@ -642,23 +651,27 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
|
|||||||
|
|
||||||
description = btrfs_group_type_str(flags);
|
description = btrfs_group_type_str(flags);
|
||||||
|
|
||||||
table_printf(matrix, 1+i, 0, "<%s", description);
|
table_printf(matrix, col++, 0, "<%s", description);
|
||||||
}
|
}
|
||||||
|
unallocated_col = col;
|
||||||
|
|
||||||
for (i = 0; i < sargs->total_spaces; i++) {
|
for (i = 0, col = 1; i < sargs->total_spaces; i++) {
|
||||||
const char *r_mode;
|
const char *r_mode;
|
||||||
|
|
||||||
u64 flags = sargs->spaces[i].flags;
|
u64 flags = sargs->spaces[i].flags;
|
||||||
|
|
||||||
|
if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
|
||||||
|
continue;
|
||||||
|
|
||||||
r_mode = btrfs_group_profile_str(flags);
|
r_mode = btrfs_group_profile_str(flags);
|
||||||
|
|
||||||
table_printf(matrix, 1+i, 1, "<%s", r_mode);
|
table_printf(matrix, col++, 1, "<%s", r_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
table_printf(matrix, 1+sargs->total_spaces, 1, "<Unallocated");
|
table_printf(matrix, unallocated_col, 1, "<Unallocated");
|
||||||
|
|
||||||
/* body */
|
/* body */
|
||||||
for (i = 0; i < device_info_count; i++) {
|
for (i = 0; i < device_info_count; i++) {
|
||||||
int k, col;
|
int k;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
u64 total_allocated = 0, unused;
|
u64 total_allocated = 0, unused;
|
||||||
@ -677,6 +690,9 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
|
|||||||
int j;
|
int j;
|
||||||
u64 size = 0;
|
u64 size = 0;
|
||||||
|
|
||||||
|
if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (j = 0 ; j < chunks_info_count ; j++) {
|
for (j = 0 ; j < chunks_info_count ; j++) {
|
||||||
if (chunks_info_ptr[j].type != flags )
|
if (chunks_info_ptr[j].type != flags )
|
||||||
continue;
|
continue;
|
||||||
@ -699,28 +715,42 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
|
|||||||
unused = get_partition_size(device_info_ptr[i].path)
|
unused = get_partition_size(device_info_ptr[i].path)
|
||||||
- total_allocated;
|
- total_allocated;
|
||||||
|
|
||||||
table_printf(matrix, sargs->total_spaces + 1, i + 3,
|
table_printf(matrix, unallocated_col, i + 3,
|
||||||
">%s", pretty_size_mode(unused, unit_mode));
|
">%s", pretty_size_mode(unused, unit_mode));
|
||||||
total_unused += unused;
|
total_unused += unused;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i <= sargs->total_spaces; i++)
|
for (i = 0, col = 1; i < sargs->total_spaces; i++) {
|
||||||
table_printf(matrix, i + 1, device_info_count + 3, "=");
|
if (sargs->spaces[i].flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
table_printf(matrix, col++, device_info_count + 3, "=");
|
||||||
|
}
|
||||||
|
/* One for Unallocated */
|
||||||
|
table_printf(matrix, col, device_info_count + 3, "=");
|
||||||
|
|
||||||
/* footer */
|
/* footer */
|
||||||
table_printf(matrix, 0, device_info_count + 4, "<Total");
|
table_printf(matrix, 0, device_info_count + 4, "<Total");
|
||||||
for (i = 0; i < sargs->total_spaces; i++)
|
for (i = 0, col = 1; i < sargs->total_spaces; i++) {
|
||||||
table_printf(matrix, 1 + i, device_info_count + 4, ">%s",
|
if (sargs->spaces[i].flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
|
||||||
pretty_size_mode(sargs->spaces[i].total_bytes, unit_mode));
|
continue;
|
||||||
|
|
||||||
table_printf(matrix, sargs->total_spaces + 1, device_info_count + 4,
|
table_printf(matrix, col++, device_info_count + 4, ">%s",
|
||||||
|
pretty_size_mode(sargs->spaces[i].total_bytes, unit_mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
table_printf(matrix, unallocated_col, device_info_count + 4,
|
||||||
">%s", pretty_size_mode(total_unused, unit_mode));
|
">%s", pretty_size_mode(total_unused, unit_mode));
|
||||||
|
|
||||||
table_printf(matrix, 0, device_info_count + 5, "<Used");
|
table_printf(matrix, 0, device_info_count + 5, "<Used");
|
||||||
for (i = 0; i < sargs->total_spaces; i++)
|
for (i = 0, col = 1; i < sargs->total_spaces; i++) {
|
||||||
table_printf(matrix, 1 + i, device_info_count+5, ">%s",
|
if (sargs->spaces[i].flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
table_printf(matrix, col++, device_info_count+5, ">%s",
|
||||||
pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode));
|
pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode));
|
||||||
|
}
|
||||||
|
|
||||||
table_dump(matrix);
|
table_dump(matrix);
|
||||||
table_free(matrix);
|
table_free(matrix);
|
||||||
|
Loading…
Reference in New Issue
Block a user