]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfsd: Retry once in nfsd_open on an -EOPENSTALE return
authorJeff Layton <jeff.layton@primarydata.com>
Sun, 19 Dec 2021 01:37:56 +0000 (20:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:18:59 +0000 (16:18 +0200)
[ Upstream commit 12bcbd40fd931472c7fc9cf3bfe66799ece93ed8 ]

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>
fs/nfsd/nfsproc.c
fs/nfsd/vfs.c

index 406dc50fea7ba6235fa16caacda042e1b2309289..f65eba938a57da72dea00e9176f6aa701fa3285b 100644 (file)
@@ -875,6 +875,7 @@ nfserrno (int errno)
                { nfserr_serverfault, -ESERVERFAULT },
                { nfserr_serverfault, -ENFILE },
                { nfserr_io, -EREMOTEIO },
+               { nfserr_stale, -EOPENSTALE },
                { nfserr_io, -EUCLEAN },
                { nfserr_perm, -ENOKEY },
                { nfserr_no_grace, -ENOGRACE},
index 925aa08ca107503cc3d97442408bfac9a0524d76..bc025fe5a595b4cb711d8afddde50207f4b51af3 100644 (file)
@@ -791,6 +791,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
                int may_flags, struct file **filp)
 {
        __be32 err;
+       bool retried = false;
 
        validate_process_creds();
        /*
@@ -806,9 +807,16 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
         */
        if (type == S_IFREG)
                may_flags |= NFSD_MAY_OWNER_OVERRIDE;
+retry:
        err = fh_verify(rqstp, fhp, type, may_flags);
-       if (!err)
+       if (!err) {
                err = __nfsd_open(rqstp, fhp, type, may_flags, filp);
+               if (err == nfserr_stale && !retried) {
+                       retried = true;
+                       fh_put(fhp);
+                       goto retry;
+               }
+       }
        validate_process_creds();
        return err;
 }