From patchwork Wed Sep 12 19:20:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 10597391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1F1614DB for ; Wed, 12 Sep 2018 11:21:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF63329BB9 for ; Wed, 12 Sep 2018 11:21:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDB2B29BBF; Wed, 12 Sep 2018 11:21:26 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 6C6F929BBD for ; Wed, 12 Sep 2018 11:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726932AbeILQZa (ORCPT ); Wed, 12 Sep 2018 12:25:30 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41017 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeILQZa (ORCPT ); Wed, 12 Sep 2018 12:25:30 -0400 Received: by mail-pl1-f193.google.com with SMTP id b12-v6so828449plr.8 for ; Wed, 12 Sep 2018 04:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ob6HC2Qr+/xkJ3W9+DCgrFS7bnUvOSciHzabJpvL+xQ=; b=JR/NaIpPJ+GRE6dh8ZryJSJ+2AUMVutc2fiJv1laJGGp4UT11ACxJmkchoV5lF0FvW 5203aA4zTNg6TthPlG1iqzpYqiTQ72FrJdOZzLgMQIeOOOY1MhGk8kOFROgDstXI7OOO InJa0kAdOym/7rasgc0Bcqgo5c56n7ETj8Mp1bBUxmviJJJaZGCq7IGPjq0UENEbkAOv DkdK1laJYC/+6PrSRpJJtajodvt+2JgiD+9bxZa33xMklk4M01gz4Jm/R+rAtpxjBJPb FG8sqCJSHGd+xaset1T5rE2e/UKOKlaQy8xAY5xxocCQV0dloJh2hqSgL0Ql3bkQ9Sw3 qmNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ob6HC2Qr+/xkJ3W9+DCgrFS7bnUvOSciHzabJpvL+xQ=; b=d2QSX49hxQ159wEHo1olnAnSnBA2zzyQap/LvLLqr++hUHiRSM31kgCzExpIJElvH1 ZZS0kEVseqzxcQyF0+FPnyufKXEEbF5VWG9wljw0OrQVd4GSpp3WGUC1HEOItDe8vL+/ tl6D/aXYm4T+96doFb0uWDPHO+eJSg4LlOf4lVJ1CxqdoF+1Zvgd3m/2lon6qavct4Xb +xGXM/uIHx6H6Aa9r+6IaIlrmHUDcoBlaG8goDPpHLKR8iRVgQZaiSiK/dNhJ2XV5Cww fbOTpU7GezEF67WMilByCE2h1Le8fosgqdAVMCMB7gqvChb8/5ORnBWi8g8Odc6HI2VM HyNw== X-Gm-Message-State: APzg51ARuL14CL1LoqmLeDifvNzLMQT/beNtGg39k6WymcW97qEdQrTG G95VdMYLHquf7H0eL/apfJiacJZ1 X-Google-Smtp-Source: ANB0VdaSgsM1eTiQ0gMMZFw6EyV+64yu5hliwm6KDrr/jam/hVsD3/J7Hth6u64RgJw8bJRxyzbQ+g== X-Received: by 2002:a17:902:b70f:: with SMTP id d15-v6mr1701723pls.53.1536751284375; Wed, 12 Sep 2018 04:21:24 -0700 (PDT) Received: from cat-arch.lan (li1862-137.members.linode.com. [172.105.208.137]) by smtp.gmail.com with ESMTPSA id h12-v6sm1267826pfo.135.2018.09.12.04.21.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 04:21:23 -0700 (PDT) From: damenly.su@gmail.com X-Google-Original-From: suy.fnst@cn.fujitsu.com To: linux-btrfs@vger.kernel.org Cc: suy.fnst@cn.fujitsu.com Subject: [PATCH 5/6] btrfs-progs: lowmem: continue to check item in last slot while checking inodes Date: Wed, 12 Sep 2018 19:20:42 +0000 Message-Id: <20180912192046.5861-6-suy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180912192046.5861-1-suy.fnst@cn.fujitsu.com> References: <20180912192046.5861-1-suy.fnst@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 From: Su Yue After call of check_inode_item(), path may point to the last unchecked slot of the leaf. The outer walk_up_tree() always treats the position as checked item then skips to next item. If the last item was an inode item, yes, it was unchecked. Then walk_up_tree() will think the leaf is checked and walk up to upper node, process_one_leaf() in walk_down_tree() would skip to check next inode item. Which means, the inode item won't be checked. Solution: After check_inode_item returns, if found path point to the last item of a leaf, decrease path slot manually, so walk_up_tree() will stay on the leaf. Fixes: 5e2dc770471b ("btrfs-progs: check: skip shared node or leaf check for low_memory mode") Signed-off-by: Su Yue --- check/mode-lowmem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 8fc9edab1d66..b6b33786d02b 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -2612,6 +2612,18 @@ again: if (cur->start == cur_bytenr) goto again; + /* + * path may point at the last item(a inode item maybe) in a leaf. + * Without below lines, walk_up_tree() will skip the item which + * means all items related to the inode will never be checked. + * Decrease the slot manually, walk_up_tree won't skip to next node + * if it occurs. + */ + if (path->slots[0] + 1 >= btrfs_header_nritems(path->nodes[0])) { + if (path->slots[0]) + path->slots[0]--; + } + /* * we have switched to another leaf, above nodes may * have changed, here walk down the path, if a node