Blame SOURCES/lvm2-2_02_182-vgcreate-close-exclusive-fd-after-pvcreate.patch

5e29a5
 lib/label/label.c | 6 +++---
5e29a5
 tools/toollib.c   | 7 +++++++
5e29a5
 2 files changed, 10 insertions(+), 3 deletions(-)
5e29a5
5e29a5
diff --git a/lib/label/label.c b/lib/label/label.c
5e29a5
index ac37713..bafa543 100644
5e29a5
--- a/lib/label/label.c
5e29a5
+++ b/lib/label/label.c
5e29a5
@@ -1190,7 +1190,7 @@ bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
5e29a5
 		return false;
5e29a5
 	}
5e29a5
 
5e29a5
-	if (!(dev->flags & DEV_BCACHE_WRITE)) {
5e29a5
+	if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
5e29a5
 		/* FIXME: avoid tossing out bcache blocks just to replace fd. */
5e29a5
 		log_debug("Close and reopen to write %s", dev_name(dev));
5e29a5
 		bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
5e29a5
@@ -1236,7 +1236,7 @@ bool dev_write_zeros(struct device *dev, uint64_t start, size_t len)
5e29a5
 		return false;
5e29a5
 	}
5e29a5
 
5e29a5
-	if (!(dev->flags & DEV_BCACHE_WRITE)) {
5e29a5
+	if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
5e29a5
 		/* FIXME: avoid tossing out bcache blocks just to replace fd. */
5e29a5
 		log_debug("Close and reopen to write %s", dev_name(dev));
5e29a5
 		bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
5e29a5
@@ -1282,7 +1282,7 @@ bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
5e29a5
 		return false;
5e29a5
 	}
5e29a5
 
5e29a5
-	if (!(dev->flags & DEV_BCACHE_WRITE)) {
5e29a5
+	if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
5e29a5
 		/* FIXME: avoid tossing out bcache blocks just to replace fd. */
5e29a5
 		log_debug("Close and reopen to write %s", dev_name(dev));
5e29a5
 		bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
5e29a5
diff --git a/tools/toollib.c b/tools/toollib.c
5e29a5
index b60ff06..e1c86f9 100644
5e29a5
--- a/tools/toollib.c
5e29a5
+++ b/tools/toollib.c
5e29a5
@@ -5897,6 +5897,13 @@ do_command:
5e29a5
 					pd->name);
5e29a5
 	}
5e29a5
 
5e29a5
+	/*
5e29a5
+	 * Don't keep devs open excl in bcache because the excl will prevent
5e29a5
+	 * using that dev elsewhere.
5e29a5
+	 */
5e29a5
+	dm_list_iterate_items(devl, &rescan_devs)
5e29a5
+		label_scan_invalidate(devl->dev);
5e29a5
+
5e29a5
 	dm_list_iterate_items(pd, &pp->arg_fail)
5e29a5
 		log_debug("%s: command failed for %s.",
5e29a5
 			  cmd->command->name, pd->name);