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
This commit is contained in:
parent
84c12dcdd0
commit
2d22619adc
@ -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,
|
||||
&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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user