[pnfs] [PATCH 2/3] 4.1 server stateid generation number processing as per draft-13

andros at umich.edu andros at umich.edu
Tue Sep 18 13:21:50 EDT 2007


From: Andy Adamson <andros at umich.edu>

If the generation number is 0, use the current generation number.  Also,
reinstate generation number checking for bad or old stateids.

Signed-off by: Andy Adamson<andros at umich.edu>
Signed-off-by: Mike Sager <sager at netapp.com>
---
 fs/nfsd/nfs4state.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b8032b2..129936e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2766,15 +2766,22 @@ nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int fl
 			goto out;
 		stidp = &stp->st_stateid;
 	}
-	if (flags & NFS_4_1 && stateid->si_generation !=0 )
-		goto out;
-	if (!(flags & NFS_4_1) && stateid->si_generation > stidp->si_generation)
+	/*
+	* 4.1 is allowed to ignore the generation number when it is zero
+	* whereas 4.0 returns bad_stateid or stale stateid.
+	*/
+	if ((flags & NFS_4_1) && stateid->si_generation == 0)
+		goto checkmode;
+
+	if (stateid->si_generation > stidp->si_generation)
 		goto out;
 
 	/* OLD STATEID */
 	status = nfserr_old_stateid;
-	if (!(flags & NFS_4_1) && stateid->si_generation < stidp->si_generation)
+	if (stateid->si_generation < stidp->si_generation)
 		goto out;
+
+checkmode:
 	if (stp) {
 		if ((status = nfs4_check_openmode(stp->st_access_bmap,flags)))
 			goto out;
@@ -2898,12 +2905,11 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei
 		return nfserr_bad_stateid;
 	}
 
-	if (sop->so_minorversion == 1) {
-		if (stateid->si_generation != 0)
-			return nfserr_bad_stateid;
-		else
+	/*
+	* 4.1 is allowed to ignore the generation number when it is zero
+	*/
+	if (sop->so_minorversion == 1 && stateid->si_generation == 0)
 			goto renew; /* skip v4.0 generation number checks */
-	}
 
 	if (stateid->si_generation > stp->st_stateid.si_generation) {
 		printk("NFSD: preprocess_seqid_op: future stateid?!\n");
-- 
1.5.0.2



More information about the pNFS mailing list