diff options
author | David Teigland <teigland@redhat.com> | 2022-02-10 14:00:25 -0600 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-06-09 11:32:40 -0500 |
commit | 08a5619a1d7a5a8dd6e0df6e4dedec47ce2533b7 (patch) | |
tree | ff94e1f2d9da86ab0cf45cce34a3e22c07125e9f /lib/device | |
parent | df2b1555aff71452cde156badec70117065c9e2c (diff) | |
download | lvm2-08a5619a1d7a5a8dd6e0df6e4dedec47ce2533b7.tar.gz |
devices file: do not clear PVID of unread devices
In a certain disconnected state, a block device is present on
the system, can be opened, reports a valid size, reports the
correct device id (wwid), and matches a devices file entry.
But, reading the device can still fail. In this case,
device_ids_validate() was misinterpreting the read error as
the device having no data/label on it (and no PVID).
The validate function would then clear the PVID from the
devices file entry for the device, thinking that it was
fixing the devices file (making it consistent with the on disk
state.) Fix this by not attempting to check and correct a
devices file entry that cannot be read. Also make this case
explicit in the hints validation code (which was doing the
right thing but indirectly.)
Diffstat (limited to 'lib/device')
-rw-r--r-- | lib/device/device.h | 1 | ||||
-rw-r--r-- | lib/device/device_id.c | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/device/device.h b/lib/device/device.h index 9e471a9b5..8c3a8c30e 100644 --- a/lib/device/device.h +++ b/lib/device/device.h @@ -40,6 +40,7 @@ #define DEV_IS_NVME 0x00040000 /* set if dev is nvme */ #define DEV_MATCHED_USE_ID 0x00080000 /* matched an entry from cmd->use_devices */ #define DEV_SCAN_FOUND_NOLABEL 0x00100000 /* label_scan read, passed filters, but no lvm label */ +#define DEV_SCAN_NOT_READ 0x00200000 /* label_scan not able to read dev */ /* * Support for external device info. diff --git a/lib/device/device_id.c b/lib/device/device_id.c index aeaa1ffc6..7fe581571 100644 --- a/lib/device/device_id.c +++ b/lib/device/device_id.c @@ -1725,6 +1725,13 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, continue; /* + * The matched device could not be read so we do not have + * the PVID from disk and cannot verify the devices file entry. + */ + if (dev->flags & DEV_SCAN_NOT_READ) + continue; + + /* * du and dev may have been matched, but the dev could still * have been excluded by other filters during label scan. * This shouldn't generally happen, but if it does the user @@ -1806,6 +1813,13 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, if (scanned_devs && !dev_in_device_list(dev, scanned_devs)) continue; + /* + * The matched device could not be read so we do not have + * the PVID from disk and cannot verify the devices file entry. + */ + if (dev->flags & DEV_SCAN_NOT_READ) + continue; + if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, "persistent")) { log_warn("Devices file %s is excluded by filter: %s.", dev_name(dev), dev_filtered_reason(dev)); |