From patchwork Wed Jan 18 05:21:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9522617 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 EDE83601B7 for ; Wed, 18 Jan 2017 05:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD53F28599 for ; Wed, 18 Jan 2017 05:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF539285AD; Wed, 18 Jan 2017 05:26:42 +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 5808428599 for ; Wed, 18 Jan 2017 05:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751159AbdARF0h (ORCPT ); Wed, 18 Jan 2017 00:26:37 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:42488 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750712AbdARF0g (ORCPT ); Wed, 18 Jan 2017 00:26:36 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="14865957" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Jan 2017 13:21:12 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id B539B47B0CB2 for ; Wed, 18 Jan 2017 13:21:09 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 18 Jan 2017 13:21:09 +0800 From: Qu Wenruo To: Subject: [PATCH] btrfs-progs: lowmem-check: Fix false alert on dropped leaf Date: Wed, 18 Jan 2017 13:21:07 +0800 Message-ID: <20170118052107.7394-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: B539B47B0CB2.AFC1B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.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 For btrfs-progs test case 021-partially-dropped-snapshot-case, if the first leaf is already dropped, btrfs check low-memory mode will report false alert: checking fs roots checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000 checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000 checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000 checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000 This is caused by we are calling check_fs_first_inode() function, unlike the rest part of check_fs_root_v2(), it doesn't have enough check on dropping progress, and caused the false alert. Fix it by checking dropping progress before searching slot. Signed-off-by: Qu Wenruo --- cmds-check.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 1dba2985..25247fd9 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -4939,11 +4939,18 @@ static int check_fs_first_inode(struct btrfs_root *root, unsigned int ext_ref) int err = 0; int ret; - btrfs_init_path(&path); key.objectid = BTRFS_FIRST_FREE_OBJECTID; key.type = BTRFS_INODE_ITEM_KEY; key.offset = 0; + /* For root being dropped, we don't need to check first inode */ + if (btrfs_root_refs(&root->root_item) == 0 && + btrfs_disk_key_objectid(&root->root_item.drop_progress) >= + key.objectid) + return 0; + + btrfs_init_path(&path); + ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) goto out;