Paul Slootman
2012-Apr-15 11:57 UTC
Bug#666024: rsync --link-dest can incorrectly hardlink together destination files
[please Cc: 666024-forwarded at bugs.debian.org on any replies, thanks] Please see the attached Debian bug report, which includes a helpful bug-reproducing shell script; I've confirmed this still happens with 3.0.9. Paul Slootman On Tue 27 Mar 2012, Ian Jackson wrote:> Package: rsync > Version: 3.0.7-2 > > With rsync --link-dest, if two different source files (not hardlinked > to each other) are both candidates for being hardlinked from files of > the same name in the link-dest directory, both of them may be so > hardlinked. The effect is that on the destination the two files > become hardlined to each other even though they are not hardlinked > together in the source. > > I discovered this because my backup system has a stage which checks > that the generated backup directory is truly semantically identical to > the source volume. When --link-dest is used in a backup mechanism the > effect is that if files were previously hardlinks on the source > volume, but something makes them no longer hardlinks by breaking the > link and copying the contents and attributes of the file, this change > is not reflected in the backups. > > The bug can be reproduced with the attached shell script. > Run the script, and observe these lines in the output: > 1390154 4 -rw-rw-r-- 4 ian ian 9 Mar 27 22:32 ./dst/b > 1390154 4 -rw-rw-r-- 4 ian ian 9 Mar 27 22:32 ./dst/a > ... > 1390155 4 -rw-rw-r-- 1 ian ian 9 Mar 27 22:32 ./src/b > 1390152 4 -rw-rw-r-- 1 ian ian 9 Mar 27 22:32 ./src/a > You can see that the inode numbers of src/a and src/b are different, > whereas the inode numbers of dst/a and dst/b are the same. > > Thanks, > Ian. >> #!/bin/sh > set -e > rm -rf d > mkdir d > cd d > set -x > > mkdir src > echo contents >src/a > ln src/a src/b > > rsync -aH src/. linkdest > > rm src/b > cp -a src/a src/b > > rsync -aH --link-dest=`pwd`/linkdest/. src/. dst > > find -lsOn Tue 27 Mar 2012, Ian Jackson wrote:> > I wrote: > > With rsync --link-dest, if two different source files (not hardlinked > > to each other) are both candidates for being hardlinked from files of > > the same name in the link-dest directory, both of them may be so > > hardlinked. The effect is that on the destination the two files > > become hardlined to each other even though they are not hardlinked > > together in the source. > > That's garbled. I meant: > > With rsync --link-dest, if two different source files (not hardlinked > to each other) have identical contents and are both candidates for > being hardlinked from files of their respective names in the link-dest > directory, and the link-dest files are hardlinks to each other, rsync > may wrongly make the two destination files hardlinks to each other. > > Hopefully the test case script made this clear. > > Ian.
Apparently Analagous Threads
- DO NOT REPLY [Bug 3693] New: rsync can use same --link-dest file several times, leading to incorrect hard links
- --link-dest copying modified files
- rsync mirroring and hardlink issues
- [Bug 10334] New: rsync doesn't log hardlink-copies using --link-dest
- TODO hardlink performance optimizations