Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spa: Fix FreeBSD sysctl handlers #15719

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ spa_taskq_param_set(zio_type_t t, char *cfg)
}

static int
spa_taskq_param_get(zio_type_t t, char *buf)
spa_taskq_param_get(zio_type_t t, char *buf, boolean_t add_newline)
{
int pos = 0;

Expand All @@ -1410,7 +1410,8 @@ spa_taskq_param_get(zio_type_t t, char *buf)
sep = " ";
}

buf[pos++] = '\n';
if (add_newline)
buf[pos++] = '\n';
buf[pos] = '\0';

return (pos);
Expand All @@ -1428,7 +1429,7 @@ spa_taskq_read_param_set(const char *val, zfs_kernel_param_t *kp)
static int
spa_taskq_read_param_get(char *buf, zfs_kernel_param_t *kp)
{
return (spa_taskq_param_get(ZIO_TYPE_READ, buf));
return (spa_taskq_param_get(ZIO_TYPE_READ, buf, TRUE));
}

static int
Expand All @@ -1442,11 +1443,9 @@ spa_taskq_write_param_set(const char *val, zfs_kernel_param_t *kp)
static int
spa_taskq_write_param_get(char *buf, zfs_kernel_param_t *kp)
{
return (spa_taskq_param_get(ZIO_TYPE_WRITE, buf));
return (spa_taskq_param_get(ZIO_TYPE_WRITE, buf, TRUE));
}
#else
#include <sys/sbuf.h>

/*
* On FreeBSD load-time parameters can be set up before malloc() is available,
* so we have to do all the parsing work on the stack.
Expand All @@ -1457,19 +1456,11 @@ static int
spa_taskq_read_param(ZFS_MODULE_PARAM_ARGS)
{
char buf[SPA_TASKQ_PARAM_MAX];
int err = 0;

if (req->newptr == NULL) {
int len = spa_taskq_param_get(ZIO_TYPE_READ, buf);
struct sbuf *s = sbuf_new_for_sysctl(NULL, NULL, len+1, req);
sbuf_cpy(s, buf);
err = sbuf_finish(s);
sbuf_delete(s);
return (err);
}
int err;

(void) spa_taskq_param_get(ZIO_TYPE_READ, buf, FALSE);
err = sysctl_handle_string(oidp, buf, sizeof (buf), req);
if (err)
if (err || req->newptr == NULL)
return (err);
return (spa_taskq_param_set(ZIO_TYPE_READ, buf));
}
Expand All @@ -1478,19 +1469,11 @@ static int
spa_taskq_write_param(ZFS_MODULE_PARAM_ARGS)
{
char buf[SPA_TASKQ_PARAM_MAX];
int err = 0;

if (req->newptr == NULL) {
int len = spa_taskq_param_get(ZIO_TYPE_WRITE, buf);
struct sbuf *s = sbuf_new_for_sysctl(NULL, NULL, len+1, req);
sbuf_cpy(s, buf);
err = sbuf_finish(s);
sbuf_delete(s);
return (err);
}
int err;

(void) spa_taskq_param_get(ZIO_TYPE_WRITE, buf, FALSE);
err = sysctl_handle_string(oidp, buf, sizeof (buf), req);
if (err)
if (err || req->newptr == NULL)
return (err);
return (spa_taskq_param_set(ZIO_TYPE_WRITE, buf));
}
Expand Down