New: Non-atomic short write problem with O_APPEND
https://bugzilla.kernel.org/show_bug.cgi?id=55651
Summary: Non-atomic short write problem with O_APPEND
Product: File System
Version: 2.5
Kernel Version: 3.8.4
Platform: All
OS/Version: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: ext4
AssignedTo: [email protected]
ReportedBy: [email protected]
Regression: No
Created an attachment (id=96041)
--> (https://bugzilla.kernel.org/attachment.cgi?id=96041)
C program to demonstrate problem with non-atomic short writes.
With recent kernels, short writes to a regular file opened with O_APPEND can be non-atomic when receiving a signal, and the write syscall is still returning bytes written == nbytes.
I tried this with v3.8.4 (latest stable) and as far back as v3.2.41 and a smattering in between. All show this problem. However, it does not reproduce on v3.0.70 or earlier kernels. All testing was done with on x86_64 SMP systems and on an ext3 or ext4 file system. (I also tried running with only a single CPU enabled. It made no difference.)
This is likely going to not be a problem specifically with the ext file system, but it seemed the best Bugzilla match that I saw based on the information gathered so far.
The problem did not reproduce on an OpenSUSE 12.1 system (3.1.10-1.19-default). In the world of RHEL kernels, this problem does not appear with RHEL5.7 or earlier RHEL kernels I tried. However, it does appear starting with RHEL5.8 and 5.9 and also on RHEL6 kernels that I tried (6.2 & 6.4).
I can't find anything wrong with the attached demo program, or find anything in the POSIX standard or with the Linux open(2) man pages that might allow for this apparent erroneous behavior.
To reproduce the problem, compile and run the program below. After it's been running a say 4-6 seconds, press ^C. Notice there's been no output from the program (for every write call made, all returned success and with scnt==wcnt). Now run "grep '^P.*P' test.log". If there is no problem, there will be no output. If you see output, you'll see lines that were stepped on or otherwise not fully written out.
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 55651] Non-atomic short write problem with O_APPEND
https://bugzilla.kernel.org/show_bug.cgi?id=55651
--- Comment #1 from Quentin Barnes <[email protected]> 2013-03-25 20:59:31 --- I have a small mistake in the above report. The problem does not reproduce on RHEL6.2 (or earlier RHEL6 releases). Only on RHEL6.3 and later.
So it looks like the bug came in between: v3.1 and v3.2, RHEL5.7 and RHEL5.8, and RHEL6.2 and RHEL6.3.
I'm still poking about to see if I can figure out which patch that is so I can better have a guess at which subsystem.
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 55651] Non-atomic short write problem with O_APPEND
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=55651
Quentin Barnes <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #96041|0 |1
is obsolete| |
--- Comment #2 from Quentin Barnes <[email protected]> 2013-03-27 18:40:35 --- Created an attachment (id=96411)
--> (https://bugzilla.kernel.org/attachment.cgi?id=96411)
Fully automatic C test for demostrating problem
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 55651] Non-atomic short write problem with O_APPEND
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=55651
Quentin Barnes <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|ext4 |VFS
Kernel Version|3.8.4 |3.9-rc4--- Comment #3 from Quentin Barnes <[email protected]> 2013-03-27 18:46:35 --- I tracked the problem down to the specific patch a50527b1.
Since now I know the problem is not specific to ext[34], I'm updating the ticket to be the VFS layer. (HOWEVER, Bugzilla won't let me change the assignee to [email protected]. Can someone do that for me?)
With the patch in place (even up to and including 3.9-rc4), the attached test (mlt-auto.c) fails.
If I git revert a50527b1 out of 3.9-rc4, the test passes.
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.
[Bug 55651] Non-atomic short write problem with O_APPEND
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=55651
Theodore Tso <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |[email protected]
AssignedTo|[email protected] |[email protected]
|g |--- Comment #4 from Theodore Tso <[email protected]> 2013-03-27 18:57:24 --- The commit in question (a50527b1) was authored by Jan Kara so I've changed the assignee of this bug to him.
Signature · 3 lines
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching the assignee of the bug.