mv for symlinks on dapper is not atomic

Bug #262811 reported by Mark Painter
10
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Fix Released
Medium
Unassigned
Dapper
Fix Released
Undecided
Martin Pitt
Hardy
Fix Released
Undecided
Unassigned
Intrepid
Fix Released
Medium
Unassigned

Bug Description

This is fixed in newer versions of coreutils, eg those used in hardy. Attached is a minimal debdiff that makes mv for symlinks atomic in dapper's coreutils

Revision history for this message
Mark Painter (mpainter) wrote :
Revision history for this message
Mark Painter (mpainter) wrote :

See also http://<email address hidden>/msg12594.html

Revision history for this message
Mark Painter (mpainter) wrote :

Currently, mv may not be atomic. Atomic mv of symlinks is necessary for doing things like updating a symlink while ensuring the symlink always exists. Consider the case of a server that knows what directory is live via a symlink.

Upstream have removed the unlink for all moves, and this updated coreutils is in current development (and hardy).

TEST CASE: mv a symlink. The unlink syscall should not be triggered.

There is no expected regression with this patch.

Revision history for this message
C de-Avillez (hggdh2) wrote :

marking as triaged, medium importance. Dapper is LTS.

Changed in coreutils:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Martin Pitt (pitti) wrote :

This doesn't seem to be fixed in Intrepid either. The patch on the upstream ML isn't applied to the intrepid version.

Mark, your attached dapper patch seems to be pretty much exactly backwards to the upstream posted one. I don't understand the patch yet, that needs some closer investigation before I can judge in a qualified way, but that jumped into my eye.

Changed in coreutils:
assignee: nobody → pitti
status: Triaged → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Ah, you talk about symlinks, while the referenced mail talks about hardlinks. That's where my initial confusion came from.

I confirm that mv is not atomic in dapper, hardy and intrepid when using hardlinks:

$ echo foo >foo; echo bar > bar; ln foo foo.backup
$ strace mv bar foo
[...]
access("foo", W_OK) = 0
unlink("foo") = 0
rename("bar", "foo") = 0
[...]

As for symlinks, I used this test case:

$ rm -f *; ln -s file1 link; ln -s file2 link.new; strace -e access,rename,unlink mv link.new link

In Hardy and Intrepid I get the correct behaviour:

rename("link.new", "link") = 0

while in Dapper I get:

unlink("link") = 0
rename("link.new", "link") = 0

I checked the intrepid sources, and this is covered by tests/mv/atomic (with pretty much the same approach).

Revision history for this message
Martin Pitt (pitti) wrote :

So for symlinks this is confirmed fixed in hardy and intrepid.

Changed in coreutils:
assignee: pitti → nobody
status: In Progress → Fix Released
status: New → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :
Changed in coreutils:
assignee: nobody → pitti
status: New → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Dapper update uploaded, waiting in SRU queue for approval.

Revision history for this message
Steve Langasek (vorlon) wrote :

Ok for SRU, however:

Running: "accept coreutils"
Accepting ubuntu/dapper-proposed (UNAPPROVED) 1/1
---------------------------------------------------------------------------
Accepting coreutils
** coreutils could not be accepted due to The source coreutils - 5.93-5ubuntu5 is already accepted in ubuntu/edgy and you cannot upload the same version within the same distribution. You have to modify the source version and re-upload.
---------------------------------------------------------------------------

Please reupload with a distinct version number.

Revision history for this message
Martin Pitt (pitti) wrote :

Accepted into dapper-proposed, please test and give feedback here. Please see https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in coreutils:
status: In Progress → Fix Committed
Revision history for this message
Mark Painter (mpainter) wrote :

I've installed the proposed coreutils, and can verify that mv is atomic for me now.

Revision history for this message
Martin Pitt (pitti) wrote :

Copied to dapper-updates.

Changed in coreutils:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.