Author: vlendec Date: 2005-05-19 17:32:33 +0000 (Thu, 19 May 2005) New Revision: 6911
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6911 Log: For some weird reason, the patch I sent to Jeremy did not make it to his inbox several times. This is an optimization for the write cache necessary for optimal performance when sequentially writing large files. A Win32 app writes files in chunks of, say, 256k. At the SMB layer this only arrives as 64k chunks. This is fine for the file system algorithms that detect that this is a growing file, if the chunks would be sent in sequence. This however is not the case. When the XP redirector has to send a new 256k chunk it sends one single byte at the end of the 256k chunk, probably as an indication to NTFS that more stuff is coming and that NTFS should preallocate stuff. This however destroys the file system prediction and *completely* kills performance. I've seen the write system call for this one byte take 2.6 seconds where with this patch the file system happily writes 90MBytes/second per client from several clients simultaneously. Without the patch it works perfectly fine and correct, just *really* slow. Volker Modified: trunk/source/smbd/fileio.c Changeset: Modified: trunk/source/smbd/fileio.c =================================================================== --- trunk/source/smbd/fileio.c 2005-05-19 17:00:41 UTC (rev 6910) +++ trunk/source/smbd/fileio.c 2005-05-19 17:32:33 UTC (rev 6911) @@ -509,6 +509,30 @@ write_path = 3; + } else if ( (pos >= wcp->file_size) && + (pos < wcp->offset + 2*wcp->alloc_size) && + (wcp->file_size == wcp->offset + wcp->data_size) && + (n == 1) ) { + + /* + +---------------+ + | Cached data | + +---------------+ + + +--------+ + | 1 Byte | + +--------+ + */ + + SMB_BIG_UINT new_start = wcp->offset + wcp->data_size; + + flush_write_cache(fsp, WRITE_FLUSH); + wcp->offset = new_start; + wcp->data_size = pos - new_start + 1; + memset(wcp->data, '\0', wcp->data_size); + memcpy(wcp->data + wcp->data_size-1, data, 1); + return n; + } else { /* ASCII art..... JRA.