* [PATCH] nfsd: fix inclusive vfs_fsync_range() end
@ 2014-10-06 23:42 Zach Brown
2014-10-07 12:32 ` J. Bruce Fields
0 siblings, 1 reply; 2+ messages in thread
From: Zach Brown @ 2014-10-06 23:42 UTC (permalink / raw)
To: J. Bruce Fields, linux-nfs, linux-kernel
The vfs_fsync_range() call during write processing got the end of the
range off by one. The range is inclusive, not exclusive. The error has
nfsd sync more data than requested -- it's correct but unnecessary
overhead.
The call during commit processing is correct so I copied that pattern in
write processing. Maybe a helper would be nice but I kept it trivial.
This is untested. I found it while reviewing code for something else
entirely.
Signed-off-by: Zach Brown <zab@zabbo.net>
---
fs/nfsd/vfs.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index f501a9b..825250e 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -921,6 +921,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
int stable = *stablep;
int use_wgather;
loff_t pos = offset;
+ loff_t end = LLONG_MAX;
unsigned int pflags = current->flags;
if (rqstp->rq_local)
@@ -952,10 +953,13 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
fsnotify_modify(file);
if (stable) {
- if (use_wgather)
+ if (use_wgather) {
host_err = wait_for_concurrent_writes(file);
- else
- host_err = vfs_fsync_range(file, offset, offset+*cnt, 0);
+ } else {
+ if (*cnt)
+ end = offset + *cnt - 1;
+ host_err = vfs_fsync_range(file, offset, end, 0);
+ }
}
out_nfserr:
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nfsd: fix inclusive vfs_fsync_range() end
2014-10-06 23:42 [PATCH] nfsd: fix inclusive vfs_fsync_range() end Zach Brown
@ 2014-10-07 12:32 ` J. Bruce Fields
0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2014-10-07 12:32 UTC (permalink / raw)
To: Zach Brown; +Cc: linux-nfs, linux-kernel
On Mon, Oct 06, 2014 at 04:42:52PM -0700, Zach Brown wrote:
> The vfs_fsync_range() call during write processing got the end of the
> range off by one. The range is inclusive, not exclusive. The error has
> nfsd sync more data than requested -- it's correct but unnecessary
> overhead.
>
> The call during commit processing is correct so I copied that pattern in
> write processing. Maybe a helper would be nice but I kept it trivial.
>
> This is untested. I found it while reviewing code for something else
> entirely.
Makes sense to me, thanks! Queuing up for 3.19.--b.
>
> Signed-off-by: Zach Brown <zab@zabbo.net>
> ---
> fs/nfsd/vfs.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index f501a9b..825250e 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -921,6 +921,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> int stable = *stablep;
> int use_wgather;
> loff_t pos = offset;
> + loff_t end = LLONG_MAX;
> unsigned int pflags = current->flags;
>
> if (rqstp->rq_local)
> @@ -952,10 +953,13 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> fsnotify_modify(file);
>
> if (stable) {
> - if (use_wgather)
> + if (use_wgather) {
> host_err = wait_for_concurrent_writes(file);
> - else
> - host_err = vfs_fsync_range(file, offset, offset+*cnt, 0);
> + } else {
> + if (*cnt)
> + end = offset + *cnt - 1;
> + host_err = vfs_fsync_range(file, offset, end, 0);
> + }
> }
>
> out_nfserr:
> --
> 1.9.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-07 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 23:42 [PATCH] nfsd: fix inclusive vfs_fsync_range() end Zach Brown
2014-10-07 12:32 ` J. Bruce Fields
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.