From 6187a5afb059f375166260d13a51f581b8336a7c Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Thu, 28 May 2026 20:56:47 +1000 Subject: [PATCH] fix: LHv2: don't use BDF paths when driver set to 'aio' The Longhorn V2 aio bdev driver needs a regular device path to a disk (e.g. "/dev/whatever"), but currently NDM will always try to use BDF paths for NVMe or virtio devices even if the disk driver is set to aio. In this case, Longhorn just doesn't know what to do and can't add the disk. We can fix this by ensuring NDM doesn't try to resolve BDF paths if the disk driver is set to aio. Related-to: https://github.com/harvester/harvester/issues/10666 Signed-off-by: Tim Serong --- pkg/provisioner/longhornv2.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/provisioner/longhornv2.go b/pkg/provisioner/longhornv2.go index 08708ee8..6018d308 100644 --- a/pkg/provisioner/longhornv2.go +++ b/pkg/provisioner/longhornv2.go @@ -172,9 +172,11 @@ func resolveLonghornV2DevPath(device *diskv1.BlockDevice) (string, error) { device.Status.DeviceStatus.Details.DeviceType) } devPath := "" - if device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerVirtio) || - device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerNVMe) { - // In both of these cases, we should (hopefully!) be able to extract BDF from BusPath + if (device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerVirtio) || + device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerNVMe)) && + device.Spec.Provisioner.Longhorn.DiskDriver != longhornv1.DiskDriverAio { + // In both of these cases, we should (hopefully!) be able to extract BDF from BusPath, + // but this can't be used with the "aio" disk driver (that needs a regular device path) if strings.HasPrefix(device.Status.DeviceStatus.Details.BusPath, "pci-") { devPath = strings.Split(device.Status.DeviceStatus.Details.BusPath, "-")[1] } @@ -187,7 +189,11 @@ func resolveLonghornV2DevPath(device *diskv1.BlockDevice) (string, error) { }).Warn("Unable to extract BDF from BusPath, falling back to WWN") } if wwn := device.Status.DeviceStatus.Details.WWN; valueExists(wwn) { - devPath = "/dev/disk/by-id/wwn-" + wwn + if device.Status.DeviceStatus.Details.StorageController == string(diskv1.StorageControllerNVMe) { + devPath = "/dev/disk/by-id/nvme-" + wwn + } else { + devPath = "/dev/disk/by-id/wwn-" + wwn + } _, err := os.Stat(devPath) if err == nil { return devPath, nil @@ -195,9 +201,10 @@ func resolveLonghornV2DevPath(device *diskv1.BlockDevice) (string, error) { logrus.WithFields(logrus.Fields{ "device": device.Name, "wwn": device.Status.DeviceStatus.Details.WWN, - }).Warn("/dev/disk/by-id/wwn-* path does not exist for device") + }).Warn("/dev/disk/by-id/* path does not exist for device") } if busPath := device.Status.DeviceStatus.Details.BusPath; valueExists(busPath) { + // This won't work for LHv2 devices util https://github.com/longhorn/longhorn/issues/13228 is fixed devPath = "/dev/disk/by-path/" + busPath _, err := os.Stat(devPath) if err == nil {