Blob Blame History Raw
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Date: Thu, 21 Jan 2021 17:11:42 -0500
Subject: [PATCH] pNFS/NFSv4: Try to return invalid layout in
 pnfs_layout_process()
Git-commit: 08bd8dbe88825760e953759d7ec212903a026c75
Patch-mainline: v5.11
References: git-fixes

If the server returns a new stateid that does not match the one in our
cache, then try to return the one we hold instead of just invalidating
it on the client side. This ensures that both client and server will
agree that the stateid is invalid.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Acked-by: NeilBrown <neilb@suse.com>

---
 fs/nfs/pnfs.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2026,7 +2026,13 @@ pnfs_layout_process(struct nfs4_layoutge
 		 * We got an entirely new state ID.  Mark all segments for the
 		 * inode invalid, and retry the layoutget
 		 */
-		pnfs_mark_layout_stateid_invalid(lo, &free_me);
+		struct pnfs_layout_range range = {
+			.iomode = IOMODE_ANY,
+			.length = NFS4_MAX_UINT64,
+		};
+		pnfs_set_plh_return_info(lo, IOMODE_ANY, 0);
+		pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
+						&range, 0);
 		goto out_forget;
 	}
 
@@ -2047,7 +2053,6 @@ out_forget:
 	NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
 	if (!pnfs_layout_is_valid(lo))
 		nfs_commit_inode(ino, 0);
-	pnfs_free_lseg_list(&free_me);
 	return ERR_PTR(-EAGAIN);
 }