From patchwork Thu Nov 2 06:00:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Chen X-Patchwork-Id: 10037943 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 D470D60291 for ; Thu, 2 Nov 2017 06:02:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B968328D67 for ; Thu, 2 Nov 2017 06:02:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB31B28D92; Thu, 2 Nov 2017 06:02:53 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A47728D67 for ; Thu, 2 Nov 2017 06:02:52 +0000 (UTC) Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA262gZx025806 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 06:02:43 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA262fBA030330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Nov 2017 06:02:41 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eA8aO-00045V-Uy; Wed, 01 Nov 2017 23:02:40 -0700 Received: from aserv0021.oracle.com ([141.146.126.233]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eA8aM-00045L-UK for ocfs2-devel@oss.oracle.com; Wed, 01 Nov 2017 23:02:39 -0700 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vA262cuF010242 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 2 Nov 2017 06:02:38 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vA260IfX005058 for ; Thu, 2 Nov 2017 06:02:38 GMT Authentication-Results: oracle.com; spf=pass smtp.mailfrom=alex.chen@huawei.com Received: from huawei.com ([45.249.212.32]) by userp2030.oracle.com with ESMTP id 2dyu0s4kgh-1 for ; Thu, 02 Nov 2017 06:02:38 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 34F3959D53130; Thu, 2 Nov 2017 14:02:24 +0800 (CST) Received: from [127.0.0.1] (10.177.26.59) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.361.1; Thu, 2 Nov 2017 14:00:16 +0800 Message-ID: <59FAB46C.9050703@huawei.com> Date: Thu, 2 Nov 2017 14:00:12 +0800 From: alex chen User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Andrew Morton X-Originating-IP: [10.177.26.59] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGB0dEQpMehcdEhEKWU0XZ2ZyEQpZSRcHGxobcRkGBxwddwYYGhoGGRp CHwYaBhsaGgYeEnEYEBp3BhoGGgYaBhoGGgYacRoQGncGGhEKWV4XaG55EQpJRhdFWEtJRk91Wl hFTl9JXkNFRB4RCkNOF00YYWVQb09vS21vWUNzaXxaQ0xLZRlyB2RfZ24YaEMcEQpYXBcfBBoEG xsTBxtIGk4YTktPBRsaBBsaGgQeEgQbEBseGh8aEQpeWRd4Z2xHcBEKTVwXGR8cEQpMWhdpaGlC a3kRCkVZF2hrEQpDWhceHwQYHhMEGBsYBBkYEQpCXhcbEQpESRcTEQpCRhdgU24eQxlzZ1hGZhE KQlwXGhEKQkUXYhJ9YhJiaxxFa30RCkJOF2xCSFlTGk1leHgdEQpCTBdpAQEYbhlbGFJHehEKQm wXaxxCQ056SBxeekARCkJAF25HYnNfXE5LY31jEQpCWBdifW95AU8YGXBwexEKWlgXGxEKcGgXb 0hob2tYW3xfX0AQGhEKcGgXa1NrW0xsRh9PckMQGhEKcGgXYnh4ZVAcSWMaHlIQBxkaEQpwaBdj XlhPHU5ZRGJzHxAHGRoRCnBoF25cWl1PSW0ca21bEBoRCnBsF2ZBTmRTS1lyYHodEBkaEQptfhc aEQpYTRdLESA= X-PDR: PASS X-ServerName: [45.249.212.32] X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8702 signatures=668609 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=78 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=277 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711020080 Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH v2] ocfs2/cluster: unlock the o2hb_live_lock before the o2nm_depend_item() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: userv0022.oracle.com [156.151.31.74] X-Virus-Scanned: ClamAV using ClamSMTP In the following situation, the down_write() will be called under the spin_lock(), which may lead a soft lockup: o2hb_region_inc_user spin_lock(&o2hb_live_lock) o2hb_region_pin o2nm_depend_item configfs_depend_item inode_lock down_write -->here may sleep and reschedule So we should unlock the o2hb_live_lock before the o2nm_depend_item(), and get item reference in advance to prevent the region to be released. Signed-off-by: Alex Chen Reviewed-by: Yiwen Jiang Reviewed-by: Jun Piao --- fs/ocfs2/cluster/heartbeat.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index d020604..07b2fdc 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -2399,8 +2399,15 @@ static int o2hb_region_pin(const char *region_uuid) if (reg->hr_item_pinned || reg->hr_item_dropped) goto skip_pin; + config_item_get(®->hr_item); + spin_unlock(&o2hb_live_lock); + /* Ignore ENOENT only for local hb (userdlm domain) */ ret = o2nm_depend_item(®->hr_item); + + config_item_put(®->hr_item); + spin_lock(&o2hb_live_lock); + if (!ret) { mlog(ML_CLUSTER, "Pin region %s\n", uuid); reg->hr_item_pinned = 1;