File bug-1137296_pvremove-vgextend-fix-using-device-aliases-with-lvmetad.patch of Package lvm2.13365

From b13ebfa4c289a5bc6eb4f8ba26126db8e6d78296 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 26 Jun 2019 16:03:42 -0500
Subject: [PATCH] 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 file changed, 9 insertions(+)

diff --git a/tools/toollib.c b/tools/toollib.c
index 3221e5f1ca..1b01cccfa2 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5543,6 +5543,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.
 	 */
-- 
2.21.0