From patchwork Fri Dec 13 09:16:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 3339241 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 1D81E9F380 for ; Fri, 13 Dec 2013 09:17:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0124120607 for ; Fri, 13 Dec 2013 09:17:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4ED6820603 for ; Fri, 13 Dec 2013 09:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752256Ab3LMJQp (ORCPT ); Fri, 13 Dec 2013 04:16:45 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:42977 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751897Ab3LMJQl (ORCPT ); Fri, 13 Dec 2013 04:16:41 -0500 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBD9GeCV026205 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 09:16:41 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBD9Gdxt027187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 13 Dec 2013 09:16:40 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBD9GdZw016902 for ; Fri, 13 Dec 2013 09:16:39 GMT Received: from localhost.jp.oracle.com (/10.191.13.82) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 Dec 2013 01:16:38 -0800 From: Liu Bo To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/3] Btrfs: don't build inode cache for orphan root Date: Fri, 13 Dec 2013 17:16:22 +0800 Message-Id: <1386926183-18325-3-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1386926183-18325-1-git-send-email-bo.li.liu@oracle.com> References: <1386926183-18325-1-git-send-email-bo.li.liu@oracle.com> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 We check if we have orphan roots when mounting btrfs, but orphan roots are those who are already dead and about to be freed, so don't start building inode cache for them, otherwise we'll get an ugly crash. Signed-off-by: Liu Bo Acked-by: Miao Xie --- fs/btrfs/inode-map.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index 6c8d7bb..493694f 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c @@ -141,7 +141,9 @@ static void start_caching(struct btrfs_root *root) int ret; u64 objectid; - if (!btrfs_test_opt(root, INODE_MAP_CACHE)) + /* Don't even start if this is an orphan root. */ + if (!btrfs_test_opt(root, INODE_MAP_CACHE) || + btrfs_root_refs(&root->root_item) == 0) return; spin_lock(&root->cache_lock);