Skip to content

Commit 12bcbd4

Browse files
Jeff Laytonchucklever
authored andcommitted
nfsd: Retry once in nfsd_open on an -EOPENSTALE return
If we get back -EOPENSTALE from an NFSv4 open, then we either got some unhandled error or the inode we got back was not the same as the one associated with the dentry. We really have no recourse in that situation other than to retry the open, and if it fails to just return nfserr_stale back to the client. Signed-off-by: Jeff Layton <jeff.layton@primarydata.com> Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent a2694e5 commit 12bcbd4

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

fs/nfsd/nfsproc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ nfserrno (int errno)
875875
{ nfserr_serverfault, -ESERVERFAULT },
876876
{ nfserr_serverfault, -ENFILE },
877877
{ nfserr_io, -EREMOTEIO },
878+
{ nfserr_stale, -EOPENSTALE },
878879
{ nfserr_io, -EUCLEAN },
879880
{ nfserr_perm, -ENOKEY },
880881
{ nfserr_no_grace, -ENOGRACE},

fs/nfsd/vfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
777777
int may_flags, struct file **filp)
778778
{
779779
__be32 err;
780+
bool retried = false;
780781

781782
validate_process_creds();
782783
/*
@@ -792,9 +793,16 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
792793
*/
793794
if (type == S_IFREG)
794795
may_flags |= NFSD_MAY_OWNER_OVERRIDE;
796+
retry:
795797
err = fh_verify(rqstp, fhp, type, may_flags);
796-
if (!err)
798+
if (!err) {
797799
err = __nfsd_open(rqstp, fhp, type, may_flags, filp);
800+
if (err == nfserr_stale && !retried) {
801+
retried = true;
802+
fh_put(fhp);
803+
goto retry;
804+
}
805+
}
798806
validate_process_creds();
799807
return err;
800808
}

0 commit comments

Comments
 (0)