diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 5684845d9511..e29034b1e612 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1803,9 +1803,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(dirp, rdentry, NULL); + + for (retries = 1;;) { + host_err = vfs_unlink(dirp, rdentry, NULL); + if (host_err != -EAGAIN || !retries--) + break; + if (!nfsd_wait_for_delegreturn(rqstp, rinode)) + break; + } } else { host_err = vfs_rmdir(dirp, rdentry); }