From patchwork Thu Aug 25 05:21:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoguang Wang X-Patchwork-Id: 9298697 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 837E360459 for ; Thu, 25 Aug 2016 05:25:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BD3F2919C for ; Thu, 25 Aug 2016 05:25:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EBF5291C8; Thu, 25 Aug 2016 05:25:25 +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 D39742919C for ; Thu, 25 Aug 2016 05:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757393AbcHYFZN (ORCPT ); Thu, 25 Aug 2016 01:25:13 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:31551 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1757363AbcHYFZM (ORCPT ); Thu, 25 Aug 2016 01:25:12 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="808166" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 25 Aug 2016 13:25:04 +0800 Received: from localhost.localdomain (unknown [10.167.226.107]) by cn.fujitsu.com (Postfix) with ESMTP id 150F14056403; Thu, 25 Aug 2016 13:25:00 +0800 (CST) From: Wang Xiaoguang To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 2/3] btrfs-progs: check: make low memory mode support partially dropped snapshots Date: Thu, 25 Aug 2016 13:21:00 +0800 Message-Id: <20160825052101.25864-2-wangxg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160825052101.25864-1-wangxg.fnst@cn.fujitsu.com> References: <20160825052101.25864-1-wangxg.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 150F14056403.AC339 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wangxg.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 Signed-off-by: Wang Xiaoguang --- cmds-check.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 1cd0421..bce586c 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -9016,9 +9016,10 @@ static int check_tree_block_backref(struct btrfs_fs_info *fs_info, u64 root_id, free_extent_buffer(eb); btrfs_init_path(&path); + path.lowest_level = level; /* Search with the first key, to ensure we can reach it */ ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); - if (ret) { + if (ret < 0) { err |= REFERENCER_MISSING; goto release_out; } @@ -9901,6 +9902,8 @@ static int traverse_tree_block(struct btrfs_root *root, struct extent_buffer *node) { struct extent_buffer *eb; + struct btrfs_key key; + struct btrfs_key drop_key; int level; u64 nr; int i; @@ -9946,6 +9949,7 @@ static int traverse_tree_block(struct btrfs_root *root, } nr = btrfs_header_nritems(node); + btrfs_disk_key_to_cpu(&drop_key, &root->root_item.drop_progress); btree_space_waste += (BTRFS_NODEPTRS_PER_BLOCK(root) - nr) * sizeof(struct btrfs_key_ptr); @@ -9953,6 +9957,11 @@ static int traverse_tree_block(struct btrfs_root *root, for (i = 0; i < nr; i++) { u64 blocknr = btrfs_node_blockptr(node, i); + btrfs_node_key_to_cpu(node, &key, i); + if (level == root->root_item.drop_level && + is_dropped_key(&key, &drop_key)) + continue; + /* * As a btrfs tree has most 8 levels (0..7), so it's quite safe * to call the function itself.