Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BE04C433F5 for ; Tue, 15 Mar 2022 12:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348246AbiCOM13 (ORCPT ); Tue, 15 Mar 2022 08:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239134AbiCOM13 (ORCPT ); Tue, 15 Mar 2022 08:27:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB601532E4 for ; Tue, 15 Mar 2022 05:26:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 76FEC6151D for ; Tue, 15 Mar 2022 12:26:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 808ECC340EE; Tue, 15 Mar 2022 12:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647347176; bh=7VXOAkkyS+1laY0hmXlZz8plmtnsWeXjmxMJSnosvnY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HIrJU6gpMSRJHWNuPKq0bO67I55jY/THkVnK0kZOImMkQjK3EExBIIGI7EPOXnmaO 8oXjkPjWCXKV1B7wjAa/4hNKFjb9I8aD/WiD8ArDEa/frfgMxdNJ0uk9CDMvSxc5So sEWHPqw1KSQPbr74gzOTjCVqOQezPQDr9Q3Z9IT/k7TM6cPaV+F4iPpxirVpmnojV/ CfC9wAn9jTysZGmeQj/iunlB76poEwCmwPLq45j93J2qe2E0pIYWoNBo+EOcIC3+M6 wuDQRpPws3kf6k84NADbUyI+YDsM0oe4Z683K/yIG5fsk6WLNZufiCpDq3xx/FakCJ rKTV9c+puvxdw== Message-ID: <1ce10b6639b34759a701602d9172aec59e23c03b.camel@kernel.org> Subject: Re: [PATCH] ceph: get snap_rwsem read lock in handle_cap_export for ceph_add_cap From: Jeff Layton To: Niels Dossche , ceph-devel@vger.kernel.org Cc: Ilya Dryomov Date: Tue, 15 Mar 2022 08:26:15 -0400 In-Reply-To: <20220314200717.52033-1-dossche.niels@gmail.com> References: <20220314200717.52033-1-dossche.niels@gmail.com> Content-Type: text/plain; charset="ISO-8859-15" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org On Mon, 2022-03-14 at 21:07 +0100, Niels Dossche wrote: > ceph_add_cap says in its function documentation that the caller should > hold the read lock on the session snap_rwsem. Furthermore, not only > ceph_add_cap needs that lock, when it calls to ceph_lookup_snap_realm it > eventually calls ceph_get_snap_realm which states via lockdep that > snap_rwsem needs to be held. handle_cap_export calls ceph_add_cap > without that mdsc->snap_rwsem held. Thus, since ceph_get_snap_realm > and ceph_add_cap both need the lock, the common place to acquire that > lock is inside handle_cap_export. > > Signed-off-by: Niels Dossche > --- > fs/ceph/caps.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c > index b472cd066d1c..0dd60db285b1 100644 > --- a/fs/ceph/caps.c > +++ b/fs/ceph/caps.c > @@ -3903,8 +3903,10 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex, > /* add placeholder for the export tagert */ > int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; > tcap = new_cap; > + down_read(&mdsc->snap_rwsem); > ceph_add_cap(inode, tsession, t_cap_id, issued, 0, > t_seq - 1, t_mseq, (u64)-1, flag, &new_cap); > + up_read(&mdsc->snap_rwsem); > > if (!list_empty(&ci->i_cap_flush_list) && > ci->i_auth_cap == tcap) { Looks good. The other ceph_add_cap callsites already hold this. Merged into ceph testing branch. Thanks! -- Jeff Layton