Skip to content

Commit 466e16f

Browse files
neilbrownJ. Bruce Fields
authored andcommitted
nfsd: check for EBUSY from vfs_rmdir/vfs_unink.
vfs_rmdir and vfs_unlink can return -EBUSY if the target is a mountpoint. This currently gets passed to nfserrno() by nfsd_unlink(), and that results in a WARNing, which is not user-friendly. Possibly the best NFSv4 error is NFS4ERR_FILE_OPEN, because there is a sense in which the object is currently in use by some other task. The Linux NFSv4 client will map this back to EBUSY, which is an added benefit. For NFSv3, the best we can do is probably NFS3ERR_ACCES, which isn't true, but is not less true than the other options. Signed-off-by: NeilBrown <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent a25e372 commit 466e16f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

fs/nfsd/nfsd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ void nfsd_lockd_shutdown(void);
280280
#define nfserr_union_notsupp cpu_to_be32(NFS4ERR_UNION_NOTSUPP)
281281
#define nfserr_offload_denied cpu_to_be32(NFS4ERR_OFFLOAD_DENIED)
282282
#define nfserr_wrong_lfs cpu_to_be32(NFS4ERR_WRONG_LFS)
283-
#define nfserr_badlabel cpu_to_be32(NFS4ERR_BADLABEL)
283+
#define nfserr_badlabel cpu_to_be32(NFS4ERR_BADLABEL)
284+
#define nfserr_file_open cpu_to_be32(NFS4ERR_FILE_OPEN)
284285

285286
/* error codes for internal use */
286287
/* if a request fails due to kmalloc failure, it gets dropped.

fs/nfsd/vfs.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,17 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
18151815
out_drop_write:
18161816
fh_drop_write(fhp);
18171817
out_nfserr:
1818-
err = nfserrno(host_err);
1818+
if (host_err == -EBUSY) {
1819+
/* name is mounted-on. There is no perfect
1820+
* error status.
1821+
*/
1822+
if (nfsd_v4client(rqstp))
1823+
err = nfserr_file_open;
1824+
else
1825+
err = nfserr_acces;
1826+
} else {
1827+
err = nfserrno(host_err);
1828+
}
18191829
out:
18201830
return err;
18211831
}

0 commit comments

Comments
 (0)