Skip to content

Commit 0ea56d3

Browse files
committed
apply led update in bio_bs_state_set
Features: nvme Signed-off-by: Tom Nabarro <thomas.nabarro@hpe.com>
1 parent b7a224a commit 0ea56d3

File tree

4 files changed

+56
-63
lines changed

4 files changed

+56
-63
lines changed

src/bio/bio_device.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ revive_dev(struct bio_xs_context *xs_ctxt, struct bio_bdev *d_bdev)
4949
d_bdev->bb_trigger_reint = 1;
5050
spdk_thread_send_msg(owner_thread(bbs), setup_bio_bdev, d_bdev);
5151

52-
/* Reset the LED of the VMD device once revived */
53-
rc = bio_led_manage(xs_ctxt, NULL, d_bdev->bb_uuid, (unsigned int)CTL__LED_ACTION__RESET,
54-
NULL, 0);
55-
if (rc != 0)
56-
DL_ERROR(rc, "Reset LED on device:" DF_UUID " failed", DP_UUID(d_bdev->bb_uuid));
57-
5852
return 0;
5953
}
6054

src/bio/bio_monitor.c

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ struct vid_opts {
4949
uint16_t vid;
5050
};
5151

52-
/* Used for managing LED on init xstream when auto-faulty is triggered */
53-
struct led_msg_arg {
54-
struct bio_xs_context *xs;
55-
uuid_t dev_uuid;
56-
};
57-
5852
/* Collect space utilization for blobstore */
5953
static void
6054
collect_bs_usage(struct spdk_blob_store *bs, struct nvme_stats *stats)
@@ -739,45 +733,6 @@ is_bbs_faulty(struct bio_blobstore *bbs)
739733
return false;
740734
}
741735

742-
/* Callback to set LED on init xstream when auto-faulty is triggered */
743-
static void
744-
set_led_faulty(void *arg)
745-
{
746-
struct led_msg_arg *led_msg = arg;
747-
Ctl__LedState led_state = CTL__LED_STATE__ON;
748-
int rc;
749-
750-
D_ASSERT(led_msg->xs != NULL);
751-
752-
rc = bio_led_manage(led_msg->xs, NULL, led_msg->dev_uuid,
753-
(unsigned int)CTL__LED_ACTION__SET, (unsigned int *)&led_state, 0);
754-
if (rc != 0)
755-
DL_ERROR(rc, "Failed to set LED to FAULTY state on device:" DF_UUID,
756-
DP_UUID(led_msg->dev_uuid));
757-
758-
D_FREE(led_msg);
759-
}
760-
761-
static void
762-
send_set_led_faulty(struct bio_blobstore *bbs)
763-
{
764-
struct led_msg_arg *led_msg;
765-
766-
/* Set LED to FAULTY state on init xstream */
767-
if (init_thread() != NULL) {
768-
D_ALLOC_PTR(led_msg);
769-
if (led_msg == NULL) {
770-
D_ERROR("Failed to allocate LED message for device:" DF_UUID "\n",
771-
DP_UUID(bbs->bb_dev->bb_uuid));
772-
return;
773-
}
774-
775-
uuid_copy(led_msg->dev_uuid, bbs->bb_dev->bb_uuid);
776-
led_msg->xs = bbs->bb_owner_xs;
777-
spdk_thread_send_msg(init_thread(), set_led_faulty, led_msg);
778-
}
779-
}
780-
781736
void
782737
auto_faulty_detect(struct bio_blobstore *bbs)
783738
{
@@ -820,19 +775,14 @@ auto_faulty_detect(struct bio_blobstore *bbs)
820775
smd_dev_free_info(dev_info);
821776

822777
rc = smd_dev_set_state(bbs->bb_dev->bb_uuid, SMD_DEV_FAULTY);
823-
if (rc) {
778+
if (rc)
824779
DL_ERROR(rc, "Set device state failed.");
825-
} else {
780+
else
826781
trigger_faulty_reaction(bbs);
827-
send_set_led_faulty(bbs);
828-
}
829782
} else {
830783
rc = bio_bs_state_set(bbs, BIO_BS_STATE_FAULTY);
831-
if (rc) {
784+
if (rc)
832785
DL_ERROR(rc, "Failed to set FAULTY state.");
833-
} else {
834-
send_set_led_faulty(bbs);
835-
}
836786
}
837787

838788
if (rc == 0)

src/bio/bio_recovery.c

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* (C) Copyright 2018-2024 Intel Corporation.
3-
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
@@ -95,7 +95,7 @@ teardown_xs_bs(void *arg)
9595

9696
bio_blob_close(ioc, true);
9797
}
98-
98+
9999
if (opened_blobs) {
100100
D_DEBUG(DB_MGMT, "blobstore:%p has %d opened blobs\n",
101101
bxb->bxb_blobstore, opened_blobs);
@@ -426,6 +426,52 @@ on_setup(struct bio_blobstore *bbs)
426426
return rc;
427427
}
428428

429+
/* Used for managing LED on init xstream when auto-faulty is triggered */
430+
struct led_msg_arg {
431+
struct bio_xs_context *xs;
432+
Ctl__LedState state;
433+
uuid_t dev_uuid;
434+
};
435+
436+
/* Callback to set LED on init xstream when auto-faulty is triggered */
437+
static void
438+
set_led(void *arg)
439+
{
440+
struct led_msg_arg *led_msg = arg;
441+
int rc;
442+
443+
D_ASSERT(led_msg->xs != NULL);
444+
445+
rc = bio_led_manage(led_msg->xs, NULL, led_msg->dev_uuid,
446+
(unsigned int)CTL__LED_ACTION__SET, (unsigned int *)&led_msg->state, 0);
447+
if (rc != 0)
448+
DL_ERROR(rc, "Failed to set LED to FAULTY state on device:" DF_UUID,
449+
DP_UUID(led_msg->dev_uuid));
450+
451+
D_FREE(led_msg);
452+
}
453+
454+
static void
455+
send_set_led(struct bio_blobstore *bbs, Ctl__LedState led_state)
456+
{
457+
struct led_msg_arg *led_msg;
458+
459+
/* Set LED to FAULTY state on init xstream */
460+
if (init_thread() != NULL) {
461+
D_ALLOC_PTR(led_msg);
462+
if (led_msg == NULL) {
463+
D_ERROR("Failed to allocate LED message for device:" DF_UUID "\n",
464+
DP_UUID(bbs->bb_dev->bb_uuid));
465+
return;
466+
}
467+
468+
uuid_copy(led_msg->dev_uuid, bbs->bb_dev->bb_uuid);
469+
led_msg->xs = bbs->bb_owner_xs;
470+
led_msg->state = led_state;
471+
spdk_thread_send_msg(init_thread(), set_led, led_msg);
472+
}
473+
}
474+
429475
int
430476
bio_bs_state_set(struct bio_blobstore *bbs, enum bio_bs_state new_state)
431477
{
@@ -496,6 +542,9 @@ bio_bs_state_set(struct bio_blobstore *bbs, enum bio_bs_state new_state)
496542
if (rc)
497543
D_ERROR("Set device state failed. "DF_RC"\n",
498544
DP_RC(rc));
545+
send_set_led(bbs, CTL__LED_STATE__ON);
546+
} else {
547+
send_set_led(bbs, CTL__LED_STATE__OFF);
499548
}
500549
}
501550
ABT_mutex_unlock(bbs->bb_mutex);

src/bio/bio_xstream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ scan_bio_bdevs(struct bio_xs_context *ctxt, uint64_t now)
20592059
}
20602060

20612061
void
2062-
bio_led_event_monitor(struct bio_xs_context *ctxt, uint64_t now)
2062+
bio_led_reset_on_timeout(struct bio_xs_context *ctxt, uint64_t now)
20632063
{
20642064
struct bio_bdev *d_bdev;
20652065
int rc;
@@ -2125,7 +2125,7 @@ bio_nvme_poll(struct bio_xs_context *ctxt)
21252125
/* Detect new plugged device, manage LED on init xstream */
21262126
if (is_init_xstream(ctxt)) {
21272127
scan_bio_bdevs(ctxt, now);
2128-
bio_led_event_monitor(ctxt, now);
2128+
bio_led_reset_on_timeout(ctxt, now);
21292129
}
21302130

21312131
/* Detect stalled I/Os */

0 commit comments

Comments
 (0)