[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rsync link corruption with -H and --link-dest



On Sun, Nov 22, 2020 at 04:43:21AM +0000, Gareth Evans wrote:
> Hi all,
> 
> I have asked this question on both the rsync mailing list and serverfault.com but got no response from either.

Please, don't hijack threads.

> I would be grateful, if this isn't too off-topic, if anyone could explain the following:
> 
> man rsync for -H includes:
> 
> "If you specify a --link-dest directory that contains hard links, the linking of the destination files against the --link-dest files can cause some paths in the destination to become linked together due to the --link-dest associations."
> 
> How and/or why does this happen?  What sort of scenario might lead to it?

The way I understand it is this:

Suppose whithin --link-dest, files A and B are hard-linked together.

Now suppose you have two files in your source, say A' and B', with
equal content to A and B (and thus equal themselves, but /not/ linked).
You rsync with --link-dest and with -H. 

Now due to --link-dest, rsync sees "ah, A' == A, so I'll create
A'' on dest hard linked to A'...". Same goes with B and its kin.

Now you end up with two files A'' and B'' on dest which are hard
linked to A' and B' on link-dest which are hard linked together.

Due to how hard links work (they are all just directory entries
pointing all to the same i-node), A'' and B'' are hard linked
together.

Somewhat contradicting your expectation set by -H (preserve hard
links), since the sources A and B had equal content but weren't
hard linked.

This is all, of course, a hunch, and should be backed (or falsified)
by code study and/or experimental evidence, which is left as an
exercise for the reader ;-)

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


Reply to: