diff mbox series

nfsd: Return the correct number of bytes written to the file

Message ID 20191217173333.105547-1-trond.myklebust@hammerspace.com (mailing list archive)
State New, archived
Headers show
Series nfsd: Return the correct number of bytes written to the file | expand

Commit Message

Trond Myklebust Dec. 17, 2019, 5:33 p.m. UTC
We must allow for the fact that iov_iter_write() could have returned
a short write (e.g. if there was an ENOSPC issue).

Fixes: 73da852e3831 ("nfsd: use vfs_iter_read/write")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfsd/vfs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Bruce Fields Dec. 17, 2019, 7:30 p.m. UTC | #1
On Tue, Dec 17, 2019 at 12:33:33PM -0500, Trond Myklebust wrote:
> We must allow for the fact that iov_iter_write() could have returned
> a short write (e.g. if there was an ENOSPC issue).

Thanks!  Just a nit:

> 
> Fixes: 73da852e3831 ("nfsd: use vfs_iter_read/write")

I think that should be d890be159a71 "nfsd: Add I/O trace points in the
NFSv4 write path".

--b.

> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  fs/nfsd/vfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index c0dc491537a6..f0bca0e87d0c 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -975,6 +975,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
>  	host_err = vfs_iter_write(file, &iter, &pos, flags);
>  	if (host_err < 0)
>  		goto out_nfserr;
> +	*cnt = host_err;
>  	nfsdstats.io_write += *cnt;
>  	fsnotify_modify(file);
>  
> -- 
> 2.23.0
>
Trond Myklebust Dec. 17, 2019, 8:51 p.m. UTC | #2
On Tue, 2019-12-17 at 14:30 -0500, J. Bruce Fields wrote:
> On Tue, Dec 17, 2019 at 12:33:33PM -0500, Trond Myklebust wrote:
> > We must allow for the fact that iov_iter_write() could have
> > returned
> > a short write (e.g. if there was an ENOSPC issue).
> 
> Thanks!  Just a nit:
> 
> > Fixes: 73da852e3831 ("nfsd: use vfs_iter_read/write")
> 
> I think that should be d890be159a71 "nfsd: Add I/O trace points in
> the
> NFSv4 write path".

Fair enough. Do you want to fix that up?

> 
> --b.
> 
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > ---
> >  fs/nfsd/vfs.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > index c0dc491537a6..f0bca0e87d0c 100644
> > --- a/fs/nfsd/vfs.c
> > +++ b/fs/nfsd/vfs.c
> > @@ -975,6 +975,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct
> > svc_fh *fhp, struct file *file,
> >  	host_err = vfs_iter_write(file, &iter, &pos, flags);
> >  	if (host_err < 0)
> >  		goto out_nfserr;
> > +	*cnt = host_err;
> >  	nfsdstats.io_write += *cnt;
> >  	fsnotify_modify(file);
> >  
> > -- 
> > 2.23.0
> >
Bruce Fields Dec. 17, 2019, 9:04 p.m. UTC | #3
On Tue, Dec 17, 2019 at 08:51:20PM +0000, Trond Myklebust wrote:
> On Tue, 2019-12-17 at 14:30 -0500, J. Bruce Fields wrote:
> > On Tue, Dec 17, 2019 at 12:33:33PM -0500, Trond Myklebust wrote:
> > > We must allow for the fact that iov_iter_write() could have
> > > returned
> > > a short write (e.g. if there was an ENOSPC issue).
> > 
> > Thanks!  Just a nit:
> > 
> > > Fixes: 73da852e3831 ("nfsd: use vfs_iter_read/write")
> > 
> > I think that should be d890be159a71 "nfsd: Add I/O trace points in
> > the
> > NFSv4 write path".
> 
> Fair enough. Do you want to fix that up?

I've taken care of it.--b.

> 
> > 
> > --b.
> > 
> > > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > > ---
> > >  fs/nfsd/vfs.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > > index c0dc491537a6..f0bca0e87d0c 100644
> > > --- a/fs/nfsd/vfs.c
> > > +++ b/fs/nfsd/vfs.c
> > > @@ -975,6 +975,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct
> > > svc_fh *fhp, struct file *file,
> > >  	host_err = vfs_iter_write(file, &iter, &pos, flags);
> > >  	if (host_err < 0)
> > >  		goto out_nfserr;
> > > +	*cnt = host_err;
> > >  	nfsdstats.io_write += *cnt;
> > >  	fsnotify_modify(file);
> > >  
> > > -- 
> > > 2.23.0
> > > 
> -- 
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> trond.myklebust@hammerspace.com
> 
>
Trond Myklebust Dec. 17, 2019, 9:09 p.m. UTC | #4
On Tue, 2019-12-17 at 16:04 -0500, J. Bruce Fields wrote:
> On Tue, Dec 17, 2019 at 08:51:20PM +0000, Trond Myklebust wrote:
> > On Tue, 2019-12-17 at 14:30 -0500, J. Bruce Fields wrote:
> > > On Tue, Dec 17, 2019 at 12:33:33PM -0500, Trond Myklebust wrote:
> > > > We must allow for the fact that iov_iter_write() could have
> > > > returned
> > > > a short write (e.g. if there was an ENOSPC issue).
> > > 
> > > Thanks!  Just a nit:
> > > 
> > > > Fixes: 73da852e3831 ("nfsd: use vfs_iter_read/write")
> > > 
> > > I think that should be d890be159a71 "nfsd: Add I/O trace points
> > > in
> > > the
> > > NFSv4 write path".
> > 
> > Fair enough. Do you want to fix that up?
> 
> I've taken care of it.--b.

Thank you!
diff mbox series

Patch

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index c0dc491537a6..f0bca0e87d0c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -975,6 +975,7 @@  nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
 	host_err = vfs_iter_write(file, &iter, &pos, flags);
 	if (host_err < 0)
 		goto out_nfserr;
+	*cnt = host_err;
 	nfsdstats.io_write += *cnt;
 	fsnotify_modify(file);