Test case for hard link failure

Pete Wenzel pmwenzel at yahoo.com
Wed Nov 26 10:30:53 EST 2003


The rsync 2.5.6 TODO file mentions the need for hard link test cases. 
Here is one in which a linked file is unnecessarily transferred in full.

   # Setup initial directories
   mkdir src dest
   dd if=/dev/zero bs=1024 count=10000 of=src/a 2>/dev/null
   rsync -a src/. dest/.
   ln src/a src/b
   # At this point, a & b exist in src; only a exists in dest.
   rsync -aHv src/. dest/.
   building file list ... done
   ./
   b => a
   wrote 78 bytes  read 20 bytes  196.00 bytes/sec
   total size is 20480000  speedup is 208979.59

The above is GOOD behavior; only the file metadata was transferred, and 
the link was made in dest, as expected.

Now try the failure case:

   # Setup initial directories
   rm dest/a
   # At this point, a & b exist in src; only b exists in dest.
   rsync -aHv src/. dest/.
   building file list ... done
   ./
   a
   b => a
   wrote 10241366 bytes  read 36 bytes  6827601.33 bytes/sec
   total size is 20480000  speedup is 2.00

The above is BAD (nonoptimal) behavior; the entire file is transferred, 
even though it could simply have been linked.  It seems that "a" is 
transferred before it is determined that a suitable equivalent (linked) 
file "b" already exists.

I suspect that this has to do with handling the file list in a sorted 
order; when the missing filename is encountered first, it is transferred 
in full.  Not being familiar with the rsync protocol or source code, I 
can't say whether this should be fixed on the client or server side.

--Pete




More information about the rsync mailing list