Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2090329ybp; Thu, 10 Oct 2019 02:01:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqx77iWwMVOf+w2HcfVYjhQuS0oyeRDxpfAJWugrEZIB5j2qumrfA3W2VtwS7ta3KRDWwGwn X-Received: by 2002:a50:8f03:: with SMTP id 3mr7275937edy.195.1570698101983; Thu, 10 Oct 2019 02:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570698101; cv=none; d=google.com; s=arc-20160816; b=p5UElveKEHc4RG1ScIWnwBNfjllYD1qjo4mvDiYGPO/BiaTGUkP7EUCcQId/gM2ic1 7uM/f2MpUjy1GZS34YMsFocZwXb/q61odhONUKdFbZ3ZhLiZQSyFOsgQ15Cy4dvwyZcw vXoYIKD3aeJJ7ftkTLG9I45TTj7S/lqHmJGJsGzpNI7zGzqhNbZ3dVyE4pC2L7sb/w9s XWYe4pQ12HGFwDDr3qHChngkGmTEUZMmdnI7TKgi0gBsuLPsciQ2kcxOdfSEmSRQg/jP snpG2lfHvYeaiuUAhIpmEMZpwsiWhUDmIvqdhYEWdnqC8OlnB0ryk9bmTV6G5m6ZnSjE 6YUw== 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=3enh+gaXqNWtaDF1q4PaEsXUnpK6M3nc8ZSqBf1crpo=; b=JR6C5Cz2eB9EVrgWBzbBWTmdZgYERjlaGCDOjKjsgxtyMZw2Fr2BlL658gb8ovw5iY uCs2yij5wr+svgK29i45TX5es4amj2wDQVHXQ4F2RyL6HU9KqxmKBgSvR4lo805lBSml TSYQ0MOo2I11Cp8Rc18L0YUhY2K2+MzYGGjQiCT2JFq7MB2moORma+tJLo6W83ONxCU4 dMjdS9hRJ2Be6A4dC2jf8cA2Ha0GtU+bK/+eZwbmcgPppXzeoodJmgGJThFNNdTEoYnY cWyhuRuacckU3HVBjFEYAbD47Kb0A0GJKWw7qM+/4Ro6hHEclwoEEcVbHg3uhPQMCrIA XItg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JLbraXo5; 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 t9si2597212ejr.29.2019.10.10.02.01.18; Thu, 10 Oct 2019 02:01:41 -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=JLbraXo5; 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 S2388431AbfJJIl4 (ORCPT + 99 others); Thu, 10 Oct 2019 04:41:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:46446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387721AbfJJIlz (ORCPT ); Thu, 10 Oct 2019 04:41:55 -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 560952190F; Thu, 10 Oct 2019 08:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696914; bh=vp8BY+ig8VH0RV4ooBLtwJ7jzgPrMoIacvhyxXcgS8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JLbraXo5VLgCHo63WXJ7NSFxuyfC80d/xvwzpFrmYB6sMAyRafKV4QBx/grBNbsTN 95ESHzr46DBc7h9i7nGsqLG0XqdQK2GI4Ij72Ct0dzahM9YOunpYWdMr0rq8rwUr7b KPXOfTD5gsoNj2Xdu8DGuuMpV1eV9XQjlsM1p3Ow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , "Yan, Zheng" , Ilya Dryomov , Sasha Levin Subject: [PATCH 5.3 099/148] ceph: fetch cap_gen under spinlock in ceph_add_cap Date: Thu, 10 Oct 2019 10:36:00 +0200 Message-Id: <20191010083617.246042248@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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: Jeff Layton [ Upstream commit 606d102327a45a49d293557527802ee7fbfd7af1 ] It's protected by the s_gen_ttl_lock, so we should fetch under it and ensure that we're using the same generation in both places. Signed-off-by: Jeff Layton Reviewed-by: "Yan, Zheng" Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/caps.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index ce0f5658720ab..8fd5301128106 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -645,6 +645,7 @@ void ceph_add_cap(struct inode *inode, struct ceph_cap *cap; int mds = session->s_mds; int actual_wanted; + u32 gen; dout("add_cap %p mds%d cap %llx %s seq %d\n", inode, session->s_mds, cap_id, ceph_cap_string(issued), seq); @@ -656,6 +657,10 @@ void ceph_add_cap(struct inode *inode, if (fmode >= 0) wanted |= ceph_caps_for_mode(fmode); + spin_lock(&session->s_gen_ttl_lock); + gen = session->s_cap_gen; + spin_unlock(&session->s_gen_ttl_lock); + cap = __get_cap_for_mds(ci, mds); if (!cap) { cap = *new_cap; @@ -681,7 +686,7 @@ void ceph_add_cap(struct inode *inode, list_move_tail(&cap->session_caps, &session->s_caps); spin_unlock(&session->s_cap_lock); - if (cap->cap_gen < session->s_cap_gen) + if (cap->cap_gen < gen) cap->issued = cap->implemented = CEPH_CAP_PIN; /* @@ -775,7 +780,7 @@ void ceph_add_cap(struct inode *inode, cap->seq = seq; cap->issue_seq = seq; cap->mseq = mseq; - cap->cap_gen = session->s_cap_gen; + cap->cap_gen = gen; if (fmode >= 0) __ceph_get_fmode(ci, fmode); -- 2.20.1