summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-01-21 23:34:13 +0000
committerJeremy Allison <jra@samba.org>2002-01-21 23:34:13 +0000
commit2383fd87a7c05b56f98bf64fa9ef536a6217f3a5 (patch)
tree0e4f59aa70603a91308d03cbdbe87227661908e7 /source3/smbd
parent2af4b8a500531f682765280b2af9cbcafb5036d9 (diff)
downloadsamba-2383fd87a7c05b56f98bf64fa9ef536a6217f3a5.tar.gz
samba-2383fd87a7c05b56f98bf64fa9ef536a6217f3a5.tar.bz2
samba-2383fd87a7c05b56f98bf64fa9ef536a6217f3a5.zip
Found and fixed the logic bug in write cache code. Amazingly helpful
work from Juergen.Hasch@de.bosch.com in tracking this down. Jermy. (This used to be commit 40060fe3459cf103a143c324f99c2233a8e53825)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/fileio.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 9f7cb5f340..a13d05ddc4 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -240,8 +240,8 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
return real_write_file(fsp, data, pos, n);
}
- DEBUG(9,("write_file(fd=%d pos=%d size=%d) wofs=%d wsize=%d\n",
- fsp->fd, (int)pos, (int)n, (int)wcp->offset, (int)wcp->data_size));
+ DEBUG(9,("write_file(fd=%d pos=%.0f size=%u) wcp->offset=%.0f wcp->data_size=%u\n",
+ fsp->fd, (double)pos, (unsigned int)n, (double)wcp->offset, (unsigned int)wcp->data_size));
/*
* If we have active cache and it isn't contiguous then we flush.
@@ -344,12 +344,15 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
write_path = 2;
} else if ( (pos >= wcp->file_size) &&
+ (wcp->offset + wcp->data_size == wcp->file_size) &&
(pos > wcp->offset + wcp->data_size) &&
(pos < wcp->offset + wcp->alloc_size) ) {
/*
* Non-contiguous write part of which fits within
- * the cache buffer and is extending the file.
+ * the cache buffer and is extending the file
+ * and the cache contents reflect the current
+ * data up to the current end of the file.
*/
size_t data_used;
@@ -504,7 +507,8 @@ n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
if (wcp->offset + wcp->data_size > wcp->file_size)
wcp->file_size = wcp->offset + wcp->data_size;
- DEBUG(9,("cache return %u\n", (unsigned int)n));
+ DEBUG(9,("wcp->offset = %.0f wcp->data_size = %u cache return %u\n",
+ (double)wcp->offset, (unsigned int)wcp->data_size, (unsigned int)n));
total_written += n;
return total_written; /* .... that's a write :) */
@@ -570,6 +574,8 @@ static BOOL setup_write_cache(files_struct *fsp, SMB_OFF_T file_size)
return False;
}
+ memset(wcp->data, '\0', wcp->alloc_size );
+
fsp->wcp = wcp;
DO_PROFILE_INC(writecache_allocated_write_caches);
allocated_write_caches++;