kern/189865: zfs_dirty_data_max{, _max, _percent} not exported as loader tunables

Nathaniel Filardo nwf at
Fri May 16 16:10:02 UTC 2014

>Number:         189865
>Category:       kern
>Synopsis:       zfs_dirty_data_max{,_max,_percent} not exported as loader tunables
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 16 16:10:01 UTC 2014
>Originator:     Nathaniel Filardo
>Release:        9.2-STABLE
FreeBSD 9.2-STABLE FreeBSD 9.2-STABLE #132 9089443-dirty: Wed Apr 30 22:02:57 EDT 2014     root at  sparc64

On machines with gobs of RAM, zfs_dirty_data_max is zfs_dirty_data_max_percent (i.e. 10) percent of memory or zfs_dirty_data_max_max (ie 4G) which may take tens of minutes to sync to disk, especially if data is spread out across the disk, during which time any program that attempts to write to disk eventually stalls because there are at most three txgs pending.  It would be nice to limit transactions to something smaller so that these latency spikes go away.

I think something like the following (compiled but untested) patch would do the trick?

diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
index 9fe1961..f5aa000 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
@@ -132,6 +132,22 @@ uint64_t zfs_delay_scale = 1000 * 1000 * 1000 / 2000;
+TUNABLE_INT("vfs.zfs.dirty_data_max_percent", &zfs_dirty_data_max_percent);
+SYSCTL_INT(_vfs_zfs, OID_AUTO, dirty_data_max_percent, CTLFLAG_RDTUN,
+    &zfs_dirty_data_max_percent, 0,
+    "Maximum percent of physical memory allocated to dirty data");
+TUNABLE_QUAD("vfs.zfs.dirty_data_max", &zfs_dirty_data_max);
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max, CTLFLAG_RDTUN,
+    &zfs_dirty_data_max, 0,
+    "Force a txg if dirty buffers exceed this value (bytes)");
+TUNABLE_QUAD("vfs.zfs.dirty_data_max_max", &zfs_dirty_data_max_max);
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max_max, CTLFLAG_RDTUN,
+    &zfs_dirty_data_max_max, 0,
+    "Limit dirty_data_max when using dirty_data_max_percent");
 #if 0
 TUNABLE_INT("vfs.zfs.no_write_throttle", &zfs_no_write_throttle);
 SYSCTL_INT(_vfs_zfs, OID_AUTO, no_write_throttle, CTLFLAG_RDTUN,


More information about the freebsd-bugs mailing list