[Samba] File corruption with write cache enabled - patch included

jra at dp.samba.org jra at dp.samba.org
Thu Oct 3 18:21:00 GMT 2002


On Thu, Oct 03, 2002 at 12:52:10PM +0200, Rasmus Borup Hansen wrote:
> I recently found out that write caching in samba sometimes leads to
> file corruption (the setup program for Sophos Antivirus generates
> corrupted files when making a "central installation" on a Samba
> share).
> 
> This morning I tracked down the place in the Samba code that leads to
> corruption. Here is what happened to me:
> 
> "write cache size" is 8192 bytes. A client opens a new file and writes
> byte no. 30959. This byte is cached. Then the program write byte
> no. 61919 which is written directly to the disk, since the cache
> doesn't go that far. The client then writes bytes no. 0 through
> 61920. Since these bytes don't fit into the cache they are written
> directly to the disk. However, the cached byte at position 30959 is
> not discarded. When this byte is later written to the disk, the file
> will get corrupted.
> 
> The patch below detects this situation and discards the cached
> byte(s). I guess that some profiling code should also be added at some
> time. The patch is against version 2.2.5.
> 
> Perhaps you should warn users of current versions against using write
> caching.
> 
> I believe that this bug is the same as bug no. 24502 submitted by
> Henrik Qwinto <qwinto at tut.by>.
> 
> Best regards, and thank you for making Samba,

Damn good call ! Very good bugfix. I've committed it to all
Samba branches. Thanks a *lot* for this fix !

Jeremy.



More information about the samba mailing list