cyberjock said:
So this is where things get *really* messy. After tons of research I'm convinced that doing NFS with sync=disabled is about the same danger level as using iSCSI with sync=standard or sync=disabled. Also, if you want to use iSCSI with approximately(keyword: approximately) the same level of protection as NFS with its sync writes, then you must set sync=enabled when using iSCSI. The reason for the "approximately" is that iSCSI may internally return the write as complete to the iSCSI initiator *before* issuing the write to ZFS. So there may be a chance that you could lose data even with sync=enabled. Keep in mind that in a properly operating system we are talking fractions of a millisecond, but that is the "write hole" that ZFS is supposed to prevent. But its still not quite the same as using NFS with sync writes. The safest is to use NFS with its sync writes.
There's 2 things to realize about the sync=disabled situation:
1. This will tell the system to never honor sync writes(this is obviously not recommended, but you may want to take that risk). If you have other services that are dependent on that sync write being honored and performed, you may be in for serious trouble.
2. There is no significant possibility of harm to the pool if you recognize that every write to the file system is an atomic write. That is to say that any single write to the file system either hasn't been performed or has been performed and completed. There is no such thing as a "partial" transaction. ZFS will automatically discard any incomplete transaction when the pool is remounted after a "partial" transaction. Obviously if ZFS discards a partial transaction then that data is lost.
So, if so many people are using sync=standard with iSCSI and not having problems, why am I hesitant to turn around and start recommending setting sync=disabled? I just said they are the same thing, right?
Excellent post, although I have a few extra remarks of my own:
Assuming that ESXi's implementation is sane; using "sync=standard" with iSCSI should be a bit safer than using "sync=disabled" with either iSCSI or NFS.
Let me try to explain my reasoning!
SCSI/SATA (and iSCSI) actually does provide the ability to perform non-cached writes through a Force Unit Access flag, but what usually ends up happening on consumer grade hardware is that they cheat and ignores it for the sake of performance. I had a brief look at the istgt sources at Google Code (hopefully not too different from the one used by FreeNAS) and it seems to me like istgt ignores it too.
But fortunately for us, it's a situation that modern OS makers are taking into account and compensating for. Newer versions of Windows will for example issue a full blown Sync/Flush after these writes and which are honored. The most logical way for ESXi to handle iSCSI is simply to forward all commands to the target, and istgt seems to respond to that with a fsync.
So iSCSI with "sync=standard" should therefore from a "successful writes are lost after a power outage" point-of-view be no more dangerous than using regular consumer grade HDDs in your ZFS pool.
What about "sync=disabled"?
Well, that's telling ZFS to also ignore the follow-up flush from the VM so all bets are really off... :)
TL;DR: iSCSI with "sync=standard" is the way to go (unless you are super paranoid or super lucky).