From patchwork Wed May 15 07:48:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 2570361 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 20FB33FDBC for ; Wed, 15 May 2013 07:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757003Ab3EOHsj (ORCPT ); Wed, 15 May 2013 03:48:39 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:48578 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756817Ab3EOHsj (ORCPT ); Wed, 15 May 2013 03:48:39 -0400 X-IronPort-AV: E=Sophos;i="4.87,676,1363104000"; d="scan'208";a="7274576" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 15 May 2013 15:45:47 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r4F7mZHV008128; Wed, 15 May 2013 15:48:35 +0800 Received: from btrfs.fnst.cn.fujitsu.com ([10.167.234.170]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013051515472778-1246902 ; Wed, 15 May 2013 15:47:27 +0800 From: Miao Xie To: linux-btrfs@vger.kernel.org Cc: alex.btrfs@zadarastorage.com Subject: [PATCH 02/17] Btrfs: fix unprotected root node of the subvolume's inode rb-tree Date: Wed, 15 May 2013 15:48:16 +0800 Message-Id: <1368604111-25073-3-git-send-email-miaox@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1368604111-25073-1-git-send-email-miaox@cn.fujitsu.com> References: <1368604111-25073-1-git-send-email-miaox@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/15 15:47:27, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/15 15:47:29, Serialize complete at 2013/05/15 15:47:29 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The root node of the rb-tree may be changed, so we should get it under the lock. Fix it. Signed-off-by: Miao Xie --- fs/btrfs/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7f6e78a..bf5c399 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4839,14 +4839,13 @@ static void inode_tree_add(struct inode *inode) struct rb_node **p; struct rb_node *parent; u64 ino = btrfs_ino(inode); -again: - p = &root->inode_tree.rb_node; - parent = NULL; if (inode_unhashed(inode)) return; - +again: + parent = NULL; spin_lock(&root->inode_lock); + p = &root->inode_tree.rb_node; while (*p) { parent = *p; entry = rb_entry(parent, struct btrfs_inode, rb_node);