summaryrefslogtreecommitdiffstats
path: root/source3/smbd/fileio.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-07-07 21:50:23 +0200
committerVolker Lendecke <vl@samba.org>2010-07-09 08:50:41 +0200
commit1c0cb365a895ce670fc32db3380cee7f129ce95b (patch)
treea31b81669a5fcc04146be8bc0855213c5db78401 /source3/smbd/fileio.c
parent6a0d3665e2a2cd9cbae4096c82418f9b0406161f (diff)
downloadsamba-1c0cb365a895ce670fc32db3380cee7f129ce95b.tar.gz
samba-1c0cb365a895ce670fc32db3380cee7f129ce95b.tar.xz
samba-1c0cb365a895ce670fc32db3380cee7f129ce95b.zip
s3: Optimize the write cache for sequential writes
In case of the one-byte allocating writes we don't work work optimally because we start the write cache at the current offset. This patch tries to avoid this case.
Diffstat (limited to 'source3/smbd/fileio.c')
-rw-r--r--source3/smbd/fileio.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 92b7d3ed9ea..92757f7052e 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -796,6 +796,26 @@ n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
DO_PROFILE_INC(writecache_init_writes);
}
#endif
+
+ if ((wcp->data_size == 0)
+ && (pos > wcp->file_size)
+ && (pos + n <= wcp->file_size + wcp->alloc_size)) {
+ /*
+ * This is a write completely beyond the
+ * current EOF, but within reach of the write
+ * cache. We expect fill-up writes pretty
+ * soon, so it does not make sense to start
+ * the write cache at the current
+ * offset. These fill-up writes would trigger
+ * separate pwrites or even unnecessary cache
+ * flushes because they overlap if this is a
+ * one-byte allocating write.
+ */
+ wcp->offset = wcp->file_size;
+ wcp->data_size = pos - wcp->file_size;
+ memset(wcp->data, 0, wcp->data_size);
+ }
+
memcpy(wcp->data+wcp->data_size, data, n);
if (wcp->data_size == 0) {
wcp->offset = pos;