@@ -120,7 +120,7 @@ show sizes in TiB, or TB with --si.
--sort=[\+/-]<attr>[,[+/-]<attr>]...::::
list qgroups in order of <attr>.
+
-<attr> can be one or more of qgroupid,rfer,excl,max_rfer,max_excl.
+<attr> can be one or more of qgroupid,rfer,excl,max_rfer,max_excl,path.
+
Prefix \'+' means ascending order and \'-' means descending order of <attr>.
If no prefix is given, use ascending order by default.
@@ -284,7 +284,7 @@ static const char * const cmd_qgroup_show_usage[] = {
"-f list all qgroups which impact the given path",
" (excluding ancestral qgroups)",
HELPINFO_UNITS_LONG,
- "--sort=qgroupid,rfer,excl,max_rfer,max_excl",
+ "--sort=qgroupid,rfer,excl,max_rfer,max_excl,path",
" list qgroups sorted by specified items",
" you can use '+' or '-' in front of each item.",
" (+:ascending, -:descending, ascending default)",
@@ -415,12 +415,31 @@ static int comp_entry_with_max_excl(struct btrfs_qgroup *entry1,
return is_descending ? -ret : ret;
}
+static int comp_entry_with_path(struct btrfs_qgroup *entry1,
+ struct btrfs_qgroup *entry2,
+ int is_descending)
+{
+ int ret;
+
+ if (!entry1->path && !entry2->path)
+ ret = 0;
+ else if (!entry1->path)
+ ret = -1;
+ else if (!entry2->path)
+ ret = 1;
+ else
+ ret = strcmp(entry1->path, entry2->path);
+
+ return is_descending ? -ret : ret;
+}
+
static btrfs_qgroup_comp_func all_comp_funcs[] = {
[BTRFS_QGROUP_COMP_QGROUPID] = comp_entry_with_qgroupid,
[BTRFS_QGROUP_COMP_RFER] = comp_entry_with_rfer,
[BTRFS_QGROUP_COMP_EXCL] = comp_entry_with_excl,
[BTRFS_QGROUP_COMP_MAX_RFER] = comp_entry_with_max_rfer,
- [BTRFS_QGROUP_COMP_MAX_EXCL] = comp_entry_with_max_excl
+ [BTRFS_QGROUP_COMP_MAX_EXCL] = comp_entry_with_max_excl,
+ [BTRFS_QGROUP_COMP_PATH] = comp_entry_with_path
};
static char *all_sort_items[] = {
@@ -429,6 +448,7 @@ static char *all_sort_items[] = {
[BTRFS_QGROUP_COMP_EXCL] = "excl",
[BTRFS_QGROUP_COMP_MAX_RFER] = "max_rfer",
[BTRFS_QGROUP_COMP_MAX_EXCL] = "max_excl",
+ [BTRFS_QGROUP_COMP_PATH] = "path",
[BTRFS_QGROUP_COMP_MAX] = NULL,
};
@@ -69,6 +69,7 @@ enum btrfs_qgroup_comp_enum {
BTRFS_QGROUP_COMP_EXCL,
BTRFS_QGROUP_COMP_MAX_RFER,
BTRFS_QGROUP_COMP_MAX_EXCL,
+ BTRFS_QGROUP_COMP_PATH,
BTRFS_QGROUP_COMP_MAX
};
You may want to sort qgroup with the subvol path, now you can use --sort=path. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> --- Changelog: v2: rebase on the qgroup cleanup Documentation/btrfs-qgroup.asciidoc | 2 +- cmds-qgroup.c | 2 +- qgroup.c | 22 +++++++++++++++++++++- qgroup.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-)