mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-06 08:10:25 +03:00
FreeBSD: Implement sysctl for fletcher4 impl
There is a tunable to select the fletcher 4 checksum implementation on Linux but it was not present in FreeBSD. Implement the sysctl handler for FreeBSD and use ZFS_MODULE_PARAM_CALL to provide the tunable on both platforms. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #11270
This commit is contained in:
parent
21adfb031c
commit
8847b06bf6
@ -57,6 +57,8 @@
|
|||||||
#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, func, _, perm, desc) \
|
#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, func, _, perm, desc) \
|
||||||
ZFS_MODULE_PARAM_CALL_IMPL(_vfs_ ## scope_prefix, name, perm, func ## _args(name_prefix ## name), desc)
|
ZFS_MODULE_PARAM_CALL_IMPL(_vfs_ ## scope_prefix, name, perm, func ## _args(name_prefix ## name), desc)
|
||||||
|
|
||||||
|
#define ZFS_MODULE_VIRTUAL_PARAM_CALL ZFS_MODULE_PARAM_CALL
|
||||||
|
|
||||||
#define param_set_arc_long_args(var) \
|
#define param_set_arc_long_args(var) \
|
||||||
CTLTYPE_ULONG, &var, 0, param_set_arc_long, "LU"
|
CTLTYPE_ULONG, &var, 0, param_set_arc_long, "LU"
|
||||||
|
|
||||||
@ -84,6 +86,9 @@
|
|||||||
#define param_set_max_auto_ashift_args(var) \
|
#define param_set_max_auto_ashift_args(var) \
|
||||||
CTLTYPE_U64, &var, 0, param_set_max_auto_ashift, "QU"
|
CTLTYPE_U64, &var, 0, param_set_max_auto_ashift, "QU"
|
||||||
|
|
||||||
|
#define fletcher_4_param_set_args(var) \
|
||||||
|
CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"
|
||||||
|
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#define module_init(fn) \
|
#define module_init(fn) \
|
||||||
static void \
|
static void \
|
||||||
|
@ -143,6 +143,17 @@ enum scope_prefix_types {
|
|||||||
MODULE_PARM_DESC(name_prefix ## name, desc)
|
MODULE_PARM_DESC(name_prefix ## name, desc)
|
||||||
/* END CSTYLED */
|
/* END CSTYLED */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As above, but there is no variable with the name name_prefix ## name,
|
||||||
|
* so NULL is passed to module_param_call instead.
|
||||||
|
*/
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
|
#define ZFS_MODULE_VIRTUAL_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
|
||||||
|
CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
|
||||||
|
module_param_call(name_prefix ## name, setfunc, getfunc, NULL, perm); \
|
||||||
|
MODULE_PARM_DESC(name_prefix ## name, desc)
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
#define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp
|
#define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp
|
||||||
|
|
||||||
#define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s)
|
#define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s)
|
||||||
|
@ -885,23 +885,26 @@ zio_abd_checksum_func_t fletcher_4_abd_ops = {
|
|||||||
.acf_iter = abd_fletcher_4_iter
|
.acf_iter = abd_fletcher_4_iter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(_KERNEL)
|
||||||
|
|
||||||
#if defined(_KERNEL) && defined(__linux__)
|
#define IMPL_FMT(impl, i) (((impl) == (i)) ? "[%s] " : "%s ")
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fletcher_4_param_get(char *buffer, zfs_kernel_param_t *unused)
|
fletcher_4_param_get(char *buffer, zfs_kernel_param_t *unused)
|
||||||
{
|
{
|
||||||
const uint32_t impl = IMPL_READ(fletcher_4_impl_chosen);
|
const uint32_t impl = IMPL_READ(fletcher_4_impl_chosen);
|
||||||
char *fmt;
|
char *fmt;
|
||||||
int i, cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
/* list fastest */
|
/* list fastest */
|
||||||
fmt = (impl == IMPL_FASTEST) ? "[%s] " : "%s ";
|
fmt = IMPL_FMT(impl, IMPL_FASTEST);
|
||||||
cnt += sprintf(buffer + cnt, fmt, "fastest");
|
cnt += sprintf(buffer + cnt, fmt, "fastest");
|
||||||
|
|
||||||
/* list all supported implementations */
|
/* list all supported implementations */
|
||||||
for (i = 0; i < fletcher_4_supp_impls_cnt; i++) {
|
for (uint32_t i = 0; i < fletcher_4_supp_impls_cnt; ++i) {
|
||||||
fmt = (i == impl) ? "[%s] " : "%s ";
|
fmt = IMPL_FMT(impl, i);
|
||||||
cnt += sprintf(buffer + cnt, fmt,
|
cnt += sprintf(buffer + cnt, fmt,
|
||||||
fletcher_4_supp_impls[i]->name);
|
fletcher_4_supp_impls[i]->name);
|
||||||
}
|
}
|
||||||
@ -915,14 +918,62 @@ fletcher_4_param_set(const char *val, zfs_kernel_param_t *unused)
|
|||||||
return (fletcher_4_impl_set(val));
|
return (fletcher_4_impl_set(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <sys/sbuf.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
fletcher_4_param(ZFS_MODULE_PARAM_ARGS)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (req->newptr == NULL) {
|
||||||
|
const uint32_t impl = IMPL_READ(fletcher_4_impl_chosen);
|
||||||
|
const int init_buflen = 64;
|
||||||
|
const char *fmt;
|
||||||
|
struct sbuf *s;
|
||||||
|
|
||||||
|
s = sbuf_new_for_sysctl(NULL, NULL, init_buflen, req);
|
||||||
|
|
||||||
|
/* list fastest */
|
||||||
|
fmt = IMPL_FMT(impl, IMPL_FASTEST);
|
||||||
|
(void) sbuf_printf(s, fmt, "fastest");
|
||||||
|
|
||||||
|
/* list all supported implementations */
|
||||||
|
for (uint32_t i = 0; i < fletcher_4_supp_impls_cnt; ++i) {
|
||||||
|
fmt = IMPL_FMT(impl, i);
|
||||||
|
(void) sbuf_printf(s, fmt,
|
||||||
|
fletcher_4_supp_impls[i]->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = sbuf_finish(s);
|
||||||
|
sbuf_delete(s);
|
||||||
|
|
||||||
|
return (err);
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
|
err = sysctl_handle_string(oidp, buf, sizeof (buf), req);
|
||||||
|
if (err)
|
||||||
|
return (err);
|
||||||
|
return (-fletcher_4_impl_set(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef IMPL_FMT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Choose a fletcher 4 implementation in ZFS.
|
* Choose a fletcher 4 implementation in ZFS.
|
||||||
* Users can choose "cycle" to exercise all implementations, but this is
|
* Users can choose "cycle" to exercise all implementations, but this is
|
||||||
* for testing purpose therefore it can only be set in user space.
|
* for testing purpose therefore it can only be set in user space.
|
||||||
*/
|
*/
|
||||||
module_param_call(zfs_fletcher_4_impl,
|
/* BEGIN CSTYLED */
|
||||||
fletcher_4_param_set, fletcher_4_param_get, NULL, 0644);
|
ZFS_MODULE_VIRTUAL_PARAM_CALL(zfs, zfs_, fletcher_4_impl,
|
||||||
MODULE_PARM_DESC(zfs_fletcher_4_impl, "Select fletcher 4 implementation.");
|
fletcher_4_param_set, fletcher_4_param_get, ZMOD_RW,
|
||||||
|
"Select fletcher 4 implementation.");
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
EXPORT_SYMBOL(fletcher_init);
|
EXPORT_SYMBOL(fletcher_init);
|
||||||
EXPORT_SYMBOL(fletcher_2_incremental_native);
|
EXPORT_SYMBOL(fletcher_2_incremental_native);
|
||||||
|
Loading…
Reference in New Issue
Block a user