diff mbox series

[v2,06/10] nfsd: NFSv3 should allow zero length writes

Message ID 20211219013803.324724-7-trondmy@kernel.org (mailing list archive)
State New, archived
Headers show
Series Assorted patches for knfsd | expand

Commit Message

Trond Myklebust Dec. 19, 2021, 1:37 a.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

According to RFC1813: "If count is 0, the WRITE will succeed
and return a count of 0, barring errors due to permissions checking."

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfsd/vfs.c    | 3 +++
 net/sunrpc/svc.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Chuck Lever Dec. 19, 2021, 8:11 p.m. UTC | #1
> On Dec 18, 2021, at 8:37 PM, trondmy@kernel.org wrote:
> 
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> According to RFC1813: "If count is 0, the WRITE will succeed
> and return a count of 0, barring errors due to permissions checking."

If you resend this series, please move this patch to the front.


> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
> fs/nfsd/vfs.c    | 3 +++
> net/sunrpc/svc.c | 2 +-
> 2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index eb9818432149..85e579aa6944 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -967,6 +967,9 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
> 
> 	trace_nfsd_write_opened(rqstp, fhp, offset, *cnt);
> 
> +	if (!*cnt)
> +		return nfs_ok;
> +
> 	if (sb->s_export_op)
> 		exp_op_flags = sb->s_export_op->flags;
> 
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 4292278a9552..72a7822fd257 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -1638,7 +1638,7 @@ unsigned int svc_fill_write_vector(struct svc_rqst *rqstp,
> 	 * entirely in rq_arg.pages. In this case, @first is empty.
> 	 */
> 	i = 0;
> -	if (first->iov_len) {
> +	if (first->iov_len || !total) {
> 		vec[i].iov_base = first->iov_base;
> 		vec[i].iov_len = min_t(size_t, total, first->iov_len);
> 		total -= vec[i].iov_len;
> -- 
> 2.33.1
> 

--
Chuck Lever
diff mbox series

Patch

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index eb9818432149..85e579aa6944 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -967,6 +967,9 @@  nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
 
 	trace_nfsd_write_opened(rqstp, fhp, offset, *cnt);
 
+	if (!*cnt)
+		return nfs_ok;
+
 	if (sb->s_export_op)
 		exp_op_flags = sb->s_export_op->flags;
 
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 4292278a9552..72a7822fd257 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1638,7 +1638,7 @@  unsigned int svc_fill_write_vector(struct svc_rqst *rqstp,
 	 * entirely in rq_arg.pages. In this case, @first is empty.
 	 */
 	i = 0;
-	if (first->iov_len) {
+	if (first->iov_len || !total) {
 		vec[i].iov_base = first->iov_base;
 		vec[i].iov_len = min_t(size_t, total, first->iov_len);
 		total -= vec[i].iov_len;