From: phessler Date: Sun, 18 Aug 2024 19:44:10 +0000 (+0000) Subject: unregister softraid sensors when the volumes are removed X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=84e87b21418fda14d6aaa76b267462e19021ea82;p=openbsd unregister softraid sensors when the volumes are removed From Sven M. Hallberg tested and OK phessler@ OK mvs@ --- diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index b73f2d1deca..3acccfaf664 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.430 2024/02/03 18:51:58 beck Exp $ */ +/* $OpenBSD: softraid.c,v 1.431 2024/08/18 19:44:10 phessler Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom * Copyright (c) 2008 Chris Kuethe @@ -4862,10 +4862,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