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

Bo Jacobsen subs at systemhouse.dk
Mon Nov 11 08:57: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.
> -- 

Is this patch included in 2.2.6.

> >Perhaps you should warn users of current versions against using write
> > caching.

Are we talking about oplocked files or has it also something to do with "strict sync".

Bo.





More information about the samba mailing list