Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3854125pxv; Mon, 19 Jul 2021 10:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+9WVW5uEWmCDdsyb2M0QcXL0BcGI0iDH1efk+eogLvUfASXg0+VZvHLvQNydxS0XSKSJ0 X-Received: by 2002:a02:cd0a:: with SMTP id g10mr22494027jaq.18.1626715114849; Mon, 19 Jul 2021 10:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626715114; cv=none; d=google.com; s=arc-20160816; b=YUPXaFl/bBKIb/Zu34ZAxAasK2pnWEjIWRc83P042EA/FZlNbrFxfIFlMf3NQodlKc j3+T+k8JVF3pWhadSLTeP7KoqwhegFJ+AYy9LpBH7aDYm6HoeFzavz1JanXKohT1MZqj EaXvGcLoyjmAJeelvgr+EfK5RKKT5fWGeUBAwugRblLf7EtsFGCuP/k+Y+oveurrKdyV IF69tm9CSP0YYWGo7uYdm8ogVDjqprgFk2QELhnGbFxDDTxqMdR69CFXjpC/aWfkkXWh 5ovFxhv3f5IxsLsAywnSzFk3P1MwbNFmW8RQV3BMVgq6apWq4QAAMheH8ehwVu9TSEF2 Dkyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QFvDSMztGMqjRsZCwj4J+BssBgrNwAkJZV+Uk6lK9PE=; b=yKMWC1BHxzwTu7Ojg7tKKXnZapOmRaX0LW62iYd6h8VMtqAE4CkXThhIWtzp9b90vS 1ENmbAPMURcSAbbKDulqiaGP57PbevZp/mhKGdQIs1YFSloD8W9HTbf74J51y1QXWW9c 02t8PGWZ3gogY9t+HxtWoHMY6ZP4Rm/xL7mIh6Avro3HULMPcm5dl+DmctRjaLDd9heI IaYiuvjErqBLy43qoFyPOGNVRbqCGftxdaS9Gr1nPGu+eZvNuvrXYweuo3SwNTLbDOKb 7NV/Np7lEV+qO3T4vL0C1ZNBY9QszpZjX5PQRKfOIlDclWyM4HeORXoW/GnRsVQysjXt NtZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w3Us64qK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si22031592ilh.42.2021.07.19.10.18.22; Mon, 19 Jul 2021 10:18:34 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w3Us64qK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355086AbhGSQfr (ORCPT + 99 others); Mon, 19 Jul 2021 12:35:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:40008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347966AbhGSPXd (ORCPT ); Mon, 19 Jul 2021 11:23:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60ECF6138C; Mon, 19 Jul 2021 15:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710395; bh=RwlISPnHQslLBk/zlANfaI8QrAYVqKcDeX1BM6g9CaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w3Us64qKDyhCqcOqxJjwnumGCdjtYTJWaBlZJaf1UKLhWLlfV2iWIzs2VnzGGszwO 0I9bstC2Otp1J908adkOLFhsMZXwWZJCyO8A4H5qxCJUV8G10SKhedviiVK/ueXQKk 8KJV86V8dkf5xwUu16MhXhTGh0aXfWFjk8ReZeos= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 181/243] NFSv4/pnfs: Fix the layout barrier update Date: Mon, 19 Jul 2021 16:53:30 +0200 Message-Id: <20210719144946.756253099@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit aa95edf309ef31e2df4a37ebf0e5c2ca2a6772ab ] If we have multiple outstanding layoutget requests, the current code to update the layout barrier assumes that the outstanding layout stateids are updated in order. That's not necessarily the case. Instead of using the value of lo->plh_outstanding as a guesstimate for the window of values we need to accept, just wait to update the window until we're processing the last one. The intention here is just to ensure that we don't process 2^31 seqid updates without also updating the barrier. Fixes: 1bcf34fdac5f ("pNFS/NFSv4: Update the layout barrier when we schedule a layoutreturn") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/pnfs.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 4d20125e982a..c0c2612f14af 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -966,10 +966,8 @@ void pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, const struct cred *cred, bool update_barrier) { - u32 oldseq, newseq, new_barrier = 0; - - oldseq = be32_to_cpu(lo->plh_stateid.seqid); - newseq = be32_to_cpu(new->seqid); + u32 oldseq = be32_to_cpu(lo->plh_stateid.seqid); + u32 newseq = be32_to_cpu(new->seqid); if (!pnfs_layout_is_valid(lo)) { pnfs_set_layout_cred(lo, cred); @@ -979,19 +977,21 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, clear_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); return; } - if (pnfs_seqid_is_newer(newseq, oldseq)) { + + if (pnfs_seqid_is_newer(newseq, oldseq)) nfs4_stateid_copy(&lo->plh_stateid, new); - /* - * Because of wraparound, we want to keep the barrier - * "close" to the current seqids. - */ - new_barrier = newseq - atomic_read(&lo->plh_outstanding); - } - if (update_barrier) - new_barrier = be32_to_cpu(new->seqid); - else if (new_barrier == 0) + + if (update_barrier) { + pnfs_barrier_update(lo, newseq); return; - pnfs_barrier_update(lo, new_barrier); + } + /* + * Because of wraparound, we want to keep the barrier + * "close" to the current seqids. We really only want to + * get here from a layoutget call. + */ + if (atomic_read(&lo->plh_outstanding) == 1) + pnfs_barrier_update(lo, be32_to_cpu(lo->plh_stateid.seqid)); } static bool -- 2.30.2