Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ledmon/ledmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ static void _add_block(struct block_device *block)
} else {
temp->ibpi = block->ibpi;
}
} else if (temp->ibpi == LED_IBPI_PATTERN_FAILED_DRIVE &&
!temp->raid_dev) {
Comment thread
tasleson marked this conversation as resolved.
Outdated
/*
* Non-RAID device reappeared in sysfs scan.
* Allow recovery from FAILED_DRIVE so the LED
* is cleared after a hot-swap cycle.
*/
temp->ibpi = LED_IBPI_PATTERN_ADDED;
} else if (!(temp->ibpi == LED_IBPI_PATTERN_FAILED_DRIVE &&
block->ibpi == LED_IBPI_PATTERN_HOTSPARE) ||
(temp->ibpi == LED_IBPI_PATTERN_FAILED_DRIVE &&
Expand Down
36 changes: 26 additions & 10 deletions src/ledmon/udev.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,40 @@ static struct udev_monitor *udev_monitor;

static int _compare(const struct block_device *bd, const char *syspath, struct led_ctx *ctx)
{
struct block_device *bd_new;
const char *udev_name;
const char *dev_name;
int ret;

if (!bd || !syspath)
return 0;

if (strcmp(bd->sysfs_path, syspath) == 0) {
if (strcmp(bd->sysfs_path, syspath) == 0)
return 1;
} else {
struct block_device *bd_new;
int ret;

bd_new = block_device_init(sysfs_get_cntrl_devices(ctx), syspath);
if (!bd_new)
return 0;

bd_new = block_device_init(sysfs_get_cntrl_devices(ctx), syspath);
if (bd_new) {
ret = block_compare(bd, bd_new);
block_device_fini(bd_new);

return ret;
if (ret)
return 1;
}

/*
* NVMe udev events may arrive with a virtual nvme-subsystem path
* that cannot be resolved to a PCI controller. Fall back to matching
* by device name so that add/remove events are not silently dropped.
*/
if (bd->devnode[0] == '\0')
return 0;

dev_name = strrchr(bd->devnode, '/');
dev_name = dev_name ? dev_name + 1 : bd->devnode;

udev_name = strrchr(syspath, '/');
udev_name = udev_name ? udev_name + 1 : syspath;

return strcmp(dev_name, udev_name) == 0;
}

static int create_udev_monitor(void)
Expand Down
7 changes: 7 additions & 0 deletions src/lib/pci_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "config.h"
#include "led/libled.h"
Expand Down Expand Up @@ -71,6 +72,12 @@ struct slot_property *pci_slot_property_init(struct pci_slot *pci_slot)

result->bl_device = get_block_device_from_sysfs_path(pci_slot->ctx,
pci_slot->address, true);
if (result->bl_device) {
Comment thread
tasleson marked this conversation as resolved.
struct stat st;

if (stat(result->bl_device->devnode, &st) != 0)
result->bl_device = NULL;
}
result->slot_spec.pci = pci_slot;
snprintf(result->slot_id, PATH_MAX, "%s", pci_slot->sysfs_path);
result->c = &pci_slot_common;
Expand Down