]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFSD: Make nfsd4_remove() wait before returning NFS4ERR_DELAY
authorChuck Lever <chuck.lever@oracle.com>
Thu, 8 Sep 2022 22:14:25 +0000 (18:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:17 +0000 (16:19 +0200)
[ Upstream commit 5f5f8b6d655fd947e899b1771c2f7cb581a06764 ]

nfsd_unlink() can kick off a CB_RECALL (via
vfs_unlink() -> leases_conflict()) if a delegation is present.
Before returning NFS4ERR_DELAY, give the client holding that
delegation a chance to return it and then retry the nfsd_unlink()
again, once.

Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=354
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/vfs.c

index 4c5cc142562b2fe98f11d99f6c850866a433d6d3..d17377148b669bf4a93c54d949b796976a9515da 100644 (file)
@@ -1790,9 +1790,18 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
 
        fh_fill_pre_attrs(fhp);
        if (type != S_IFDIR) {
+               int retries;
+
                if (rdentry->d_sb->s_export_op->flags & EXPORT_OP_CLOSE_BEFORE_UNLINK)
                        nfsd_close_cached_files(rdentry);
-               host_err = vfs_unlink(&init_user_ns, dirp, rdentry, NULL);
+
+               for (retries = 1;;) {
+                       host_err = vfs_unlink(&init_user_ns, dirp, rdentry, NULL);
+                       if (host_err != -EAGAIN || !retries--)
+                               break;
+                       if (!nfsd_wait_for_delegreturn(rqstp, rinode))
+                               break;
+               }
        } else {
                host_err = vfs_rmdir(&init_user_ns, dirp, rdentry);
        }