btrfs-progs: fi usage: list multiple profiles type
Update the summary of 'fi usage' where the multiple profiles will be listed by type, like: Multiple profiles: yes (data, metadata) The string is returned from btrfs_test_for_multiple_profiles so the callers don't have to assemble it together from the other profile strings. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
da7da3f661
commit
3f92fe88c3
|
@ -309,6 +309,7 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
|||
const char *path, unsigned unit_mode)
|
||||
{
|
||||
struct btrfs_ioctl_space_args *sargs = NULL;
|
||||
char *tmp;
|
||||
int i;
|
||||
int ret = 0;
|
||||
int width = 10; /* default 10 for human units */
|
||||
|
@ -492,11 +493,12 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
|||
printf(" Global reserve:\t\t%*s\t(used: %s)\n", width,
|
||||
pretty_size_mode(l_global_reserve, unit_mode),
|
||||
pretty_size_mode(l_global_reserve_used, unit_mode));
|
||||
if (btrfs_test_for_multiple_profiles_by_fd(fd) > 0)
|
||||
printf(" Multiple profiles:\t\t%*s\n", width, "YES");
|
||||
tmp = btrfs_test_for_multiple_profiles(fd);
|
||||
if (tmp[0])
|
||||
printf(" Multiple profiles:\t\t%*s\t(%s)\n", width, "yes", tmp);
|
||||
else
|
||||
printf(" Multiple profiles:\t\t%*s\n", width, "no");
|
||||
|
||||
free(tmp);
|
||||
|
||||
exit:
|
||||
|
||||
|
|
|
@ -1755,7 +1755,8 @@ static char *sprint_profiles(u64 profiles)
|
|||
}
|
||||
|
||||
static int btrfs_get_string_for_multiple_profiles(int fd, char **data_ret,
|
||||
char **metadata_ret, char **mixed_ret, char **system_ret)
|
||||
char **metadata_ret, char **mixed_ret, char **system_ret,
|
||||
char **types_ret)
|
||||
{
|
||||
int ret;
|
||||
int i;
|
||||
|
@ -1798,22 +1799,49 @@ static int btrfs_get_string_for_multiple_profiles(int fd, char **data_ret,
|
|||
*mixed_ret = sprint_profiles(mixed_profiles);
|
||||
*system_ret = sprint_profiles(system_profiles);
|
||||
|
||||
if (types_ret) {
|
||||
*types_ret = calloc(1, 64);
|
||||
if (!*types_ret)
|
||||
goto out;
|
||||
if (*data_ret)
|
||||
strcat(*types_ret, "data");
|
||||
if (*metadata_ret) {
|
||||
if ((*types_ret)[0])
|
||||
strcat(*types_ret, ", ");
|
||||
strcat(*types_ret, "metadata");
|
||||
}
|
||||
if (*mixed_ret) {
|
||||
if ((*types_ret)[0])
|
||||
strcat(*types_ret, ", ");
|
||||
strcat(*types_ret, "data+metadata");
|
||||
}
|
||||
if (*system_ret) {
|
||||
if ((*types_ret)[0])
|
||||
strcat(*types_ret, ", ");
|
||||
strcat(*types_ret, "system");
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return *data_ret || *metadata_ret || *mixed_ret || *system_ret;
|
||||
}
|
||||
|
||||
int btrfs_test_for_multiple_profiles_by_fd(int fd)
|
||||
/*
|
||||
* Return string containing coma separated list of block group types that
|
||||
* contain multiple profiles. The return value must be freed by the caller.
|
||||
*/
|
||||
char *btrfs_test_for_multiple_profiles(int fd)
|
||||
{
|
||||
char *data, *metadata, *system, *mixed;
|
||||
int ret;
|
||||
char *data, *metadata, *system, *mixed, *types;
|
||||
|
||||
ret = btrfs_get_string_for_multiple_profiles(fd, &data, &metadata,
|
||||
&mixed, &system);
|
||||
btrfs_get_string_for_multiple_profiles(fd, &data, &metadata, &mixed,
|
||||
&system, &types);
|
||||
free(data);
|
||||
free(metadata);
|
||||
free(mixed);
|
||||
free(system);
|
||||
|
||||
return ret;
|
||||
return types;
|
||||
}
|
||||
|
||||
int btrfs_warn_multiple_profiles(int fd)
|
||||
|
@ -1822,7 +1850,7 @@ int btrfs_warn_multiple_profiles(int fd)
|
|||
char *data_prof, *mixed_prof, *metadata_prof, *system_prof;
|
||||
|
||||
ret = btrfs_get_string_for_multiple_profiles(fd, &data_prof,
|
||||
&metadata_prof, &mixed_prof, &system_prof);
|
||||
&metadata_prof, &mixed_prof, &system_prof, NULL);
|
||||
|
||||
if (ret != 1)
|
||||
return ret;
|
||||
|
|
|
@ -137,7 +137,7 @@ u64 rand_u64(void);
|
|||
unsigned int rand_range(unsigned int upper);
|
||||
void init_rand_seed(u64 seed);
|
||||
|
||||
int btrfs_test_for_multiple_profiles_by_fd(int fd);
|
||||
char *btrfs_test_for_multiple_profiles(int fd);
|
||||
int btrfs_warn_multiple_profiles(int fd);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue