The following reply was made to PR system/6576; it has been noted by GNATS.
From: Joel Sing <[email protected]> To: [email protected] Cc: [email protected], [email protected] Subject: Re: system/6576: softraid(4) attaches multiple sensors under the same sensor id Date: Mon, 14 Mar 2011 00:28:40 +1100 On Wednesday 09 March 2011, [email protected] wrote: > >Number: 6576 > >Category: system > >Synopsis: softraid(4) attaches multiple sensors under the same > > sensor id Confidential: yes > >Severity: serious > >Priority: medium > >Responsible: bugs > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: sw-bug > >Submitter-Id: unknown > >Arrival-Date: Tue Mar 08 16:10:01 GMT 2011 > >Closed-Date: > >Last-Modified: > >Originator: > >Release: > >Organization: > >Environment: > > System : OpenBSD 4.9 > Details : OpenBSD 4.9 (GENERIC.MP) #2: Wed Mar 2 13:13:28 CET 2011 > > [email protected]:/usr/src/sys/arch/sparc64/compile/GENERIC.MP > > Architecture: OpenBSD.sparc64 > Machine : sparc64 > > >Description: > > I have two softraid(4) volumes : > $ sudo bioctl softraid0 > Volume Status Size Device > softraid0 0 Online 34008760320 sd4 RAID1 > 0 Online 34008760320 0:0.0 noencl <sd0p> > 1 Online 34008760320 0:1.0 noencl <sd1p> > softraid0 1 Online 293625659392 sd5 RAID0 > 0 Online 146814142464 1:0.0 noencl <sd2p> > 1 Online 146812870656 1:1.0 noencl <sd3p> > > But the sensor framework exposed their state under the same sysctl node: > $ sysctl hw.sensors > hw.sensors.softraid0.drive0=online (sd4), OK > hw.sensors.softraid0.drive0=online (sd5), OK > > $ sysctl hw.sensors.softraid0.drive0 > hw.sensors.softraid0.drive0=online (sd4), OK > For some (currently unknown) reason, softraid attaches multiple sensordevs (one per discipline), rather than one per the softraid device (i.e. softraid0). The below diff changes this and fixes the problem. Index: softraid.c =================================================================== RCS file: /cvs/src/sys/dev/softraid.c,v retrieving revision 1.221 diff -u -p -r1.221 softraid.c --- softraid.c 29 Jan 2011 15:01:22 -0000 1.221 +++ softraid.c 13 Mar 2011 13:15:08 -0000 @@ -1640,6 +1640,12 @@ sr_attach(struct device *parent, struct sc->sc_ioctl = sr_ioctl; #endif /* NBIO > 0 */ +#ifndef SMALL_KERNEL + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); + sensordev_install(&sc->sc_sensordev); +#endif /* SMALL_KERNEL */ + printf("\n"); softraid_disk_attach = sr_disk_attach; @@ -1650,6 +1656,12 @@ sr_attach(struct device *parent, struct int sr_detach(struct device *self, int flags) { +#ifndef SMALL_KERNEL + struct sr_softc *sc = (void *)self; + + sensordev_deinstall(&sc->sc_sensordev); +#endif /* SMALL_KERNEL */ + return (0); } @@ -4066,22 +4078,19 @@ sr_sensors_create(struct sr_discipline * DNPRINTF(SR_D_STATE, "%s: %s: sr_sensors_create\n", DEVNAME(sc), sd->sd_meta->ssd_devname); - strlcpy(sd->sd_vol.sv_sensordev.xname, DEVNAME(sc), - sizeof(sd->sd_vol.sv_sensordev.xname)); - sd->sd_vol.sv_sensor.type = SENSOR_DRIVE; sd->sd_vol.sv_sensor.status = SENSOR_S_UNKNOWN; strlcpy(sd->sd_vol.sv_sensor.desc, sd->sd_meta->ssd_devname, sizeof(sd->sd_vol.sv_sensor.desc)); - sensor_attach(&sd->sd_vol.sv_sensordev, &sd->sd_vol.sv_sensor); + sensor_attach(&sc->sc_sensordev, &sd->sd_vol.sv_sensor); + sd->sd_vol.sv_sensor_attached = 1; if (sc->sc_sensors_running == 0) { if (sensor_task_register(sc, sr_sensors_refresh, 10) == NULL) goto bad; sc->sc_sensors_running = 1; } - sensordev_install(&sd->sd_vol.sv_sensordev); rv = 0; bad: @@ -4093,8 +4102,8 @@ sr_sensors_delete(struct sr_discipline * { DNPRINTF(SR_D_STATE, "%s: sr_sensors_delete\n", DEVNAME(sd->sd_sc)); - if (sd->sd_vol.sv_sensor_valid) - sensordev_deinstall(&sd->sd_vol.sv_sensordev); + if (sd->sd_vol.sv_sensor_attached) + sensor_detach(&sd->sd_sc->sc_sensordev, &sd->sd_vol.sv_sensor); } void Index: softraidvar.h =================================================================== RCS file: /cvs/src/sys/dev/softraidvar.h,v retrieving revision 1.97 diff -u -p -r1.97 softraidvar.h --- softraidvar.h 29 Jan 2011 15:01:22 -0000 1.97 +++ softraidvar.h 13 Mar 2011 13:15:09 -0000 @@ -453,7 +452,7 @@ struct sr_volume { /* sensors */ struct ksensor sv_sensor; - struct ksensordev sv_sensordev; + int sv_sensor_attached; int sv_sensor_valid; }; @@ -573,7 +572,9 @@ struct sr_softc { struct rwlock sc_hs_lock; /* Lock for hotspares list. */ int sc_hotspare_no; /* Number of hotspares. */ + struct ksensordev sc_sensordev; int sc_sensors_running; + /* * during scsibus attach this is the discipline that is in use * this variable is protected by sc_lock and splhigh -- "Reason is not automatic. Those who deny it cannot be conquered by it. Do not count on them. Leave them alone." -- Ayn Rand
