From patchwork Fri Oct 20 23:40:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10021235 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 C2181603B5 for ; Sat, 21 Oct 2017 00:43:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4A1C28DF9 for ; Sat, 21 Oct 2017 00:43:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A965128E4A; Sat, 21 Oct 2017 00:43:55 +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, UNPARSEABLE_RELAY 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 463EA28DF9 for ; Sat, 21 Oct 2017 00:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753186AbdJUAnw (ORCPT ); Fri, 20 Oct 2017 20:43:52 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:37178 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbdJUAnv (ORCPT ); Fri, 20 Oct 2017 20:43:51 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9L0hoJw016871 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 21 Oct 2017 00:43:51 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v9L0hooE012694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 21 Oct 2017 00:43:50 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9L0hoTZ030549 for ; Sat, 21 Oct 2017 00:43:50 GMT Received: from dhcp-10-211-47-181.usdhcp.oraclecorp.com.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 20 Oct 2017 17:43:49 -0700 From: Liu Bo To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: avoid deadlock in btrfs_async_run_delayed_root Date: Fri, 20 Oct 2017 17:40:12 -0600 Message-Id: <20171020234012.9929-1-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 Here %path is set with ->leave_spinning=1, thus it'll hold the rwlock after btrfs_search_slot(), however, when processing delayed items in __btrfs_commit_inode_delayed_items(), it goes to acquire node->mutex which might sleep, that is, it may sleep under spin_lock. Given node->mutex is necessary to avoid race between async works, this remove the ->leave_spining setting. Signed-off-by: Liu Bo --- fs/btrfs/delayed-inode.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 19e4ad2..a857a2f 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -1331,7 +1331,6 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work) if (!delayed_node) goto free_path; - path->leave_spinning = 1; root = delayed_node->root; trans = btrfs_join_transaction(root);