Skip to content

Commit

Permalink
spa: Let spa_taskq_param_get()'s addition of a newline be optional
Browse files Browse the repository at this point in the history
For FreeBSD sysctls, we don't want the extra newline, since the
sysctl(8) utility will format strings appropriately.

Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reported-by: Peter Holm <[email protected]>
Signed-off-by: Mark Johnston <[email protected]>
Closes openzfs#15719
  • Loading branch information
markjdb authored and lundman committed Mar 13, 2024
1 parent 04c719d commit 12e49aa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,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 @@ -1412,7 +1412,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 @@ -1430,7 +1431,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 @@ -1444,7 +1445,7 @@ 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
/*
Expand All @@ -1459,7 +1460,7 @@ spa_taskq_read_param(ZFS_MODULE_PARAM_ARGS)
char buf[SPA_TASKQ_PARAM_MAX];
int err;

(void) spa_taskq_param_get(ZIO_TYPE_READ, buf);
(void) spa_taskq_param_get(ZIO_TYPE_READ, buf, FALSE);
err = sysctl_handle_string(oidp, buf, sizeof (buf), req);
if (err || req->newptr == NULL)
return (err);
Expand All @@ -1472,7 +1473,7 @@ spa_taskq_write_param(ZFS_MODULE_PARAM_ARGS)
char buf[SPA_TASKQ_PARAM_MAX];
int err;

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

0 comments on commit 12e49aa

Please sign in to comment.