From patchwork Wed Nov 22 09:03:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10069943 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 CEF0960375 for ; Wed, 22 Nov 2017 09:04:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3D7029A4F for ; Wed, 22 Nov 2017 09:04:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8FDA29BA6; Wed, 22 Nov 2017 09:04:27 +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 65D9629A4F for ; Wed, 22 Nov 2017 09:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751916AbdKVJEV (ORCPT ); Wed, 22 Nov 2017 04:04:21 -0500 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:48160 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbdKVJER (ORCPT ); Wed, 22 Nov 2017 04:04:17 -0500 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); Wed, 22 Nov 2017 02:04:02 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 08/11] btrfs-progs: lowmem check: Fix false alerts for image with shared block ref only backref Date: Wed, 22 Nov 2017 17:03:22 +0800 Message-Id: <20171122090325.29458-9-wqu@suse.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171122090325.29458-1-wqu@suse.com> References: <20171122090325.29458-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 [BUG] For image with shared block ref only metadata item like: ------ item 66 key (21573632 METADATA_ITEM 0) itemoff 3971 itemsize 24 refs 66 gen 9 flags TREE_BLOCK|FULL_BACKREF tree block skinny level 0 item 0 key (21573632 SHARED_BLOCK_REF 21676032) itemoff 3995 itemsize 0 shared block backref item 1 key (21573632 SHARED_BLOCK_REF 21921792) itemoff 3995 itemsize 0 shared block backref item 2 key (21573632 SHARED_BLOCK_REF 21995520) itemoff 3995 itemsize 0 shared block backref item 3 key (21573632 SHARED_BLOCK_REF 22077440) itemoff 3995 itemsize 0 shared block backref ... ------ Lowmem mode check will report false alerts like: ------ ERROR: extent[21573632 4096] backref lost (owner: 256, level: 0) ------ [CAUSE] In fact, the false alerts is not even from extent tree verfication, but a fs tree helper which is designed to make sure there is some tree block referring to the fs tree block. The idea is to find inlined tree backref then keyed TREE_BLOCK_REF_KEY. However it missed SHARED_BLOCK_REF_KEY, and caused such false alert. [FIX] Add SHARED_BLOCK_REF_KEY to make the warning shut up. Signed-off-by: Qu Wenruo --- cmds-check.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index 7eb08b6cb962..791fab6b3e6a 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -11850,6 +11850,30 @@ static int check_tree_block_ref(struct btrfs_root *root, if (!ret) found_ref = 1; } + /* + * Finally check SHARED BLOCK REF, any found will be good + * Here we're not doing comprehensive extent backref checking, + * only need to ensure there is some extent referring to this + * tree block. + */ + if (!found_ref) { + btrfs_release_path(&path); + key.objectid = bytenr; + key.type = BTRFS_SHARED_BLOCK_REF_KEY; + key.offset = (u64)-1; + + ret = btrfs_search_slot(NULL, extent_root, &key, &path, 0, 0); + if (ret < 0) { + err |= BACKREF_MISSING; + goto out; + } + ret = btrfs_previous_extent_item(extent_root, &path, bytenr); + if (ret) { + err |= BACKREF_MISSING; + goto out; + } + found_ref = 1; + } if (!found_ref) err |= BACKREF_MISSING; out: