Bug 584119 - CIFS file corruption on append *fix included*
Summary: CIFS file corruption on append *fix included*
Keywords:
Status: CLOSED DUPLICATE of bug 500838
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel
Version: 5.4
Hardware: All
OS: Linux
low
high
Target Milestone: rc
: ---
Assignee: Jeff Layton
QA Contact: Red Hat Kernel QE team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-04-20 19:26 UTC by Marco van Leeuwen
Modified: 2014-06-18 07:39 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-04-21 01:41:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Marco van Leeuwen 2010-04-20 19:26:02 UTC
Description of problem: the cifs client code in the kernel sometimes garbles files that are written in append mode.


Version-Release number of selected component (if applicable):
kernel 2.6.18-164.15.1.el5

How reproducible:
This depends on the write mode and probably on the type of SAMBA/CIFS server.

Solution:

I am pretty sure that the problem that we experience is what is described in kernel ChangeLog-2.31.7:
http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.31.7

---> Quoting:
    CIFS: Duplicate data on appending to some Samba servers
    
    commit cea62343956c24452700c06cf028b72414c58a74 upstream.

    SMB writes are sent with a starting offset and length. When the server
    supports the newer SMB trans2 posix open (rather than using the SMB
    NTCreateX) a file can be opened with SMB_O_APPEND flag, and for that
    case Samba server assumes that the offset sent in SMBWriteX is unneeded
    since the write should go to the end of the file - which can cause
    problems if the write was cached (since the beginning part of a
    page could be written twice by the client mm).  Jeff suggested that
    masking the flag on posix open on the client is easiest for the time
    being.

----> End quote

The fix is simple: comment out or remove lines 170 and 171 of fs/cifs/dir.c:

if (oflags & O_APPEND) 
   posix_flags != O_SMB_APPEND

The line above is indeed not present in kernel 2.6.31.7. I recompiled the cifs kernel module and tested and for me this works.

Comment 1 Jeff Layton 2010-04-21 01:41:01 UTC
Already fixed in 5.5.

*** This bug has been marked as a duplicate of bug 500838 ***


Note You need to log in before you can comment on or make changes to this bug.