ZIL and SLOG in ZFS
The ZIL and the SLOG are not alternatives. The ZIL (ZFS Intent Log) is a mechanism. The SLOG (separate log device) is a place to store it. Every ZFS pool has a ZIL; a SLOG is an optional dedicated vdev that holds the ZIL's blocks instead of the main pool vdevs.
What the ZIL does
ZFS acknowledges asynchronous writes as soon as the data is in RAM and flushes it to the pool in transaction groups (TXGs), by default every 5 seconds (zfs_txg_timeout). That is unsafe for applications that need a write to be durable when the call returns: fsync(), O_SYNC/O_DSYNC opens, synchronous NFS commits, database WAL flushes.
For those operations, ZFS writes an intent record describing the change to the ZIL and acknowledges the caller once that record is on stable storage. The actual data still goes to its final location with the next TXG. The sequence for a sync write:
- The write lands in the dirty buffer in RAM.
- An intent log record is written to the ZIL and flushed to stable storage.
- The caller is acknowledged.
- The TXG commits the dirty data to the pool.
- The ZIL records for that TXG are discarded.
The ZIL is write-only during normal operation. It is read only after a crash or unclean export, when ZFS replays records that were acknowledged but not yet committed in a TXG. Asynchronous writes never touch the ZIL.
What the SLOG does
Without a SLOG, ZIL blocks are allocated from the main pool. A sync write is then written twice to the same disks: once as a log record and again at TXG commit. The log writes are small, latency-bound, and interleaved with normal pool I/O, which is the worst case for HDD vdevs.
A SLOG moves the log writes to a dedicated low-latency device. Sync write latency becomes the SLOG's flush latency, not the pool's. Pool vdevs only see the TXG writes.
zpool add tank log mirror /dev/disk/by-id/nvme-A /dev/disk/by-id/nvme-B
zpool remove tank mirror-1 # log vdevs can be removed online
zpool iostat -v tank 1 # log device activity shown separately
What a SLOG is not
- Not a write cache. Data is never read back from the SLOG in normal operation. Sustained throughput is still limited by how fast the pool can absorb TXGs.
- Not a read cache. That is L2ARC.
- No effect on async workloads. If nothing issues sync writes, the SLOG sits idle.
Comparison
| ZIL | SLOG | |
|---|---|---|
| What it is | Per-dataset intent log mechanism | Dedicated log vdev |
| Exists by default | Yes | No, added with zpool add ... log |
| Location | Main pool, or SLOG if present | Dedicated device(s) |
| Used for | Replaying acknowledged sync writes after a crash | Lowering sync write latency |
| Affects async writes | No | No |
| Read during normal operation | No | No |
Controlling ZIL behavior
Two dataset properties decide how the ZIL and SLOG are used.
sync:
standard(default): honor sync requests from the application.always: treat every write as synchronous. Maximum durability, maximum load on the ZIL.disabled: ignore sync requests and never use the ZIL. Sync calls return immediately. A crash or power loss discards up to several seconds of writes the application believed were durable. The pool stays consistent, but application-level guarantees (databases, NFS clients) are broken.
logbias:
latency(default): log writes go to the SLOG if one exists.throughput: skip the SLOG and write data blocks directly to the pool, logging only a pointer. Useful for large sequential sync writes where the SLOG would be a bottleneck, such as some database data files.
Without a SLOG and under logbias=latency, writes at or above zfs_immediate_write_sz (32 KiB by default) are also written directly to the pool with a pointer logged, to avoid the double write.
zfs get sync,logbias tank/dataset
zfs set sync=always tank/vmstore
zfs set logbias=throughput tank/db-data
When a SLOG helps
- NFS exports with sync semantics (including ESXi datastores).
- Databases that call
fsync()on every commit. - VM disks on zvols or files with sync enabled.
- iSCSI targets with write-through semantics.
It helps most when the pool is HDD-based. If the pool is already all NVMe with similar latency, a SLOG adds little or nothing, and a slower SLOG than the pool makes sync writes worse.
Before buying hardware, check that sync writes actually occur. On Linux, the counters in /proc/spl/kstat/zfs/zil show commit and record counts. Watch zil_commit_count under load; if it barely moves, a SLOG will not help.
Device requirements
- Power-loss protection. A sync write is only acknowledged after the device reports it durable. Consumer SSDs without PLP either flush slowly or acknowledge writes still sitting in volatile cache. The latter silently defeats the purpose of the ZIL.
- Low write latency at queue depth 1. Sync writes from a single thread are serialized by the flush, so IOPS at high queue depth is irrelevant. Latency is what matters.
- Endurance. Every sync write passes through the SLOG. Use a device rated for sustained writes, or over-provision a larger device.
- Small capacity is sufficient. The SLOG only holds records for TXGs that have not yet committed, bounded by dirty data (
zfs_dirty_data_max, 10% of RAM up to 4 GiB by default) and roughly 2 to 3 TXG intervals of sync ingest. A few GB to a few tens of GB is enough in nearly all cases.
Redundancy and failure
If the SLOG fails while the system is running, ZFS falls back to the in-pool ZIL. No data is lost, because the data is still in RAM and commits with the next TXG. Performance drops to the no-SLOG level.
Data loss requires the SLOG to fail or disappear and the system to crash before the affected TXG commits. In that case, the pool imports without the log records (zpool import -m is required if the log device is missing), and the last acknowledged sync writes are lost. The pool itself remains consistent.
Mirroring the SLOG closes that window. For workloads where losing the last few seconds of acknowledged sync writes is unacceptable, mirror it. Striping across multiple log vdevs adds no resilience and is rarely worthwhile.
Summary
- The ZIL exists on every pool and provides durability for sync writes. It is not a cache.
- A SLOG is the ZIL moved to a faster device. It reduces sync write latency only.
- Use a SLOG when the workload is sync-heavy and the pool is slower than the log device.
- Use a PLP-protected, low-latency, high-endurance device, and mirror it if the last few seconds of sync writes matter.
- Do not use
sync=disabledas a substitute unless you accept losing acknowledged writes.