cam(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2021-08-10 20:05:40 -04:00
parent 94feb1f1eb
commit 303477d325
8 changed files with 22 additions and 42 deletions

View File

@ -1494,7 +1494,7 @@ adasysctlinit(void *context, int pending)
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "delete_method",
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
softc, 0, adadeletemethodsysctl, "A",
"BIO_DELETE execution method");
SYSCTL_ADD_UQUAD(&softc->sysctl_ctx,
@ -1517,12 +1517,12 @@ adasysctlinit(void *context, int pending)
&softc->write_cache, 0, "Enable disk write cache.");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "zone_mode",
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
softc, 0, adazonemodesysctl, "A",
"Zone Mode");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "zone_support",
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
softc, 0, adazonesupsysctl, "A",
"Zone Support");
SYSCTL_ADD_UQUAD(&softc->sysctl_ctx,

View File

@ -1009,7 +1009,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "limiter",
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
ios, 0, cam_iosched_limiter_sysctl, "A",
"Current limiting type.");
SYSCTL_ADD_INT(ctx, n,
@ -1027,7 +1027,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "latencies",
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
&ios->latencies, 0,
cam_iosched_sysctl_latencies, "A",
"Array of power of 2 latency from 1ms to 1.024s");
@ -1057,22 +1057,22 @@ cam_iosched_cl_sysctl_init(struct cam_iosched_softc *isc)
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "type",
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
clp, 0, cam_iosched_control_type_sysctl, "A",
"Control loop algorithm");
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "steer_interval",
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
&clp->steer_interval, 0, cam_iosched_sbintime_sysctl, "A",
"How often to steer (in us)");
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "lolat",
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
&clp->lolat, 0, cam_iosched_sbintime_sysctl, "A",
"Low water mark for Latency (in us)");
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "hilat",
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
&clp->hilat, 0, cam_iosched_sbintime_sysctl, "A",
"Hi water mark for Latency (in us)");
SYSCTL_ADD_INT(ctx, n,
@ -1200,7 +1200,7 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc *isc,
"How biased towards read should we be independent of limits");
SYSCTL_ADD_PROC(ctx, n,
OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE,
&isc->quanta, 0, cam_iosched_quanta_sysctl, "I",
"How many quanta per second do we slice the I/O up into");

View File

@ -1978,7 +1978,7 @@ ctl_init(void)
SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "ha_role",
CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT,
CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
softc, 0, ctl_ha_role_sysctl, "I", "HA role for this head");
if (softc->is_single == 0) {

View File

@ -896,7 +896,7 @@ ctl_ha_msg_init(struct ctl_softc *ctl_softc)
SYSCTL_ADD_PROC(&ctl_softc->sysctl_ctx,
SYSCTL_CHILDREN(ctl_softc->sysctl_tree),
OID_AUTO, "ha_peer",
CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
softc, 0, ctl_ha_peer_sysctl, "A", "HA peer connection method");
if (ctl_ha_msg_register(CTL_HA_CHAN_DATA, ctl_dt_event_handler)

View File

@ -9236,7 +9236,7 @@ sysctl_scsi_delay(SYSCTL_HANDLER_ARGS)
return (set_scsi_delay(delay));
}
SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, 0, sysctl_scsi_delay, "I",
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_scsi_delay, "I",
"Delay to allow devices to settle after a SCSI bus reset (ms)");
static int

View File

@ -538,7 +538,7 @@ cdsysctlinit(void *context, int pending)
*/
SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "minimum_cmd_size",
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
&softc->minimum_command_size, 0, cdcmdsizesysctl, "I",
"Minimum CDB size");

View File

@ -1579,7 +1579,7 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_uma_ccbs, CTLFLAG_RWTUN,
&da_enable_uma_ccbs, 0, "Use UMA for CCBs");
SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout,
CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0,
CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0,
dasysctlsofttimeout, "I",
"Soft I/O timeout (ms)");
TUNABLE_INT64("kern.cam.da.default_softtimeout", &da_default_softtimeout);
@ -2280,17 +2280,17 @@ dasysctlinit(void *context, int pending)
*/
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "delete_method",
CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
softc, 0, dadeletemethodsysctl, "A",
"BIO_DELETE execution method");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "delete_max",
CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE,
softc, 0, dadeletemaxsysctl, "Q",
"Maximum BIO_DELETE size");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "minimum_cmd_size",
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
&softc->minimum_cmd_size, 0, dacmdsizesysctl, "I",
"Minimum CDB size");
SYSCTL_ADD_UQUAD(&softc->sysctl_ctx,
@ -2308,12 +2308,12 @@ dasysctlinit(void *context, int pending)
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "zone_mode",
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
softc, 0, dazonemodesysctl, "A",
"Zone Mode");
SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "zone_support",
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
softc, 0, dazonesupsysctl, "A",
"Zone Support");
SYSCTL_ADD_UQUAD(&softc->sysctl_ctx,

View File

@ -79,11 +79,8 @@ struct scsi_quirk_entry {
#define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk))
static int cam_srch_hi = 0;
static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS);
SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi,
CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 0, 0,
sysctl_cam_search_luns, "I",
"allow search above LUN 7 for SCSI3 and greater devices");
SYSCTL_INT(_kern_cam, OID_AUTO, cam_srch_hi, CTLFLAG_RWTUN,
&cam_srch_hi, 0, "Search above LUN 7 for SCSI3 and greater devices");
#define CAM_SCSI2_MAXLUN 8
#define CAM_CAN_GET_SIMPLE_LUN(x, i) \
@ -1899,23 +1896,6 @@ scsi_find_quirk(struct cam_ed *device)
device->maxtags = quirk->maxtags;
}
static int
sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS)
{
int error, val;
val = cam_srch_hi;
error = sysctl_handle_int(oidp, &val, 0, req);
if (error != 0 || req->newptr == NULL)
return (error);
if (val == 0 || val == 1) {
cam_srch_hi = val;
return (0);
} else {
return (EINVAL);
}
}
typedef struct {
union ccb *request_ccb;
struct ccb_pathinq *cpi;