From e945e8d7f4fcafd4f1c01abd90810fc09ab6a811 Mon Sep 17 00:00:00 2001 From: Allan Jude Date: Mon, 16 Aug 2021 11:35:19 -0400 Subject: Restore FreeBSD sysctl processing for arc.min and arc.max Before OpenZFS 2.0, trying to set the FreeBSD sysctl vfs.zfs.arc_max to a disallowed value would return an error. Since the switch, it instead only generates WARN_IF_TUNING_IGNORED Keep the ability to set the sysctl's specifically to 0, even though that is less than the minimum, because some tests depend on this. Also lost, was the ability to set vfs.zfs.arc_max to a value less than the default vfs.zfs.arc_min at boot time. Restore this as well. Reviewed-by: Tony Nguyen Reviewed-by: Ryan Moeller Signed-off-by: Allan Jude Closes #12161 --- include/os/freebsd/spl/sys/mod_os.h | 6 ++++++ include/sys/arc.h | 7 +++++++ include/sys/arc_impl.h | 2 ++ 3 files changed, 15 insertions(+) (limited to 'include') diff --git a/include/os/freebsd/spl/sys/mod_os.h b/include/os/freebsd/spl/sys/mod_os.h index 5b3b3271e..5695abee7 100644 --- a/include/os/freebsd/spl/sys/mod_os.h +++ b/include/os/freebsd/spl/sys/mod_os.h @@ -62,6 +62,12 @@ #define param_set_arc_long_args(var) \ CTLTYPE_ULONG, &var, 0, param_set_arc_long, "LU" +#define param_set_arc_min_args(var) \ + CTLTYPE_ULONG, &var, 0, param_set_arc_min, "LU" + +#define param_set_arc_max_args(var) \ + CTLTYPE_ULONG, &var, 0, param_set_arc_max, "LU" + #define param_set_arc_int_args(var) \ CTLTYPE_INT, &var, 0, param_set_arc_int, "I" diff --git a/include/sys/arc.h b/include/sys/arc.h index 20fa47bd9..afbe65bb1 100644 --- a/include/sys/arc.h +++ b/include/sys/arc.h @@ -46,6 +46,13 @@ extern "C" { */ #define ARC_EVICT_ALL UINT64_MAX +/* + * ZFS gets very unhappy when the maximum ARC size is smaller than the maximum + * block size and a larger block is written. To leave some safety margin, we + * limit the minimum for zfs_arc_max to the maximium transaction size. + */ +#define MIN_ARC_MAX DMU_MAX_ACCESS + #define HDR_SET_LSIZE(hdr, x) do { \ ASSERT(IS_P2ALIGNED(x, 1U << SPA_MINBLOCKSHIFT)); \ (hdr)->b_lsize = ((x) >> SPA_MINBLOCKSHIFT); \ diff --git a/include/sys/arc_impl.h b/include/sys/arc_impl.h index f99d2911b..89be78ce2 100644 --- a/include/sys/arc_impl.h +++ b/include/sys/arc_impl.h @@ -1004,6 +1004,8 @@ extern void arc_unregister_hotplug(void); extern int param_set_arc_long(ZFS_MODULE_PARAM_ARGS); extern int param_set_arc_int(ZFS_MODULE_PARAM_ARGS); +extern int param_set_arc_min(ZFS_MODULE_PARAM_ARGS); +extern int param_set_arc_max(ZFS_MODULE_PARAM_ARGS); /* used in zdb.c */ boolean_t l2arc_log_blkptr_valid(l2arc_dev_t *dev, -- cgit v1.2.3