Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] nfsd: check for EBUSY from vfs_rmdir/vfs_unink.
@ 2019-11-28  2:56 NeilBrown
  2019-11-30 20:00 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2019-11-28  2:56 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Linux NFS Mailing List

[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]


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 <neilb@suse.de>
---
 fs/nfsd/nfsd.h |  3 ++-
 fs/nfsd/vfs.c  | 12 +++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index af2947551e9c..57b93d95fa5c 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -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.
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index bd0a385df3fc..fa2acb6a3b5c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -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;
 }
-- 
2.24.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfsd: check for EBUSY from vfs_rmdir/vfs_unink.
  2019-11-28  2:56 [PATCH] nfsd: check for EBUSY from vfs_rmdir/vfs_unink NeilBrown
@ 2019-11-30 20:00 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2019-11-30 20:00 UTC (permalink / raw)
  To: NeilBrown; +Cc: Linux NFS Mailing List

On Thu, Nov 28, 2019 at 01:56:43PM +1100, NeilBrown wrote:
> 
> 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.

Makes sense to me, thanks.--b.

> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  fs/nfsd/nfsd.h |  3 ++-
>  fs/nfsd/vfs.c  | 12 +++++++++++-
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> index af2947551e9c..57b93d95fa5c 100644
> --- a/fs/nfsd/nfsd.h
> +++ b/fs/nfsd/nfsd.h
> @@ -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.
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index bd0a385df3fc..fa2acb6a3b5c 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -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;
>  }
> -- 
> 2.24.0
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  2:56 [PATCH] nfsd: check for EBUSY from vfs_rmdir/vfs_unink NeilBrown
2019-11-30 20:00 ` J. Bruce Fields

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git