From: J. Bruce Fields In an earlier patch (commit b648330a1d741d5df8a5076b2a0a2519c69c8f41) I noted that a too-early grace-period check was preventing us from bumping the sequence id on open. Unfortunately in that patch I stupidly moved the grace-period check back too far, so now an open for create can succesfully create the file while still returning ERR_GRACE. The correct place for that check is after we've set the open_owner and handled any replays, but before we actually start mucking with the filesystem. Thanks to Avishay Traeger for reporting the bug. Signed-off-by: J. Bruce Fields Signed-off-by: Neil Brown Signed-off-by: Andrew Morton --- fs/nfsd/nfs4proc.c | 8 ++++++++ fs/nfsd/nfs4state.c | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff -puN fs/nfsd/nfs4proc.c~nfsd4-dont-create-on-open-that-fails-due-to-err_grace fs/nfsd/nfs4proc.c --- 25/fs/nfsd/nfs4proc.c~nfsd4-dont-create-on-open-that-fails-due-to-err_grace Fri Jan 13 17:54:24 2006 +++ 25-akpm/fs/nfsd/nfs4proc.c Fri Jan 13 17:54:24 2006 @@ -192,6 +192,14 @@ nfsd4_open(struct svc_rqst *rqstp, struc } if (status) goto out; + + /* Openowner is now set, so sequence id will get bumped. Now we need + * these checks before we do any creates: */ + if (nfs4_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) + return nfserr_grace; + if (!nfs4_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) + return nfserr_no_grace; + switch (open->op_claim_type) { case NFS4_OPEN_CLAIM_DELEGATE_CUR: status = nfserr_inval; diff -puN fs/nfsd/nfs4state.c~nfsd4-dont-create-on-open-that-fails-due-to-err_grace fs/nfsd/nfs4state.c --- 25/fs/nfsd/nfs4state.c~nfsd4-dont-create-on-open-that-fails-due-to-err_grace Fri Jan 13 17:54:24 2006 +++ 25-akpm/fs/nfsd/nfs4state.c Fri Jan 13 17:54:24 2006 @@ -1733,12 +1733,6 @@ nfsd4_process_open2(struct svc_rqst *rqs struct nfs4_delegation *dp = NULL; int status; - if (nfs4_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) - return nfserr_grace; - - if (!nfs4_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) - return nfserr_no_grace; - status = nfserr_inval; if (!TEST_ACCESS(open->op_share_access) || !TEST_DENY(open->op_share_deny)) goto out; _