Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3890079pxv; Mon, 19 Jul 2021 11:13:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRL9qAeW7DbatniGqb9p5u04zrJpvD66swxlryeeevRPojll11JYwuKnEkFRMLu79wHRC/ X-Received: by 2002:a92:d10c:: with SMTP id a12mr18449051ilb.100.1626718387182; Mon, 19 Jul 2021 11:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626718387; cv=none; d=google.com; s=arc-20160816; b=ldgETo8ubIU5sHu2YFDnuMGJ7JcVusKK91C2B/y/RRcUuccmDg/WvswF2uEXIe/yM0 rSc+OU5i/u7mb1pyE66jiNjOCRhcgzFrQqrCkDLILHOE1DuihOsuEViNrUFuT/aSLIJi wtVA3Tr2UOBjbz1UvMSgVmImxL3Xr+ITBPxSU7QEdGf/q/hBMmwd/z2wM8WSHI8cS2eM oGaGOHXRcS9qa0En2hrvEUoaIcKHn/ryBZrXnRHbA+7cG7UvjHj63pcl1bw9aXgH86bD IdP1TbGNGdzqYuvA8mWCYq+1RKOkoHW34QQIxs1bp8+57f+iOhAuEzEZNmpfTpHcVnCd 4sRg== 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=s1zzwLJepURERoSjIgGh7Kfb6+Ram+Ld/tt3zlYSAtg=; b=u2Xmo2286zryzJ0wifp5kLET5Tgg7XWmmy9lqfE5+a9XhS3vNklyp8ZfUZqMNb5rBa GqVXIAtUNcfa1J8R62ehAKR8eIWc2EU53dZrjOlCNFmvVNP5ttebE6ZxJkvnsqQ8SB8Q BIx+J6BGFFrBxrULipRUQ8+p+EdjpLAUHgS2Z1ERggOe0pBH0Il67lCQjLmKJyPvFzXM gdIrpmKLkQEWkz1y2I/7bruxT6b4UnRxZDh+cbuhKh4ohx/pxCFYnMC+BAGTcQ+d7lV+ T+kqtOTQ7ksYF35QkLjDFlcAdQryp4x3MgbuhvEABJ0r+zhLEfsgssrC0UYrA719spwS GO7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qbdRO1nD; 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 l23si20513822jaf.47.2021.07.19.11.12.56; Mon, 19 Jul 2021 11:13: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qbdRO1nD; 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 S1352537AbhGSRaQ (ORCPT + 99 others); Mon, 19 Jul 2021 13:30:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:48162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344015AbhGSPqa (ORCPT ); Mon, 19 Jul 2021 11:46:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 392BC6124C; Mon, 19 Jul 2021 16:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626712024; bh=WfFWXTXhuEAzDW6RksKJVzKJUYVvGv5V+i8H6XDgzvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qbdRO1nDsYBpn5ei5gREJynA1aJYzr2/O4dXri5QHnoeem5W2R83jALnPLrxBMdEY wwHeXe5bdCeUMoMlA/NBQ1b/gj0rrLHB7cikJeHkviUw0aAAlKyNFMgvhLIYjN8+iX fg9bmniP2Ni/jBGoS581YEi+nnLiM/P/OmBXP6C4= 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.12 220/292] NFSv4/pnfs: Fix layoutget behaviour after invalidation Date: Mon, 19 Jul 2021 16:54:42 +0200 Message-Id: <20210719144950.214875616@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.514164272@linuxfoundation.org> References: <20210719144942.514164272@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 0b77f97a7e42adc72bd566ff8cb733ea426f74f6 ] If the layout gets invalidated, we should wait for any outstanding layoutget requests for that layout to complete, and we should resend them only after re-establishing the layout stateid. Fixes: d29b468da4f9 ("pNFS/NFSv4: Improve rejection of out-of-order layouts") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/pnfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index cd041ba6f0aa..2da35a31508c 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2014,7 +2014,7 @@ lookup_again: * If the layout segment list is empty, but there are outstanding * layoutget calls, then they might be subject to a layoutrecall. */ - if (list_empty(&lo->plh_segs) && + if ((list_empty(&lo->plh_segs) || !pnfs_layout_is_valid(lo)) && atomic_read(&lo->plh_outstanding) != 0) { spin_unlock(&ino->i_lock); lseg = ERR_PTR(wait_var_event_killable(&lo->plh_outstanding, @@ -2390,11 +2390,13 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) goto out_forget; } + if (!pnfs_layout_is_valid(lo) && !pnfs_is_first_layoutget(lo)) + goto out_forget; + if (nfs4_stateid_match_other(&lo->plh_stateid, &res->stateid)) { /* existing state ID, make sure the sequence number matches. */ if (pnfs_layout_stateid_blocked(lo, &res->stateid)) { - if (!pnfs_layout_is_valid(lo) && - pnfs_is_first_layoutget(lo)) + if (!pnfs_layout_is_valid(lo)) lo->plh_barrier = 0; dprintk("%s forget reply due to sequence\n", __func__); goto out_forget; @@ -2415,8 +2417,6 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) goto out_forget; } else { /* We have a completely new layout */ - if (!pnfs_is_first_layoutget(lo)) - goto out_forget; pnfs_set_layout_stateid(lo, &res->stateid, lgp->cred, true); } -- 2.30.2