Lines 57-62
Link Here
|
57 |
#include <geom/geom_int.h> |
57 |
#include <geom/geom_int.h> |
58 |
|
58 |
|
59 |
#include <dev/led/led.h> |
59 |
#include <dev/led/led.h> |
|
|
60 |
#ifdef GEOM_DISK_ACTIVITY_LED |
61 |
#define ACTIVITY_LED_SET(set, negset) do { \ |
62 |
if (sc->activity_led[0] != 0) { \ |
63 |
if (sc->activity_led[0] != '!') \ |
64 |
led_set(sc->activity_led, (set)); \ |
65 |
else \ |
66 |
led_set(sc->activity_led+1, (negset)); \ |
67 |
} \ |
68 |
} while (0) |
69 |
#define ACTIVITY_LED_ON ACTIVITY_LED_SET("1", "0") |
70 |
#define ACTIVITY_LED_OFF ACTIVITY_LED_SET("0", "1") |
71 |
#else |
72 |
#define ACTIVITY_LED_ON |
73 |
#define ACTIVITY_LED_OFF |
74 |
#endif |
60 |
|
75 |
|
61 |
struct g_disk_softc { |
76 |
struct g_disk_softc { |
62 |
struct mtx done_mtx; |
77 |
struct mtx done_mtx; |
Lines 66-71
Link Here
|
66 |
char led[64]; |
81 |
char led[64]; |
67 |
uint32_t state; |
82 |
uint32_t state; |
68 |
struct mtx start_mtx; |
83 |
struct mtx start_mtx; |
|
|
84 |
#ifdef GEOM_DISK_ACTIVITY_LED |
85 |
char activity_led[64]; |
86 |
#endif |
69 |
}; |
87 |
}; |
70 |
|
88 |
|
71 |
static g_access_t g_disk_access; |
89 |
static g_access_t g_disk_access; |
Lines 233-238
Link Here
|
233 |
} else |
251 |
} else |
234 |
mtx_unlock(&sc->done_mtx); |
252 |
mtx_unlock(&sc->done_mtx); |
235 |
g_destroy_bio(bp); |
253 |
g_destroy_bio(bp); |
|
|
254 |
ACTIVITY_LED_OFF; |
236 |
} |
255 |
} |
237 |
|
256 |
|
238 |
static void |
257 |
static void |
Lines 250-255
Link Here
|
250 |
mtx_lock(&sc->done_mtx); |
269 |
mtx_lock(&sc->done_mtx); |
251 |
devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now); |
270 |
devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now); |
252 |
mtx_unlock(&sc->done_mtx); |
271 |
mtx_unlock(&sc->done_mtx); |
|
|
272 |
ACTIVITY_LED_OFF; |
253 |
} |
273 |
} |
254 |
g_io_deliver(bp, bp->bio_error); |
274 |
g_io_deliver(bp, bp->bio_error); |
255 |
} |
275 |
} |
Lines 306-311
Link Here
|
306 |
devstat_start_transaction_bio(dp->d_devstat, bp); |
326 |
devstat_start_transaction_bio(dp->d_devstat, bp); |
307 |
mtx_unlock(&sc->start_mtx); |
327 |
mtx_unlock(&sc->start_mtx); |
308 |
dp->d_strategy(bp); |
328 |
dp->d_strategy(bp); |
|
|
329 |
ACTIVITY_LED_ON; |
309 |
break; |
330 |
break; |
310 |
} |
331 |
} |
311 |
off = 0; |
332 |
off = 0; |
Lines 315-320
Link Here
|
315 |
error = ENOMEM; |
336 |
error = ENOMEM; |
316 |
break; |
337 |
break; |
317 |
} |
338 |
} |
|
|
339 |
ACTIVITY_LED_ON; |
318 |
do { |
340 |
do { |
319 |
bp2->bio_offset += off; |
341 |
bp2->bio_offset += off; |
320 |
bp2->bio_length -= off; |
342 |
bp2->bio_length -= off; |
Lines 565-570
Link Here
|
565 |
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led", |
587 |
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led", |
566 |
CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led), |
588 |
CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led), |
567 |
"LED name"); |
589 |
"LED name"); |
|
|
590 |
#ifdef GEOM_DISK_ACTIVITY_LED |
591 |
snprintf(tmpstr, sizeof(tmpstr), |
592 |
"kern.geom.disk.%s.activity_led", gp->name); |
593 |
TUNABLE_STR_FETCH(tmpstr, sc->activity_led, sizeof(sc->activity_led)); |
594 |
SYSCTL_ADD_STRING(&sc->sysctl_ctx, |
595 |
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "activity_led", |
596 |
CTLFLAG_RW | CTLFLAG_TUN, sc->activity_led, sizeof(sc->activity_led), |
597 |
"(!)Activity LED name"); |
598 |
#endif |
568 |
} |
599 |
} |
569 |
pp->private = sc; |
600 |
pp->private = sc; |
570 |
dp->d_geom = gp; |
601 |
dp->d_geom = gp; |