Deleted Added
full compact
37c37
< __FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 219950 2011-03-24 08:37:48Z mav $");
---
> __FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 219970 2011-03-24 19:23:42Z mav $");
58a59,68
> #include <dev/led/led.h>
>
> struct g_disk_softc {
> struct disk *dp;
> struct sysctl_ctx_list sysctl_ctx;
> struct sysctl_oid *sysctl_tree;
> char led[64];
> uint32_t state;
> };
>
78a89,91
> SYSCTL_DECL(_kern_geom);
> SYSCTL_NODE(_kern_geom, OID_AUTO, disk, CTLFLAG_RW, 0, "GEOM_DISK stuff");
>
112a126
> struct g_disk_softc *sc;
118,119c132,133
< dp = pp->geom->softc;
< if (dp == NULL || dp->d_destroyed) {
---
> sc = pp->geom->softc;
> if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
157a172,174
> sc->state = G_STATE_ACTIVE;
> if (sc->led[0] != 0)
> led_set(sc->led, "0");
188a206,231
> g_disk_setstate(struct bio *bp, struct g_disk_softc *sc)
> {
> const char *cmd;
>
> memcpy(&sc->state, bp->bio_data, sizeof(sc->state));
> if (sc->led[0] != 0) {
> switch (sc->state) {
> case G_STATE_FAILED:
> cmd = "1";
> break;
> case G_STATE_REBUILD:
> cmd = "f5";
> break;
> case G_STATE_RESYNC:
> cmd = "f1";
> break;
> default:
> cmd = "0";
> break;
> }
> led_set(sc->led, cmd);
> }
> g_io_deliver(bp, 0);
> }
>
> static void
192a236
> struct g_disk_softc *sc;
204c248,249
< (dp = bp2->bio_to->geom->softc)) {
---
> (sc = bp2->bio_to->geom->softc) &&
> (dp = sc->dp)) {
220a266
> struct g_disk_softc *sc;
224c270,271
< dp = gp->softc;
---
> sc = gp->softc;
> dp = sc->dp;
238a286
> struct g_disk_softc *sc;
242,243c290,291
< dp = bp->bio_to->geom->softc;
< if (dp == NULL || dp->d_destroyed) {
---
> sc = bp->bio_to->geom->softc;
> if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
321a370,371
> else if (!strcmp(bp->bio_attribute, "GEOM::setstate"))
> g_disk_setstate(bp, sc);
355a406
> struct g_disk_softc *sc;
357,358c408,409
< dp = gp->softc;
< if (dp == NULL)
---
> sc = gp->softc;
> if (sc == NULL || (dp = sc->dp) == NULL)
380a432,433
> struct g_disk_softc *sc;
> char tmpstr[80];
385a439,440
> sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
> sc->dp = dp;
387c442
< gp->softc = dp;
---
> gp->softc = sc;
396a452,466
> sysctl_ctx_init(&sc->sysctl_ctx);
> snprintf(tmpstr, sizeof(tmpstr), "GEOM disk %s", gp->name);
> sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
> SYSCTL_STATIC_CHILDREN(_kern_geom_disk), OID_AUTO, gp->name,
> CTLFLAG_RD, 0, tmpstr);
> if (sc->sysctl_tree != NULL) {
> snprintf(tmpstr, sizeof(tmpstr),
> "kern.geom.disk.%s.led", gp->name);
> TUNABLE_STR_FETCH(tmpstr, sc->led, sizeof(sc->led));
> SYSCTL_ADD_STRING(&sc->sysctl_ctx,
> SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led",
> CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led),
> "LED name");
> }
> pp->private = sc;
405a476
> struct g_disk_softc *sc;
410a482,491
> sc = gp->softc;
> if (sc->sysctl_tree != NULL) {
> sysctl_ctx_free(&sc->sysctl_ctx);
> sc->sysctl_tree = NULL;
> }
> if (sc->led[0] != 0) {
> led_set(sc->led, "0");
> sc->led[0] = 0;
> }
> g_free(sc);