From patchwork Wed Oct 24 10:45:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Schmidt X-Patchwork-Id: 1637471 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 996DB3FD4E for ; Wed, 24 Oct 2012 10:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933588Ab2JXKpU (ORCPT ); Wed, 24 Oct 2012 06:45:20 -0400 Received: from xp-ob.rzone.de ([81.169.146.137]:44426 "EHLO xp-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756338Ab2JXKpS (ORCPT ); Wed, 24 Oct 2012 06:45:18 -0400 X-RZG-CLASS-ID: xp Received: from pizpot.store ([192.168.43.236]) by jorabe.store (jorabe xp3) (RZmta 30.20 OK) with ESMTP id p06af8o9O8SEFs ; Wed, 24 Oct 2012 12:45:16 +0200 (CEST) From: Jan Schmidt To: chris.mason@fusionio.com, bo.li.liu@oracle.com Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: drop locks before calling read_tree_block from get_old_root Date: Wed, 24 Oct 2012 12:45:16 +0200 Message-Id: <1351075516-16344-1-git-send-email-list.btrfs@jan-o-sch.net> X-Mailer: git-send-email 1.8.0 In-Reply-To: <5087BB1D.4020501@oracle.com> References: <5087BB1D.4020501@oracle.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org get_old_root needs its lock on the root node only to clone that buffer. However, when we call read_tree_block, we know already that we're not going to clone the root node. Thus we can safely unlock before, to avoid issues where read_tree_block makes potentially sleeping allocations. Signed-off-by: Jan Schmidt Reviewed-by: Liu Bo Tested-by: Liu Bo --- Thanks for pointing that out, liubo! I added this additional patch on top of my patch staple at: git://git.jan-o-sch.net/btrfs-unstable for-chris I also made a second branch, because this last commit actually fixes that's introduced by one of the patches in the patch set. So I folded it into the respective commit: git://git.jan-o-sch.net/btrfs-unstable for-chris-fixed I made sure that the resulting code is the same. Chris: please pull either one for rc3. -Jan --- fs/btrfs/ctree.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index c608b3c..eba44b0 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1261,6 +1261,8 @@ get_old_root(struct btrfs_root *root, u64 time_seq) tm = tree_mod_log_search(root->fs_info, logical, time_seq); if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { + btrfs_tree_read_unlock(root->node); + free_extent_buffer(root->node); blocksize = btrfs_level_size(root, old_root->level); eb = read_tree_block(root, logical, blocksize, 0); if (!eb) { @@ -1271,12 +1273,15 @@ get_old_root(struct btrfs_root *root, u64 time_seq) eb = btrfs_clone_extent_buffer(eb); } } else if (old_root) { + btrfs_tree_read_unlock(root->node); + free_extent_buffer(root->node); eb = alloc_dummy_extent_buffer(logical, root->nodesize); } else { eb = btrfs_clone_extent_buffer(root->node); + btrfs_tree_read_unlock(root->node); + free_extent_buffer(root->node); } - btrfs_tree_read_unlock(root->node); - free_extent_buffer(root->node); + if (!eb) return NULL; extent_buffer_get(eb);