Skip to content

Commit

Permalink
NFSD: Make nfsd4_remove() wait before returning NFS4ERR_DELAY
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chuck Lever committed Sep 26, 2022
1 parent 68c522a commit 5f5f8b6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1788,9 +1788,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);
}
Expand Down

0 comments on commit 5f5f8b6

Please sign in to comment.