@@ -795,6 +795,7 @@ nfserrno (int errno)
{ nfserr_serverfault, -ESERVERFAULT },
{ nfserr_serverfault, -ENFILE },
{ nfserr_io, -EREMOTEIO },
+ { nfserr_stale, -EOPENSTALE },
};
int i;
@@ -622,9 +622,9 @@ __nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
int flags = O_RDONLY|O_LARGEFILE;
__be32 err;
int host_err = 0;
+ bool retried = false;
- BUG_ON(!fhp->fh_dentry);
-
+retry:
path.mnt = fhp->fh_export->ex_path.mnt;
path.dentry = fhp->fh_dentry;
inode = d_inode(path.dentry);
@@ -659,6 +659,14 @@ __nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
file = dentry_open(&path, flags, current_cred());
if (IS_ERR(file)) {
+ if (file == ERR_PTR(-EOPENSTALE) && !retried) {
+ retried = true;
+ fh_put(fhp);
+ err = fh_verify(rqstp, fhp, type, may_flags);
+ if (err)
+ goto out;
+ goto retry;
+ }
host_err = PTR_ERR(file);
goto out_nfserr;
}
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> --- fs/nfsd/nfsproc.c | 1 + fs/nfsd/vfs.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)