From patchwork Fri Oct 27 07:29:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10029299 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 892C760249 for ; Fri, 27 Oct 2017 07:30:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA2928E39 for ; Fri, 27 Oct 2017 07:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D33128E3C; Fri, 27 Oct 2017 07:30:03 +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=-6.9 required=2.0 tests=BAYES_00,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 3528F28E39 for ; Fri, 27 Oct 2017 07:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752112AbdJ0HaA (ORCPT ); Fri, 27 Oct 2017 03:30:00 -0400 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:53776 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751176AbdJ0H36 (ORCPT ); Fri, 27 Oct 2017 03:29:58 -0400 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Fri, 27 Oct 2017 01:29:43 -0600 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 4/8] btrfs-progs: qgroup-verify: Allow repair_qgroups function to do silent repair Date: Fri, 27 Oct 2017 15:29:32 +0800 Message-Id: <20171027072936.4697-5-wqu@suse.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171027072936.4697-1-wqu@suse.com> References: <20171027072936.4697-1-wqu@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 Allow repair_qgroups() to do silent repair, so it can acts as offline qgroup rescan. This provides the basis for later mkfs quota support. Signed-off-by: Qu Wenruo --- cmds-check.c | 2 +- qgroup-verify.c | 19 +++++++++++-------- qgroup-verify.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 5c822b848608..955049b95f3c 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -13360,7 +13360,7 @@ int cmd_check(int argc, char **argv) goto out; } report_qgroups(0); - ret = repair_qgroups(info, &qgroups_repaired); + ret = repair_qgroups(info, &qgroups_repaired, false); err |= !!ret; if (err) { error("failed to repair quota groups"); diff --git a/qgroup-verify.c b/qgroup-verify.c index 67bd8b96ddd3..bb77eac139aa 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -1498,7 +1498,7 @@ out: } static int repair_qgroup_info(struct btrfs_fs_info *info, - struct qgroup_count *count) + struct qgroup_count *count, bool silent) { int ret; struct btrfs_root *root = info->quota_root; @@ -1507,8 +1507,10 @@ static int repair_qgroup_info(struct btrfs_fs_info *info, struct btrfs_qgroup_info_item *info_item; struct btrfs_key key; - printf("Repair qgroup %llu/%llu\n", btrfs_qgroup_level(count->qgroupid), - btrfs_qgroup_subvid(count->qgroupid)); + if (!silent) + printf("Repair qgroup %llu/%llu\n", + btrfs_qgroup_level(count->qgroupid), + btrfs_qgroup_subvid(count->qgroupid)); trans = btrfs_start_transaction(root, 1); if (IS_ERR(trans)) @@ -1553,7 +1555,7 @@ out: return ret; } -static int repair_qgroup_status(struct btrfs_fs_info *info) +static int repair_qgroup_status(struct btrfs_fs_info *info, bool silent) { int ret; struct btrfs_root *root = info->quota_root; @@ -1562,7 +1564,8 @@ static int repair_qgroup_status(struct btrfs_fs_info *info) struct btrfs_key key; struct btrfs_qgroup_status_item *status_item; - printf("Repair qgroup status item\n"); + if (!silent) + printf("Repair qgroup status item\n"); trans = btrfs_start_transaction(root, 1); if (IS_ERR(trans)) @@ -1599,7 +1602,7 @@ out: return ret; } -int repair_qgroups(struct btrfs_fs_info *info, int *repaired) +int repair_qgroups(struct btrfs_fs_info *info, int *repaired, bool silent) { int ret = 0; struct qgroup_count *count, *tmpcount; @@ -1610,7 +1613,7 @@ int repair_qgroups(struct btrfs_fs_info *info, int *repaired) return 0; list_for_each_entry_safe(count, tmpcount, &bad_qgroups, bad_list) { - ret = repair_qgroup_info(info, count); + ret = repair_qgroup_info(info, count, silent); if (ret) { goto out; } @@ -1626,7 +1629,7 @@ int repair_qgroups(struct btrfs_fs_info *info, int *repaired) * mount. */ if (*repaired || counts.qgroup_inconsist || counts.rescan_running) { - ret = repair_qgroup_status(info); + ret = repair_qgroup_status(info, silent); if (ret) goto out; diff --git a/qgroup-verify.h b/qgroup-verify.h index d7d83a46ed5a..7e5697024f31 100644 --- a/qgroup-verify.h +++ b/qgroup-verify.h @@ -24,7 +24,7 @@ int qgroup_verify_all(struct btrfs_fs_info *info); void report_qgroups(int all); -int repair_qgroups(struct btrfs_fs_info *info, int *repaired); +int repair_qgroups(struct btrfs_fs_info *info, int *repaired, bool silent); int print_extent_state(struct btrfs_fs_info *info, u64 subvol);