From: Jeff Mahoney <je...@suse.com>

When qgroup items get left behind, we still print them in
'btrfs qgroup show' even though there is nothing to show.  Since we
now look up the pathname and that means we look up the subvolume,
we can filter out first-level qgroups that correspond to roots
that have been removed.  Specifying -v will still show them.

Signed-off-by: Jeff Mahoney <je...@suse.com>
---
 qgroup.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/qgroup.c b/qgroup.c
index 647bc2f3..08e78887 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -313,6 +313,13 @@ static void print_qgroup_column(struct btrfs_qgroup 
*qgroup,
        }
 }
 
+static bool qgroup_target_exists(const struct btrfs_qgroup *qgroup)
+{
+       if (btrfs_qgroup_level(qgroup->qgroupid) > 0)
+               return true;
+       return qgroup->pathname != NULL;
+}
+
 static void print_single_qgroup_table(struct btrfs_qgroup *qgroup, bool 
verbose)
 {
        int i;
@@ -1369,7 +1376,8 @@ static void print_all_qgroups(struct qgroup_lookup 
*qgroup_lookup, bool verbose)
        n = rb_first(&qgroup_lookup->root);
        while (n) {
                entry = rb_entry(n, struct btrfs_qgroup, sort_node);
-               print_single_qgroup_table(entry, verbose);
+               if (qgroup_target_exists(entry) || verbose)
+                       print_single_qgroup_table(entry, verbose);
                n = rb_next(n);
        }
 }
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to