From patchwork Tue Jul 8 20:41:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Fasheh X-Patchwork-Id: 4510041 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B2BC9F1C4 for ; Tue, 8 Jul 2014 20:42:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7B9C20211 for ; Tue, 8 Jul 2014 20:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C201D201EF for ; Tue, 8 Jul 2014 20:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754407AbaGHUl7 (ORCPT ); Tue, 8 Jul 2014 16:41:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:59377 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754392AbaGHUl6 (ORCPT ); Tue, 8 Jul 2014 16:41:58 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2ACAAABE9; Tue, 8 Jul 2014 20:41:57 +0000 (UTC) Date: Tue, 8 Jul 2014 13:41:57 -0700 From: Mark Fasheh To: linux-btrfs@vger.kernel.org Cc: Josef Bacik , Chris Mason , David Sterba Subject: [PATCH] btrfs-progs: ignore orphaned qgroups by default Message-ID: <20140708204157.GZ5484@wotan.suse.de> Reply-To: Mark Fasheh MIME-Version: 1.0 Content-Disposition: inline Organization: SUSE Labs User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP qgroup items are not deleted by btrfs when the underlying subvolume goes away. As a result, btrfsck will print those as inconsistent. This can clutter up the printout so we ignore them by default. They are still printed if a full report (via --qgroup-report) is requested. This patch and the ones it depends on (to do qgroup verification) can be found at: https://github.com/markfasheh/btrfs-progs-patches/tree/qgroup-verify Signed-off-by: Mark Fasheh --- qgroup-verify.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qgroup-verify.c b/qgroup-verify.c index 81a1651..2e1716d 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -38,6 +38,7 @@ static void add_bytes(u64 root_objectid, u64 num_bytes, int exclusive); struct qgroup_count { u64 qgroupid; + int subvol_exists; struct btrfs_disk_key key; struct btrfs_qgroup_info_item diskinfo; @@ -697,8 +698,10 @@ static int load_quota_info(struct btrfs_fs_info *info) { int ret; struct btrfs_root *root = info->quota_root; + struct btrfs_root *tmproot; struct btrfs_path path; struct btrfs_key key; + struct btrfs_key root_key; struct btrfs_disk_key disk_key; struct extent_buffer *leaf; struct btrfs_qgroup_info_item *item; @@ -745,6 +748,15 @@ static int load_quota_info(struct btrfs_fs_info *info) fprintf(stderr, "ERROR: out of memory\n"); goto out; } + + root_key.objectid = key.offset; + root_key.type = BTRFS_ROOT_ITEM_KEY; + root_key.offset = (u64)-1; + tmproot = btrfs_read_fs_root_no_cache(info, &root_key); + if (tmproot && !IS_ERR(tmproot)) { + count->subvol_exists = 1; + free(tmproot); + } } ret = btrfs_next_leaf(root, &path); @@ -1008,7 +1020,7 @@ static void print_qgroup_difference(struct qgroup_count *count, int verbose) is_different = excl_diff || ref_diff; - if (verbose || is_different) { + if (verbose || (is_different && count->subvol_exists)) { printf("Counts for qgroup id: %llu %s\n", (unsigned long long)count->qgroupid, is_different ? "are different" : "");