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>
This commit is contained in:
parent
72ae343f77
commit
f49fb67a25
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue