From ba180bdbe09dab24b44a8945320225991a2c194d Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 23 Jan 2025 16:14:02 -0700 Subject: [PATCH] Don't attempt to use the portable sysctl macros Instead, define the FreeBSD and Linux sysctls separately. Signed-off-by: Alan Somers --- include/os/freebsd/spl/sys/mod_os.h | 3 --- include/sys/vdev_impl.h | 2 -- include/sys/vdev_raidz.h | 5 +--- module/os/freebsd/zfs/sysctl_os.c | 8 ++++++- module/os/linux/zfs/vdev_disk.c | 9 -------- module/zfs/vdev.c | 4 ---- module/zfs/vdev_raidz_math.c | 36 +++++++++++++++++++---------- 7 files changed, 32 insertions(+), 35 deletions(-) diff --git a/include/os/freebsd/spl/sys/mod_os.h b/include/os/freebsd/spl/sys/mod_os.h index 1479242de53b..df7be6fc13f6 100644 --- a/include/os/freebsd/spl/sys/mod_os.h +++ b/include/os/freebsd/spl/sys/mod_os.h @@ -94,9 +94,6 @@ #define param_set_max_auto_ashift_args(var) \ CTLTYPE_UINT, NULL, 0, param_set_max_auto_ashift, "IU" -#define param_set_raidz_impl_args(var) \ - CTLTYPE_STRING, NULL, 0, param_set_raidz_impl, "A" - #define spa_taskq_read_param_set_args(var) \ CTLTYPE_STRING, NULL, 0, spa_taskq_read_param, "A" diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h index 46ca2859f991..abd66b8abc96 100644 --- a/include/sys/vdev_impl.h +++ b/include/sys/vdev_impl.h @@ -62,7 +62,6 @@ struct abd; extern uint_t zfs_vdev_queue_depth_pct; extern uint_t zfs_vdev_def_queue_depth; extern uint_t zfs_vdev_async_write_max_active; -extern const char *zfs_vdev_raidz_impl; /* * Virtual device operations @@ -646,7 +645,6 @@ extern int vdev_obsolete_counts_are_precise(vdev_t *vd, boolean_t *are_precise); int vdev_checkpoint_sm_object(vdev_t *vd, uint64_t *sm_obj); void vdev_metaslab_group_create(vdev_t *vd); uint64_t vdev_best_ashift(uint64_t logical, uint64_t a, uint64_t b); -int param_set_raidz_impl(ZFS_MODULE_PARAM_ARGS); /* * Vdev ashift optimization tunables diff --git a/include/sys/vdev_raidz.h b/include/sys/vdev_raidz.h index e8af9f3715f1..b50bee946158 100644 --- a/include/sys/vdev_raidz.h +++ b/include/sys/vdev_raidz.h @@ -66,17 +66,14 @@ extern const zio_vsd_ops_t vdev_raidz_vsd_ops; /* * vdev_raidz_math interface */ -#if defined(__linux__) -extern const char *zfs_vdev_raidz_impl; -#endif void vdev_raidz_math_init(void); void vdev_raidz_math_fini(void); const struct raidz_impl_ops *vdev_raidz_math_get_ops(void); int vdev_raidz_math_generate(struct raidz_map *, struct raidz_row *); int vdev_raidz_math_reconstruct(struct raidz_map *, struct raidz_row *, const int *, const int *, const int); -int vdev_raidz_impl_set(const char *); int vdev_raidz_impl_get(char *buffer, size_t size); +int vdev_raidz_impl_set(const char *); typedef struct vdev_raidz_expand { uint64_t vre_vdev_id; diff --git a/module/os/freebsd/zfs/sysctl_os.c b/module/os/freebsd/zfs/sysctl_os.c index 0be71ffce022..109af1d6f6e8 100644 --- a/module/os/freebsd/zfs/sysctl_os.c +++ b/module/os/freebsd/zfs/sysctl_os.c @@ -679,7 +679,7 @@ param_set_deadman_failmode(SYSCTL_HANDLER_ARGS) return (-param_set_deadman_failmode_common(buf)); } -int +static int param_set_raidz_impl(SYSCTL_HANDLER_ARGS) { char *buf; @@ -808,6 +808,12 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, validate_skip, /* vdev_mirror.c */ +/* vdev_raidz_math.c */ + +SYSCTL_PROC(_vfs_zfs_vdev, OID_AUTO, raidz_impl, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + NULL, 0, param_set_raidz_impl, "IU", "select RAIDZ implementation"); + /* vdev_queue.c */ extern uint_t zfs_vdev_max_active; diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index 8f464bb9de9e..e8bd513e6909 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -1637,15 +1637,6 @@ param_set_max_auto_ashift(const char *buf, zfs_kernel_param_t *kp) return (0); } -int -param_set_raidz_impl(const char *val, zfs_kernel_param_t *kp) -{ - int error; - - error = vdev_raidz_impl_set(val); - return (error); -} - ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, open_timeout_ms, UINT, ZMOD_RW, "Timeout before determining that a device is missing"); diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 438b849ff704..5df2f77e5780 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -6580,7 +6580,3 @@ ZFS_MODULE_PARAM_CALL(zfs_vdev, zfs_vdev_, max_auto_ashift, param_set_max_auto_ashift, param_get_uint, ZMOD_RW, "Maximum ashift used when optimizing for logical -> physical sector " "size on new top-level vdevs"); - -ZFS_MODULE_PARAM_CALL(zfs_vdev, zfs_vdev_, raidz_impl, - param_set_raidz_impl, param_get_charp, ZMOD_RW, - "RAIDZ implementation"); diff --git a/module/zfs/vdev_raidz_math.c b/module/zfs/vdev_raidz_math.c index 6eb017c29c25..b2eea4c083be 100644 --- a/module/zfs/vdev_raidz_math.c +++ b/module/zfs/vdev_raidz_math.c @@ -81,11 +81,8 @@ static boolean_t raidz_math_initialized = B_FALSE; #define RAIDZ_IMPL_READ(i) (*(volatile uint32_t *) &(i)) -static uint32_t zfs_vdev_raidz_impl_setting = IMPL_SCALAR; +static uint32_t zfs_vdev_raidz_impl = IMPL_SCALAR; static uint32_t user_sel_impl = IMPL_FASTEST; -#if defined(__linux__) -const char *zfs_vdev_raidz_impl = "fastest"; -#endif /* Hold all supported implementations */ static size_t raidz_supp_impl_cnt = 0; @@ -114,7 +111,7 @@ vdev_raidz_math_get_ops(void) return (&vdev_raidz_scalar_impl); raidz_impl_ops_t *ops = NULL; - const uint32_t impl = RAIDZ_IMPL_READ(zfs_vdev_raidz_impl_setting); + const uint32_t impl = RAIDZ_IMPL_READ(zfs_vdev_raidz_impl); switch (impl) { case IMPL_FASTEST: @@ -543,7 +540,7 @@ vdev_raidz_math_init(void) #endif /* Finish initialization */ - atomic_swap_32(&zfs_vdev_raidz_impl_setting, user_sel_impl); + atomic_swap_32(&zfs_vdev_raidz_impl, user_sel_impl); raidz_math_initialized = B_TRUE; } @@ -582,7 +579,7 @@ static const struct { * If we are called before init(), user preference will be saved in * user_sel_impl, and applied in later init() call. This occurs when module * parameter is specified on module load. Otherwise, directly update - * zfs_vdev_raidz_impl_setting. + * zfs_vdev_raidz_impl. * * @val Name of raidz implementation to use * @param Unused. @@ -628,12 +625,9 @@ vdev_raidz_impl_set(const char *val) if (err == 0) { if (raidz_math_initialized) - atomic_swap_32(&zfs_vdev_raidz_impl_setting, impl); + atomic_swap_32(&zfs_vdev_raidz_impl, impl); else atomic_swap_32(&user_sel_impl, impl); -#if defined(__linux__) - zfs_vdev_raidz_impl = raidz_supp_impl[i]->name; -#endif } return (err); @@ -646,7 +640,7 @@ vdev_raidz_impl_get(char *buffer, size_t size) { int i, cnt = 0; char *fmt; - const uint32_t impl = RAIDZ_IMPL_READ(zfs_vdev_raidz_impl_setting); + const uint32_t impl = RAIDZ_IMPL_READ(zfs_vdev_raidz_impl); ASSERT(raidz_math_initialized); @@ -668,3 +662,21 @@ vdev_raidz_impl_get(char *buffer, size_t size) } #endif + +#if defined(_KERNEL) && defined(__linux__) +static int +zfs_vdev_raidz_impl_set(const char *val, zfs_kernel_param_t *kp) +{ + return (vdev_raidz_impl_set(val)); +} + +static int +zfs_vdev_raidz_impl_get(char *buffer, zfs_kernel_param_t *kp) +{ + return (vdev_raidz_impl_get(buffer, PAGE_SIZE)); +} + +module_param_call(zfs_vdev_raidz_impl, zfs_vdev_raidz_impl_set, + zfs_vdev_raidz_impl_get, NULL, 0644); +MODULE_PARM_DESC(zfs_vdev_raidz_impl, "Select raidz implementation."); +#endif