Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp918283ybi; Fri, 2 Aug 2019 06:28:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrprdcvU0sLI+f9FsWEfN2Bx7+GR1EepeykTMYXas8JMYGkOPmvlqVMOwFdW+5SuucxFNe X-Received: by 2002:a17:90a:22aa:: with SMTP id s39mr4308907pjc.39.1564752496077; Fri, 02 Aug 2019 06:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564752496; cv=none; d=google.com; s=arc-20160816; b=aMpxPmBdK7LGrxhK7ydbXVuHqK6d3Rlum3bHnJjuSsFdj08umoPgrW0lrSXR91TpIm rogQh3UOYpSAQipi++R7W6w7/6cOUsgaWNelCf8Wkp3PdivLT1+DiO7T0WzZr6u9KfWp WDnzTKnhrLYIPP2PD0gHTaqpT1QTtRArSoGnrtoWsJEs9+4tFuR3shsbGNTfS6ITCkHE HcZgjTBgeo3vTtskOjBA0ANKawZBIFAgRDSYszlfa0ONbClFaoXjHKnoazBjozTs+Bca MJXn31xU8xCODkVWCOTi/FIMuqp4WUBDhDQbI9eqc6s6UzfQc1vzzpY+zc7IQSxW20Ff jQ3Q== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HS1HCpAW9q/jBmYji/dLqT/6ogDYovx0KdFJ8ABXwoc=; b=Yr24Ml7oiveU5KmO0BBsBtmf2311syjs8tupONnTGyrzNYaRbVRAQAb5QImTZt68MX cpUOHGtYXPo3btO+YmFzDoTb077goTtaLmw5XWPtczr1iuqDyAGhR4LH3x8QuahK+rM4 k3b+TQss51yTyYXjOws0AGU2hK8gwJq1loZrtvGT/kB7It1/HgfqGa1PMTu3+RNdwcJh OymrVLYUX9T8U6YnOc8t6zGyrpDWf28u+Cf+N5lGZijEvOxevLyu0X0Fr7bkRpdiG1oR LUVkFubEjUehskaM2lwj1jdeeyGP+tu0EcLUx5iF11xVDZfA2wwO91e0/5mcd7ZHNkRn mm3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UhNDG1GE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k23si39234779pgb.228.2019.08.02.06.28.00; Fri, 02 Aug 2019 06:28:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UhNDG1GE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390783AbfHBJhK (ORCPT + 99 others); Fri, 2 Aug 2019 05:37:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404833AbfHBJgQ (ORCPT ); Fri, 2 Aug 2019 05:36:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 242122184B; Fri, 2 Aug 2019 09:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738575; bh=UOlWSdtchKYsBmJqg8duIoQQ3H+xRyAdBrbbFVsXwRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UhNDG1GEQTFaCZjGVB3n3nwhrbg9ULMKKyFIYa8c8u72lNv/aF80inBJJqQrGbkh9 Pi6mw0RmBb5bwMBSfFloVroVTYjUcs0qydQX3HiPG2bFZno69zE5u6HQBd0MsGixii 4s1IG+4s0j+BKGAYSkkSeFk3McvdEoHdfKzoRA50= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Yan, Zheng" , Jeff Layton , Ilya Dryomov Subject: [PATCH 4.4 158/158] ceph: hold i_ceph_lock when removing caps for freeing inode Date: Fri, 2 Aug 2019 11:29:39 +0200 Message-Id: <20190802092233.875646888@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yan, Zheng commit d6e47819721ae2d9d090058ad5570a66f3c42e39 upstream. ceph_d_revalidate(, LOOKUP_RCU) may call __ceph_caps_issued_mask() on a freeing inode. Signed-off-by: "Yan, Zheng" Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/caps.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -1072,20 +1072,23 @@ static int send_cap_msg(struct ceph_mds_ } /* - * Queue cap releases when an inode is dropped from our cache. Since - * inode is about to be destroyed, there is no need for i_ceph_lock. + * Queue cap releases when an inode is dropped from our cache. */ void ceph_queue_caps_release(struct inode *inode) { struct ceph_inode_info *ci = ceph_inode(inode); struct rb_node *p; + /* lock i_ceph_lock, because ceph_d_revalidate(..., LOOKUP_RCU) + * may call __ceph_caps_issued_mask() on a freeing inode. */ + spin_lock(&ci->i_ceph_lock); p = rb_first(&ci->i_caps); while (p) { struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); p = rb_next(p); __ceph_remove_cap(cap, true); } + spin_unlock(&ci->i_ceph_lock); } /*