Skip to content

Commit

Permalink
Don't attempt to use the portable sysctl macros
Browse files Browse the repository at this point in the history
Instead, define the FreeBSD and Linux sysctls separately.

Signed-off-by:	Alan Somers <[email protected]>
  • Loading branch information
asomers committed Jan 23, 2025
1 parent 6a214e6 commit ba180bd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
3 changes: 0 additions & 3 deletions include/os/freebsd/spl/sys/mod_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions include/sys/vdev_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions include/sys/vdev_raidz.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion module/os/freebsd/zfs/sysctl_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions module/os/linux/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
4 changes: 0 additions & 4 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
36 changes: 24 additions & 12 deletions module/zfs/vdev_raidz_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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

0 comments on commit ba180bd

Please sign in to comment.