nfsd: check for EBUSY from vfs_rmdir/vfs_unink.
Subsystems (2)
PATCH 1/1 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.
--- fs/nfsd/nfsd.h | 3 ++- fs/nfsd/vfs.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
fs/nfsd/nfsd.h +2 -1
@@ -280,7 +280,8 @@ void nfsd_lockd_shutdown(void);#define nfserr_union_notsupp cpu_to_be32(NFS4ERR_UNION_NOTSUPP)#define nfserr_offload_denied cpu_to_be32(NFS4ERR_OFFLOAD_DENIED)#define nfserr_wrong_lfs cpu_to_be32(NFS4ERR_WRONG_LFS) -#define nfserr_badlabel cpu_to_be32(NFS4ERR_BADLABEL) +#define nfserr_badlabel cpu_to_be32(NFS4ERR_BADLABEL) +#define nfserr_file_open cpu_to_be32(NFS4ERR_FILE_OPEN)/* error codes for internal use */ /* if a request fails due to kmalloc failure, it gets dropped.
fs/nfsd/vfs.c +11 -1
@@ -1809,7 +1809,17 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, out_drop_write:fh_drop_write (fhp); out_nfserr: - err =nfserrno (host_err); +if (host_err == -EBUSY ) { +/* name is mounted-on. There is no perfect +* error status. +*/ +if (nfsd_v4client (rqstp)) + err = nfserr_file_open; +else + err = nfserr_acces; + }else { + err =nfserrno (host_err); + } out:return err; }
Signature · 1 line
2.24.0
Quoted 6 lines · NeilBrown
vfs_rmdirandvfs_unlinkcan return-EBUSYif the target is a mountpoint. This currently gets passed tonfserrno()bynfsd_unlink(), and that results in a WARNing, which is not user-friendly.
Quoted 7 lines
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.
Makes sense to me, thanks.--b.
Quoted 47 lines
Signed-off-by NeilBrown <[email protected]>--- fs/nfsd/nfsd.h | 3 ++- fs/nfsd/vfs.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-)fs/nfsd/nfsd.h +2
-1@@ -280,7 +280,8 @@ void nfsd_lockd_shutdown(void);#define nfserr_union_notsupp cpu_to_be32(NFS4ERR_UNION_NOTSUPP)#define nfserr_offload_denied cpu_to_be32(NFS4ERR_OFFLOAD_DENIED)#define nfserr_wrong_lfs cpu_to_be32(NFS4ERR_WRONG_LFS) -#define nfserr_badlabel cpu_to_be32(NFS4ERR_BADLABEL) +#define nfserr_badlabel cpu_to_be32(NFS4ERR_BADLABEL) +#define nfserr_file_open cpu_to_be32(NFS4ERR_FILE_OPEN)/* error codes for internal use */ /* if a request fails due to kmalloc failure, it gets dropped. fs/nfsd/vfs.c +11
-1@@ -1809,7 +1809,17 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, out_drop_write:fh_drop_write (fhp); out_nfserr: - err =nfserrno (host_err); +if (host_err == -EBUSY ) { +/* name is mounted-on. There is no perfect +* error status. +*/ +if (nfsd_v4client (rqstp)) + err = nfserr_file_open; +else + err = nfserr_acces; + }else { + err =nfserrno (host_err); + } out:return err; }Signature · 1 line
2.24.0