Hi, while playing around with softraid, I noticed that it lazily registers the sensor refresh task when the first volume is created, but it never removes it. The attached patch cleans it up when the last sensor is deleted.
Having the one task linger around doing nothing every 10s is obviously not a problem. I did this mainly as an exercise for my own benefit and wanted to share rather than delete it. -pesco Index: dev/softraid.c =================================================================== RCS file: /cvs/src/sys/dev/softraid.c,v retrieving revision 1.429 diff -u -p -r1.429 softraid.c --- dev/softraid.c 21 Dec 2022 09:54:23 -0000 1.429 +++ dev/softraid.c 30 Sep 2023 18:20:43 -0000 @@ -4865,10 +4865,25 @@ bad: void sr_sensors_delete(struct sr_discipline *sd) { + struct sr_softc *sc = sd->sd_sc; + DNPRINTF(SR_D_STATE, "%s: sr_sensors_delete\n", DEVNAME(sd->sd_sc)); - if (sd->sd_vol.sv_sensor_attached) + if (sd->sd_vol.sv_sensor_attached) { sensor_detach(&sd->sd_sc->sc_sensordev, &sd->sd_vol.sv_sensor); + sd->sd_vol.sv_sensor_attached = 0; + } + + /* + * Unregister the refresh task if we detached our last sensor. + */ + TAILQ_FOREACH(sd, &sc->sc_dis_list, sd_link) + if (sd->sd_vol.sv_sensor_attached) + return; + if (sc->sc_sensor_task != NULL) { + sensor_task_unregister(sc->sc_sensor_task); + sc->sc_sensor_task = NULL; + } } void