Date: Wed, 20 Sep 2017 21:19:53 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323829 - head/sys/cam Message-ID: <201709202119.v8KLJsBR053793@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Wed Sep 20 21:19:53 2017 New Revision: 323829 URL: https://svnweb.freebsd.org/changeset/base/323829 Log: cam iosched: Add a handler for the quanta sysctl to enforce valid values Invalid values can result in devision-by-zero panics or other undefined behaviour so lets not allow them. PR: 221957 Obtained from: ElectroBSD Submitted by: Fabian Keil Differential Revision: https://reviews.freebsd.org/D12351 Modified: head/sys/cam/cam_iosched.c Modified: head/sys/cam/cam_iosched.c ============================================================================== --- head/sys/cam/cam_iosched.c Wed Sep 20 21:13:20 2017 (r323828) +++ head/sys/cam/cam_iosched.c Wed Sep 20 21:19:53 2017 (r323829) @@ -883,6 +883,27 @@ cam_iosched_sysctl_latencies(SYSCTL_HANDLER_ARGS) return (error); } +static int +cam_iosched_quanta_sysctl(SYSCTL_HANDLER_ARGS) +{ + int *quanta; + int error, value; + + quanta = (unsigned *)arg1; + value = *quanta; + + error = sysctl_handle_int(oidp, (int *)&value, 0, req); + if ((error != 0) || (req->newptr == NULL)) + return (error); + + if (value < 1 || value > hz) + return (EINVAL); + + *quanta = value; + + return (0); +} + static void cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stats *ios, char *name) { @@ -1104,9 +1125,9 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc &isc->read_bias, 100, "How biased towards read should we be independent of limits"); - SYSCTL_ADD_INT(ctx, n, - OID_AUTO, "quanta", CTLFLAG_RW, - &isc->quanta, 200, + SYSCTL_ADD_PROC(ctx, n, + OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW, + &isc->quanta, 0, cam_iosched_quanta_sysctl, "I", "How many quanta per second do we slice the I/O up into"); SYSCTL_ADD_INT(ctx, n,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709202119.v8KLJsBR053793>