From patchwork Wed May 16 21:38:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 10404929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 098AF601C8 for ; Wed, 16 May 2018 21:39:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EED34286E6 for ; Wed, 16 May 2018 21:39:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3C9028755; Wed, 16 May 2018 21:39:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97D07286E6 for ; Wed, 16 May 2018 21:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752080AbeEPVjb (ORCPT ); Wed, 16 May 2018 17:39:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:52662 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbeEPVjF (ORCPT ); Wed, 16 May 2018 17:39:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EB457ADA7 for ; Wed, 16 May 2018 21:39:03 +0000 (UTC) Received: from starscream.home.jeffm.io (starscream-1.home.jeffm.io [IPv6:2001:559:c0d4::1fe]) by mail.home.jeffm.io (Postfix) with ESMTPS id 2349F81AD3F6; Wed, 16 May 2018 17:38:31 -0400 (EDT) Received: by starscream.home.jeffm.io (Postfix, from userid 1000) id DAB82816BA; Wed, 16 May 2018 17:39:00 -0400 (EDT) From: jeffm@suse.com To: linux-btrfs@vger.kernel.org Cc: Jeff Mahoney Subject: [PATCH 18/18] btrfs-progs: qgroups: don't print dead qgroups Date: Wed, 16 May 2018 17:38:51 -0400 Message-Id: <20180516213851.10196-19-jeffm@suse.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180516213851.10196-1-jeffm@suse.com> References: <20180516213851.10196-1-jeffm@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Mahoney 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 --- 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); } }