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:

  1. The write lands in the dirty buffer in RAM.
  2. An intent log record is written to the ZIL and flushed to stable storage.
  3. The caller is acknowledged.
  4. The TXG commits the dirty data to the pool.
  5. 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

Comparison

ZILSLOG
What it isPer-dataset intent log mechanismDedicated log vdev
Exists by defaultYesNo, added with zpool add ... log
LocationMain pool, or SLOG if presentDedicated device(s)
Used forReplaying acknowledged sync writes after a crashLowering sync write latency
Affects async writesNoNo
Read during normal operationNoNo

Controlling ZIL behavior

Two dataset properties decide how the ZIL and SLOG are used.

sync:

logbias:

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

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

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