summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index aa49d6f..e67e22e 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -476,8 +476,18 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred,
int error = 0;
do {
- int chunk = (len > MAXBSIZE) ? MAXBSIZE : len;
+ int chunk;
+ /*
+ * Force `offset' to a multiple of MAXBSIZE except possibly
+ * for the first chunk, so that filesystems only need to
+ * write full blocks except possibly for the first and last
+ * chunks.
+ */
+ chunk = MAXBSIZE - (uoff_t)offset % MAXBSIZE;
+
+ if (chunk > len)
+ chunk = len;
if (rw != UIO_READ && vp->v_type == VREG)
bwillwrite();
error = vn_rdwr(rw, vp, base, chunk, offset, segflg,
OpenPOWER on IntegriCloud