From patchwork Tue Oct 31 12:41:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Chen X-Patchwork-Id: 10034453 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 C983D60291 for ; Tue, 31 Oct 2017 12:44:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B61AD289A5 for ; Tue, 31 Oct 2017 12:44:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAE6728A61; Tue, 31 Oct 2017 12:44:48 +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 userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (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 9B244289A5 for ; Tue, 31 Oct 2017 12:44:47 +0000 (UTC) Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9VCiVW2019408 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Oct 2017 12:44:32 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9VCi8Fo026570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 31 Oct 2017 12:44:08 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 1e9Vto-0006HT-7u; Tue, 31 Oct 2017 05:44:08 -0700 Received: from aserv0021.oracle.com ([141.146.126.233]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1e9Vtm-0006HL-Rv for ocfs2-devel@oss.oracle.com; Tue, 31 Oct 2017 05:44:07 -0700 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9VCi6aV026443 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 31 Oct 2017 12:44:06 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.21/8.16.0.21) with SMTP id v9VCg6rN044700 for ; Tue, 31 Oct 2017 12:44:06 GMT Authentication-Results: oracle.com; spf=pass smtp.mailfrom=alex.chen@huawei.com Received: from huawei.com ([45.249.212.32]) by userp2040.oracle.com with ESMTP id 2dxp97pwh3-1 for ; Tue, 31 Oct 2017 12:44:05 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 4EF88B4C142F; Tue, 31 Oct 2017 20:43:51 +0800 (CST) Received: from [127.0.0.1] (10.177.26.59) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Tue, 31 Oct 2017 20:42:05 +0800 Message-ID: <59F86F83.7010501@huawei.com> Date: Tue, 31 Oct 2017 20:41:39 +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: 1TFkXGxMcEQpMehcbHBkRCllNF2dmchEKWUkXGnEaEBp3BhsdHHEfHRAadwY YGgYaEQpZXhdobmYRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XbVJQTx9/Z0VvcnVQSG h5fmdLekxTTB98QWVsX2UbWR4RClhcFx8EGgQbGxMHG0gaThhOS08FGxoEGxoaBB4SBBsQGx4aH xoRCl5ZF3hmQnlSEQpNXBceGRwRCkxaF2hpTU1TEQpFWRdoaxEKQ1oXHh8EGB4TBBgbGAQZGBEK Ql4XGxEKREkXGxgRCkJGF2cTbWAbW2VCH359EQpCXBcaEQpCRRdiEn1iEmJrHEVrfREKQk4XbEJ IWVMaTWV4eB0RCkJMF2kBARhuGVsYUkd6EQpCbBdrHEJDTnpIHF56QBEKQkAXbRleRX8dYGETAQ ERCkJYF2J9b3kBTxgZcHB7EQpaWBcbEQpwaBdsR2YdZlhFYXITEhAaEQpwaBdrU2tbTGxGH09yQ xAaEQpwaBdieHhlUBxJYxoeUhAaEQpwaBdjXlhPHU5ZRGJzHxAaEQpwaBdvXkgfRRxaSHN6QBAa EQpwbBdmQU5kU0tZcmB6HRAZGhEKbX4XGhEKWE0XSxEg 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=8700 signatures=668609 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=163 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=196 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710310169 Cc: Jan Kara , Fengguang Wu , "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH] 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: aserv0021.oracle.com [141.146.126.233] 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 | 8 ++++++++ 1 file changed, 8 insertions(+) -- 1.9.5.msysgit.1 diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index d020604..f1142a9 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -2399,6 +2399,9 @@ 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); if (!ret) { @@ -2410,9 +2413,14 @@ static int o2hb_region_pin(const char *region_uuid) else { mlog(ML_ERROR, "Pin region %s fails with %d\n", uuid, ret); + config_item_put(®->hr_item); + spin_lock(&o2hb_live_lock); break; } } + + config_item_put(®->hr_item); + spin_lock(&o2hb_live_lock); skip_pin: if (found) break;