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

Re: The --snaptime option



Arthur Chance wrote:
> I'm probably being stupid (not an uncommon occurrence) but I'm having
> problems understanding the use of --snaptime. Specifically, do I need it
> with ZFS snapshots, which seem to be different from UFS snapshots?

Yes.

> In search of more general enlightenment, can someone (Colin?) explain
> what the race condition is that's referred to in the manual:
> 
>>      --snaptime file
>>              (c mode only) This option MUST be specified when creating a
>>              backup from a filesystem snapshot, and file must have a
>> modifica-
>>              tion time prior to when the filesystem snapshot was created.
>>              (This is necessary to prevent races between file
>> modification and
>>              snapshot creation which could result in tarsnap failing
>> to recog-
>>              nize that a file has been modified.)
> 
> Does this imply that UFS snapshot creation isn't atomic wrt file
> modification?

It is.  Let me illustrate the issue with the following timeline:

Time		Event
----		-----
0		File is created
...
X		System clock ticks
X + 0.1		File is modified
X + 0.2		Filesystem snapshot is created
X + 0.3		File is modified again
X + 1		System clock ticks
...
X + 100		Tarsnap archives the file from the snapshot.
...
Y		Another filesystem snapshot is created
...
Y + 100		Tarsnap archives the file from the new snapshot.

When Tarsnap runs at time X + 100, it will see the version of the file as it
existed at time X + 0.2, i.e., with the modifications performed at time X + 0.1
but not the modifications performed at time X + 0.3, and with a modification
time of X.

When Tarsnap runs again at time Y + 100, it will still see a modification time
of X, so it will assume that the file hasn't changed, and it won't read the
entire file -- even though the file is in fact different, due to the changes
from time X + 0.3.

The --snaptime option allows Tarsnap to recognize situations where this might
occur and make sure that it re-reads the file rather than assuming that it
hasn't changed.

Does that make sense?

-- 
Colin Percival
Security Officer, FreeBSD | freebsd.org | The power to serve
Founder / author, Tarsnap | tarsnap.com | Online backups for the truly paranoid