Joseph Mocker wrote:
Erik Trimble wrote:


The developers can answer this definitively, but I believe the answer to your questions is NO. That is, if there is anything in the buffer waiting to be written when a snapshot request comes along, the buffer is written out so that the file is consistent with the last write(). So, snapshotting should NEVER cause a file corruption in this matter. That said, if you are doing the following:

1. App issues write() for data A
2. snapshot request
3. App issues write for data B

Then yes, the snapshot file will only contain data A, and not data B, which might lead to an inconsistency in the app's behavior, if both A and B were important to be written together.

Yes, this is what I was talking about.

But if that were the case, then the app should have written A and B atomically.

And how realistic is that? You are suggesting, for example, that every application that writes an XML file should buffer the _entire_ XML stream in memory and issue a single atomic write of that entire document. That's not realistic, and in some cases not even possible.

Otherwise, uh, we better fix sed then :-)

--joe


There is no real answer to this problem. If I have to wait for the app to issue a close() on a file before taking a copy for the snapshot, then I can wait indefinitely, and could potentially NEVER get anything for the snapshot. If I somehow manage to do some magic and set aside a copy of the file upon open(), just to put that file into a (possible) snapshot, then yes, I get a consistent file, which is out-of-date w/r/t the current one (and, kinda wrecks the concept of a snapshot being "what is there at time X"). And, as you note, if I wait for pending write() to finish before immediately taking a copy, then I run into the problem of apps possibly not leaving the file in a consistent state.

No, you won't ever have file Corruption (i.e. incomplete write() screwing the file completely), but you certainly might have file Inconsistency, which is an application problem, and not one that can be dealt with at the FileSystem level, as it requires a knowledge of what makes a "consistent" file, from the app's standpoint.

This is the exact same problem as backup software has had forever, so it is not new to snapshots. Which is why you want to take backups (and snapshots) of a quiet filesystem if at all possible.

-Erik

_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to