Skip to contentSkip to conversation

stable-2.02 - pvremove/vgextend: fix using device aliases with lvmetad

PATCH David Teigland 1 participant 1 message Jun 26, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b13ebfa4c289a5bc6eb4f8ba26126db8e6d78296
Commit:        b13ebfa4c289a5bc6eb4f8ba26126db8e6d78296
Parent:        b62c0787debeb3a66a2e3658d1edb8a61a6f247b
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Jun 26 16:03:42 2019 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Wed Jun 26 16:06:23 2019 -0500

pvremove/vgextend: fix using device aliases with lvmetad

These commands were looking for the requested device alias before dev_cache_scan had created the list of devs on the system, so they would fail and report the dev wasn't found.

---
 tools/toollib.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
tools/toollib.c +9 -0
index 3221e5f..1b01ccc 100644
@@ -5544,6 +5544,15 @@ int pvcreate_each_device(struct cmd_context *cmd,
 	lvmcache_label_scan(cmd);
 
 	/*
+	 * When using lvmetad, we want to do a dev cache scan here (if not done
+	 * already) so that the dev_cache_get just below will be able to find
+	 * device aliases.  When not using lvmetad, the label_scan just above
+	 * has done dev_cache_scan, and this will not be run.
+	 */
+	if (!dev_cache_has_scanned())
+		dev_cache_scan();
+
+	/*
 	 * Translate arg names into struct device's.
 	 */
 	dm_list_iterate_items(pd, &pp->arg_devices)