Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4170409ybz; Tue, 28 Apr 2020 06:57:08 -0700 (PDT) X-Google-Smtp-Source: APiQypLYCa6Uq25lmZm8Bnls67alOYpPmREwh+zZdFgzR2ZTaPhoxWqZDwK6Cqu7rqdX2WORt5Ov X-Received: by 2002:a17:906:4ed6:: with SMTP id i22mr598192ejv.146.1588082227904; Tue, 28 Apr 2020 06:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588082227; cv=none; d=google.com; s=arc-20160816; b=LYfJVVybYkf5Tk8jp/Eb4R04XIRCMKXdZtSlpmAwU3K2LoRamXs9ZFNimmkHJHnTEe HVqfAynGLNougZWTXP3VtcIKds80YvRUOAhv4A90SqKlY/YV4zQo8gYu0jnlY+GqEV3x sg1ey5bnJEu7okUFHPXZaioJBZ8QWa6gAl62cB1GLx+e6gBgEc6G1G68wcbKPrJMLBxU Obs2jLg/mAOHxyZdz+BNFzQ95hxbc/DyNKTe9WzJltDFwGZhFPouq5K0KXKnMUEj3kEO TpgpiSyFSeUFLa255yrqGFrf0G20GlHfQiLpIKILNtzKxI8zeHX4sm8h0w8pqjJ/3Gl5 cSCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=X4tioWD3OgZ6hJgXQPnZhVHUPE9NgIPgN7oPa4m1BwQ=; b=OrBqVN8Ifwp2eovpFwXVptIyy3/PHt5PoDoCPSIzYOKiOx2nMC5YEAhuWzy7KTNcJh IndhvpxzJW10q5O66x4pANl0MDacmHcMRXasP1fxPcru0gWErhhNmqaTpNcKktQ/OIxl 5Gx63LBJzQLWPlxfYo1zPpHyCY3nf+Ml2W+sm0pibHdL8Yu/PnuwlapHVRvyGLO0pDea v0hGv3n7GjvIH1qvHA+q2D2WIw203bCWbqh1gNeTBiUmSECnoQt1rXHkZ9SXX+KNFFW3 ZpcJspWdoYSuvG3+MvZntg3KZDdpxWIu25u5xIJPH33bybna07j75l19dR7In8ZIIug4 IBaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f3si1634799edw.598.2020.04.28.06.56.45; Tue, 28 Apr 2020 06:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727977AbgD1NzF (ORCPT + 99 others); Tue, 28 Apr 2020 09:55:05 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59976 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726868AbgD1NzF (ORCPT ); Tue, 28 Apr 2020 09:55:05 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D7F1FFE6ACFFF91720DA; Tue, 28 Apr 2020 21:54:47 +0800 (CST) Received: from [127.0.0.1] (10.166.215.100) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Tue, 28 Apr 2020 21:54:39 +0800 Subject: Re: [PATCH] fs/ceph:fix double unlock in handle_cap_export() To: "Yan, Zheng" CC: Jeff Layton , Sage Weil , "Ilya Dryomov" , ceph-devel , "Linux Kernel Mailing List" , , References: <1588077962-353994-1-git-send-email-wubo40@huawei.com> From: Wu Bo Message-ID: Date: Tue, 28 Apr 2020 21:54:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.166.215.100] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/4/28 21:41, Yan, Zheng wrote: > On Tue, Apr 28, 2020 at 8:50 PM Wu Bo wrote: >> >> If the ceph_mdsc_open_export_target_session() return fails, >> should add a lock to avoid twice unlocking. >> Because the lock will be released at the retry or out_unlock tag. >> > > at retry label, i_ceph_lock get locked. I don't see how i_ceph_lock > can get double unlock >sorry, maybe I didn't describe it clearly enough, not i_ceph_lock, but session->s_mutex. Thanks. Wu Bo >> Signed-off-by: Wu Bo >> --- >> fs/ceph/caps.c | 26 ++++++++++++++------------ >> 1 file changed, 14 insertions(+), 12 deletions(-) >> >> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c >> index 185db76..b5a62a8 100644 >> --- a/fs/ceph/caps.c >> +++ b/fs/ceph/caps.c >> @@ -3731,22 +3731,24 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex, >> >> /* open target session */ >> tsession = ceph_mdsc_open_export_target_session(mdsc, target); >> - if (!IS_ERR(tsession)) { >> - if (mds > target) { >> - mutex_lock(&session->s_mutex); >> - mutex_lock_nested(&tsession->s_mutex, >> - SINGLE_DEPTH_NESTING); >> - } else { >> - mutex_lock(&tsession->s_mutex); >> - mutex_lock_nested(&session->s_mutex, >> - SINGLE_DEPTH_NESTING); >> - } >> - new_cap = ceph_get_cap(mdsc, NULL); >> - } else { >> + if (IS_ERR(tsession)) { >> WARN_ON(1); >> tsession = NULL; >> target = -1; >> + mutex_lock(&session->s_mutex); >> + goto out_unlock; >> + } >> + >> + if (mds > target) { >> + mutex_lock(&session->s_mutex); >> + mutex_lock_nested(&tsession->s_mutex, >> + SINGLE_DEPTH_NESTING); >> + } else { >> + mutex_lock(&tsession->s_mutex); >> + mutex_lock_nested(&session->s_mutex, >> + SINGLE_DEPTH_NESTING); >> } >> + new_cap = ceph_get_cap(mdsc, NULL); >> goto retry; >> >> out_unlock: >> -- >> 1.8.3.1 >> > > . >