summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-01-03 18:26:43 +0100
committerDavid Sterba <dsterba@suse.com>2017-01-25 09:47:35 +0100
commitf49fb67a2552c14e4194b97ce34d3fbf5389a1ce (patch)
tree39f19935bbb53d21cd8c86c185bfd5bc82d19515
parent72ae343f772120ec52533e071e8bea58fd76ad3a (diff)
btrfs-progs: enable negative numbers for unallocated device space
The unallocated space is not calculated correctly when a device deltion/replace is in progress. This appears as huge number, EiB-sized. It's really a negative number, because we don't have entire information available and mixing numbers that do and don't take the deleted device size into account. We have to query search ioctl to retrieve the missing information, also this requires root access for the ioctl, so we still need a workaround for non-root case. Here the negative numbers seem to be a bit more practical than EiB numbers. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--cmds-fi-usage.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c
index 8764fef6..88e346ad 100644
--- a/cmds-fi-usage.c
+++ b/cmds-fi-usage.c
@@ -471,7 +471,7 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
printf(" Device allocated:\t\t%*s\n", width,
pretty_size_mode(r_total_chunks, unit_mode));
printf(" Device unallocated:\t\t%*s\n", width,
- pretty_size_mode(r_total_unused, unit_mode));
+ pretty_size_mode(r_total_unused, unit_mode | UNITS_NEGATIVE));
printf(" Device missing:\t\t%*s\n", width,
pretty_size_mode(r_total_missing, unit_mode));
printf(" Used:\t\t\t%*s\n", width,
@@ -736,8 +736,8 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
unused = get_partition_size(device_info_ptr[i].path)
- total_allocated;
- table_printf(matrix, unallocated_col, vhdr_skip + i,
- ">%s", pretty_size_mode(unused, unit_mode));
+ table_printf(matrix, unallocated_col, vhdr_skip + i, ">%s",
+ pretty_size_mode(unused, unit_mode | UNITS_NEGATIVE));
total_unused += unused;
}
@@ -771,7 +771,8 @@ static void _cmd_filesystem_usage_tabular(unsigned unit_mode,
}
table_printf(matrix, unallocated_col, vhdr_skip + device_info_count + 1,
- ">%s", pretty_size_mode(total_unused, unit_mode));
+ ">%s",
+ pretty_size_mode(total_unused, unit_mode | UNITS_NEGATIVE));
table_printf(matrix, 1, vhdr_skip + device_info_count + 2, "<Used");
for (i = 0, col = spaceinfos_col; i < sargs->total_spaces; i++) {
@@ -884,7 +885,7 @@ static void _cmd_filesystem_usage_linear(unsigned unit_mode,
printf("Unallocated:\n");
print_unused(info_ptr, info_count, device_info_ptr, device_info_count,
- unit_mode);
+ unit_mode | UNITS_NEGATIVE);
}
static int print_filesystem_usage_by_chunk(int fd,
@@ -1027,7 +1028,8 @@ void print_device_chunks(int fd, struct device_info *devinfo,
}
printf(" Unallocated: %*s%10s\n",
(int)(20 - strlen("Unallocated")), "",
- pretty_size_mode(devinfo->size - allocated, unit_mode));
+ pretty_size_mode(devinfo->size - allocated,
+ unit_mode | UNITS_NEGATIVE));
}
void print_device_sizes(int fd, struct device_info *devinfo, unsigned unit_mode)