From patchwork Thu Apr 24 03:19:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 4045591 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 234FD9F387 for ; Thu, 24 Apr 2014 03:22:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CEA9201B4 for ; Thu, 24 Apr 2014 03:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9ABC420179 for ; Thu, 24 Apr 2014 03:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751968AbaDXDWc (ORCPT ); Wed, 23 Apr 2014 23:22:32 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:21762 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751792AbaDXDWb (ORCPT ); Wed, 23 Apr 2014 23:22:31 -0400 X-IronPort-AV: E=Sophos;i="4.97,916,1389715200"; d="scan'208";a="29658031" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 24 Apr 2014 11:19:48 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s3O3MF3S005672 for ; Thu, 24 Apr 2014 11:22:15 +0800 Received: from wangs.fnst.cn.fujitsu.com (10.167.226.104) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Thu, 24 Apr 2014 11:22:15 +0800 From: Wang Shilong To: Subject: [PATCH 2/3] Btrfs-progs: fsck: avoid pinning same block several times Date: Thu, 24 Apr 2014 11:19:17 +0800 Message-ID: <1398309558-29509-2-git-send-email-wangsl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1398309558-29509-1-git-send-email-wangsl.fnst@cn.fujitsu.com> References: <1398309558-29509-1-git-send-email-wangsl.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.104] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This can not only give some speedups but also avoid forever loop with a really broken filesystem. Signed-off-by: Wang Shilong --- cmds-check.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index 15806a4..e6fb380 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -6189,6 +6189,15 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info, int ret; int i; + /* + * If we have pinned this block before, don't pin it again. + * This can not only avoid forever loop with broken filesystem + * but also give us some speedups. + */ + if (test_range_bit(&fs_info->pinned_extents, eb->start, + eb->start + eb->len - 1, EXTENT_DIRTY, 0)) + return 0; + btrfs_pin_extent(fs_info, eb->start, eb->len); leafsize = btrfs_super_leafsize(fs_info->super_copy);