direct write patch

Dave Dykstra dwd at
Tue Nov 13 07:02:50 EST 2001

On Mon, Nov 12, 2001 at 11:50:01AM -0800, Don Mahurin wrote:
> Perhaps, all that I need is a  "--delete-before-update" option that just
> unlinks the file before it starts to write the temp file. Then we avoid the
> possible issues that you raised.  I can still see a case where
> --direct-write may be useful (read-write file in a read-only dir),  but
> this is probably not a common situation, and I don't want to tackle those
> issues yet.

Wait, I forgot something more fundamental about the way the rsync
implementation works.  The one process on the receiver side generates
checksums, but the other one puts together pieces of the old file as well
as the pieces from the new file that get sent across the network.  If it
happens to want pieces that are earlier in the file than what is being
written, your file will be corrupted if you're overwriting it.  For
example, if it needs to move the data at the point 50K into the file
forward to the point 100K in the file, it will already have been
overwritten by the new data.

If on the other hand you use your proposed --delete-before-update option,
it won't do you any good because the operating system will not actually
delete the file until rsync closes it after it is completed, because rsync
will hold the file descriptor open the whole time.  So it won't save you
any space.

Sorry, but I don't think it's possible to do what you want and still use
the rsync algorithm.  You could probably do it in conjunction with the 
--whole-file option which turns off the rsync algorithm, but then you
give up a lot.

- Dave Dykstra

More information about the rsync mailing list