Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e77a7b4f authored by Zach Brown's avatar Zach Brown Committed by J. Bruce Fields
Browse files

nfsd: fix inclusive vfs_fsync_range() end



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: default avatarZach Brown <zab@zabbo.net>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 51904b08
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -938,6 +938,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
	int			stable = *stablep;
	int			stable = *stablep;
	int			use_wgather;
	int			use_wgather;
	loff_t			pos = offset;
	loff_t			pos = offset;
	loff_t			end = LLONG_MAX;
	unsigned int		pflags = current->flags;
	unsigned int		pflags = current->flags;


	if (rqstp->rq_local)
	if (rqstp->rq_local)
@@ -969,10 +970,13 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
	fsnotify_modify(file);
	fsnotify_modify(file);


	if (stable) {
	if (stable) {
		if (use_wgather)
		if (use_wgather) {
			host_err = wait_for_concurrent_writes(file);
			host_err = wait_for_concurrent_writes(file);
		else
		} else {
			host_err = vfs_fsync_range(file, offset, offset+*cnt, 0);
			if (*cnt)
				end = offset + *cnt - 1;
			host_err = vfs_fsync_range(file, offset, end, 0);
		}
	}
	}


out_nfserr:
out_nfserr: