ZFS: always use ZIL instead of memory?

Matt Churchyard matt.churchyard at userve.net
Fri Jul 11 12:35:04 UTC 2014


> Hello.
> Is it possible always use ZIL instead of memory for log write transactions
> for any write operation (sync and async)?
> I see that ZIL using only for sync operations, but I need for all write
> operation.

> Thanks a lot

ZFS never uses the ZIL *instead* of memory.

All writes, whether they are sync or async are tracked in memory, as part of the current transaction. After a certain amount of time, all those write operations in memory are committed to disk and a new transaction is started.

Because it's possible for the machine to crash while writes are still sitting in memory, ZFS also puts a copy of all sync writes in the ZIL (which should be on non-volatile storage somewhere). It does this because when the application requested that sync write, ZFS had to guarantee that the data made it to disk. There is no such promise with async writes. In normal operation ZFS still uses the in-memory copy for everything, and only reads the ZIL after a crash (in order to replay and sync writes that were lost in RAM).

If you want all writes to be written to the ZIL, regardless of whether they are sync or async, set the sync option to always on your dataset:

zfs set sync=always my/dataset

Although understand that, as explained above, all writes will still be handled in memory as normal, it's just that a copy of all writes will be also written to ZIL. The benefit of sync=always is that if the machine crashes, all writes can be recovered, not just those that were written in sync mode. Downside is that it may affect performance, especially if you don't have a fast ZIL device.

As far as I am aware, there is no way to stop ZFS using memory for the current write transaction, it's just part of how ZFS works.

Matt


More information about the freebsd-fs mailing list