summaryrefslogtreecommitdiff
path: root/lib/label/hints.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2022-02-10 14:00:25 -0600
committerDavid Teigland <teigland@redhat.com>2022-06-09 11:32:40 -0500
commit08a5619a1d7a5a8dd6e0df6e4dedec47ce2533b7 (patch)
treeff94e1f2d9da86ab0cf45cce34a3e22c07125e9f /lib/label/hints.c
parentdf2b1555aff71452cde156badec70117065c9e2c (diff)
downloadlvm2-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/label/hints.c')
-rw-r--r--lib/label/hints.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/label/hints.c b/lib/label/hints.c
index 3ce9634f2..95d5d77b8 100644
--- a/lib/label/hints.c
+++ b/lib/label/hints.c
@@ -234,6 +234,7 @@ static int _touch_newhints(void)
return_0;
if (fclose(fp))
stack;
+ log_debug("newhints created");
return 1;
}
@@ -504,6 +505,19 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
if (!hint->chosen)
continue;
+ /*
+ * label_scan was unable to read the dev so we don't know its pvid.
+ * Since we are unable to verify the hint is correct, it's possible
+ * that the PVID is actually found on a different device, so don't
+ * depend on hints. (This would also fail the following pvid check.)
+ */
+ if (dev->flags & DEV_SCAN_NOT_READ) {
+ log_debug("Uncertain hint for unread device %d:%d %s",
+ major(hint->devt), minor(hint->devt), dev_name(dev));
+ ret = 0;
+ continue;
+ }
+
if (strcmp(dev->pvid, hint->pvid)) {
log_debug("Invalid hint device %d:%d %s pvid %s had hint pvid %s",
major(hint->devt), minor(hint->devt), dev_name(dev),