Blame SOURCES/0036-devices-drop-incorrect-paths-from-aliases-list.patch

ab86b0
From 8ba6259b24cd4b99e061f2610c5cd0bcde890039 Mon Sep 17 00:00:00 2001
ab86b0
From: David Teigland <teigland@redhat.com>
ab86b0
Date: Thu, 24 Feb 2022 16:03:21 -0600
ab86b0
Subject: [PATCH 36/54] devices: drop incorrect paths from aliases list
ab86b0
ab86b0
along with some basic checks for cases when a device
ab86b0
has no aliases.
ab86b0
ab86b0
lvm itself creates many situations where a struct device
ab86b0
has no valid paths, when it activates and opens an LV,
ab86b0
does something with it, e.g. zeroing, and then closes
ab86b0
and deactivates it.  (dev-cache is intended for PVs, and
ab86b0
the use of LVs should be moved out of dev-cache in a
ab86b0
future patch.)
ab86b0
---
ab86b0
 lib/device/dev-cache.c | 223 ++++++++++++++++++++++++++---------------
ab86b0
 lib/device/dev-cache.h |   2 +-
ab86b0
 lib/device/dev-io.c    |  34 ++++---
ab86b0
 lib/device/device.h    |   3 -
ab86b0
 4 files changed, 164 insertions(+), 98 deletions(-)
ab86b0
ab86b0
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
ab86b0
index cc1af7c7a..58e67e130 100644
ab86b0
--- a/lib/device/dev-cache.c
ab86b0
+++ b/lib/device/dev-cache.c
ab86b0
@@ -351,7 +351,7 @@ static int _add_alias(struct device *dev, const char *path, enum add_hash hash)
ab86b0
 			goto out;
ab86b0
 		}
ab86b0
 
ab86b0
-	if (!(path = dm_pool_strdup(_cache.mem, path)) ||
ab86b0
+	if (!(path = _strdup(path)) ||
ab86b0
 	    !(sl = _zalloc(sizeof(*sl)))) {
ab86b0
 		log_error("Failed to add allias to dev cache.");
ab86b0
 		return 0;
ab86b0
@@ -1162,6 +1162,17 @@ static int _insert(const char *path, const struct stat *info,
ab86b0
 	return 1;
ab86b0
 }
ab86b0
 
ab86b0
+static void _drop_all_aliases(struct device *dev)
ab86b0
+{
ab86b0
+	struct dm_str_list *strl, *strl2;
ab86b0
+
ab86b0
+	dm_list_iterate_items_safe(strl, strl2, &dev->aliases) {
ab86b0
+		log_debug("Drop alias for %d:%d %s.", (int)MAJOR(dev->dev), (int)MINOR(dev->dev), strl->str);
ab86b0
+		dm_hash_remove(_cache.names, strl->str);
ab86b0
+		dm_list_del(&strl->list);
ab86b0
+	}
ab86b0
+}
ab86b0
+
ab86b0
 void dev_cache_scan(struct cmd_context *cmd)
ab86b0
 {
ab86b0
 	log_debug_devs("Creating list of system devices.");
ab86b0
@@ -1371,59 +1382,6 @@ int dev_cache_add_dir(const char *path)
ab86b0
 	return 1;
ab86b0
 }
ab86b0
 
ab86b0
-/* Check cached device name is still valid before returning it */
ab86b0
-/* This should be a rare occurrence */
ab86b0
-/* set quiet if the cache is expected to be out-of-date */
ab86b0
-/* FIXME Make rest of code pass/cache struct device instead of dev_name */
ab86b0
-const char *dev_name_confirmed(struct device *dev, int quiet)
ab86b0
-{
ab86b0
-	struct stat buf;
ab86b0
-	const char *name;
ab86b0
-	int r;
ab86b0
-
ab86b0
-	if ((dev->flags & DEV_REGULAR))
ab86b0
-		return dev_name(dev);
ab86b0
-
ab86b0
-	while ((r = stat(name = dm_list_item(dev->aliases.n,
ab86b0
-					  struct dm_str_list)->str, &buf)) ||
ab86b0
-	       (buf.st_rdev != dev->dev)) {
ab86b0
-		if (r < 0) {
ab86b0
-			if (quiet)
ab86b0
-				log_sys_debug("stat", name);
ab86b0
-			else
ab86b0
-				log_sys_error("stat", name);
ab86b0
-		}
ab86b0
-		if (quiet)
ab86b0
-			log_debug_devs("Path %s no longer valid for device(%d,%d)",
ab86b0
-				       name, (int) MAJOR(dev->dev),
ab86b0
-				       (int) MINOR(dev->dev));
ab86b0
-		else
ab86b0
-			log_warn("Path %s no longer valid for device(%d,%d)",
ab86b0
-				 name, (int) MAJOR(dev->dev),
ab86b0
-				 (int) MINOR(dev->dev));
ab86b0
-
ab86b0
-		/* Remove the incorrect hash entry */
ab86b0
-		dm_hash_remove(_cache.names, name);
ab86b0
-
ab86b0
-		/* Leave list alone if there isn't an alternative name */
ab86b0
-		/* so dev_name will always find something to return. */
ab86b0
-		/* Otherwise add the name to the correct device. */
ab86b0
-		if (dm_list_size(&dev->aliases) > 1) {
ab86b0
-			dm_list_del(dev->aliases.n);
ab86b0
-			if (!r)
ab86b0
-				_insert(name, &buf, 0, obtain_device_list_from_udev());
ab86b0
-			continue;
ab86b0
-		}
ab86b0
-
ab86b0
-		/* Scanning issues this inappropriately sometimes. */
ab86b0
-		log_debug_devs("Aborting - please provide new pathname for what "
ab86b0
-			       "used to be %s", name);
ab86b0
-		return NULL;
ab86b0
-	}
ab86b0
-
ab86b0
-	return dev_name(dev);
ab86b0
-}
ab86b0
-
ab86b0
 struct device *dev_hash_get(const char *name)
ab86b0
 {
ab86b0
 	return (struct device *) dm_hash_lookup(_cache.names, name);
ab86b0
@@ -1452,26 +1410,23 @@ static void _remove_alias(struct device *dev, const char *name)
ab86b0
  * deactivated LV.  Those old paths are all invalid and are dropped here.
ab86b0
  */
ab86b0
 
ab86b0
-static void _verify_aliases(struct device *dev, const char *newname)
ab86b0
+static void _verify_aliases(struct device *dev)
ab86b0
 {
ab86b0
 	struct dm_str_list *strl, *strl2;
ab86b0
 	struct stat st;
ab86b0
 
ab86b0
 	dm_list_iterate_items_safe(strl, strl2, &dev->aliases) {
ab86b0
-		/* newname was just stat'd and added by caller */
ab86b0
-		if (newname && !strcmp(strl->str, newname))
ab86b0
-			continue;
ab86b0
-
ab86b0
 		if (stat(strl->str, &st) || (st.st_rdev != dev->dev)) {
ab86b0
-			log_debug("Drop invalid path %s for %d:%d (new path %s).",
ab86b0
-				  strl->str, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), newname ?: "");
ab86b0
+			log_debug("Drop alias for %d:%d invalid path %s %d:%d.",
ab86b0
+				  (int)MAJOR(dev->dev), (int)MINOR(dev->dev), strl->str,
ab86b0
+				  (int)MAJOR(st.st_rdev), (int)MINOR(st.st_rdev));
ab86b0
 			dm_hash_remove(_cache.names, strl->str);
ab86b0
 			dm_list_del(&strl->list);
ab86b0
 		}
ab86b0
 	}
ab86b0
 }
ab86b0
 
ab86b0
-struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f)
ab86b0
+static struct device *_dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f, int existing)
ab86b0
 {
ab86b0
 	struct device *dev = (struct device *) dm_hash_lookup(_cache.names, name);
ab86b0
 	struct stat st;
ab86b0
@@ -1485,13 +1440,18 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
ab86b0
 	if (dev && (dev->flags & DEV_REGULAR))
ab86b0
 		return dev;
ab86b0
 
ab86b0
+	if (dev && dm_list_empty(&dev->aliases)) {
ab86b0
+		/* shouldn't happen */
ab86b0
+		log_warn("Ignoring dev with no valid paths for %s.", name);
ab86b0
+		return NULL;
ab86b0
+	}
ab86b0
+
ab86b0
 	/*
ab86b0
-	 * The requested path is invalid, remove any dev-cache
ab86b0
-	 * info for it.
ab86b0
+	 * The requested path is invalid, remove any dev-cache info for it.
ab86b0
 	 */
ab86b0
 	if (stat(name, &st)) {
ab86b0
 		if (dev) {
ab86b0
-			log_print("Device path %s is invalid for %d:%d %s.",
ab86b0
+			log_debug("Device path %s is invalid for %d:%d %s.",
ab86b0
 				  name, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev_name(dev));
ab86b0
 
ab86b0
 			dm_hash_remove(_cache.names, name);
ab86b0
@@ -1499,11 +1459,17 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
ab86b0
 			_remove_alias(dev, name);
ab86b0
 
ab86b0
 			/* Remove any other names in dev->aliases that are incorrect. */
ab86b0
-			_verify_aliases(dev, NULL);
ab86b0
+			_verify_aliases(dev);
ab86b0
 		}
ab86b0
 		return NULL;
ab86b0
 	}
ab86b0
 
ab86b0
+	if (dev && dm_list_empty(&dev->aliases)) {
ab86b0
+		/* shouldn't happen */
ab86b0
+		log_warn("Ignoring dev with no valid paths for %s.", name);
ab86b0
+		return NULL;
ab86b0
+	}
ab86b0
+
ab86b0
 	if (!S_ISBLK(st.st_mode)) {
ab86b0
 		log_debug("Not a block device %s.", name);
ab86b0
 		return NULL;
ab86b0
@@ -1514,26 +1480,110 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
ab86b0
 	 * Remove incorrect info and then add new dev-cache entry.
ab86b0
 	 */
ab86b0
 	if (dev && (st.st_rdev != dev->dev)) {
ab86b0
-		log_debug("Device path %s does not match %d:%d %s.",
ab86b0
-			  name, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev_name(dev));
ab86b0
+		struct device *dev_by_devt = (struct device *) btree_lookup(_cache.devices, (uint32_t) st.st_rdev);
ab86b0
+
ab86b0
+		/*
ab86b0
+		 * lvm commands create this condition when they
ab86b0
+		 * activate/deactivate LVs combined with creating new LVs.
ab86b0
+		 * The command does not purge dev structs when deactivating
ab86b0
+		 * an LV (which it probably should do), but the better
ab86b0
+		 * approach would be not using dev-cache at all for LVs.
ab86b0
+		 */
ab86b0
 
ab86b0
-		dm_hash_remove(_cache.names, name);
ab86b0
+		log_debug("Dropping aliases for device entry %d:%d %s for new device %d:%d %s.",
ab86b0
+			  (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev_name(dev),
ab86b0
+			  (int)MAJOR(st.st_rdev), (int)MINOR(st.st_rdev), name);
ab86b0
 
ab86b0
-		_remove_alias(dev, name);
ab86b0
+		_drop_all_aliases(dev);
ab86b0
 
ab86b0
-		/* Remove any other names in dev->aliases that are incorrect. */
ab86b0
-		_verify_aliases(dev, NULL);
ab86b0
+		if (dev_by_devt) {
ab86b0
+			log_debug("Dropping aliases for device entry %d:%d %s for new device %d:%d %s.",
ab86b0
+				   (int)MAJOR(dev_by_devt->dev), (int)MINOR(dev_by_devt->dev), dev_name(dev_by_devt),
ab86b0
+				   (int)MAJOR(st.st_rdev), (int)MINOR(st.st_rdev), name);
ab86b0
 
ab86b0
-		/* Add new dev-cache entry next. */
ab86b0
-		dev = NULL;
ab86b0
+			_drop_all_aliases(dev_by_devt);
ab86b0
+		}
ab86b0
+
ab86b0
+#if 0
ab86b0
+		/*
ab86b0
+		 * I think only lvm's own dm devs should be added here, so use
ab86b0
+		 * a warning to look for any other unknown cases.
ab86b0
+		 */
ab86b0
+		if (MAJOR(st.st_rdev) != cmd->dev_types->device_mapper_major) {
ab86b0
+			log_warn("WARNING: new device appeared %d:%d %s",
ab86b0
+				  (int)MAJOR(st.st_rdev), (int)(MINOR(st.st_rdev)), name);
ab86b0
+		}
ab86b0
+#endif
ab86b0
+
ab86b0
+		if (!_insert_dev(name, st.st_rdev))
ab86b0
+			return_NULL;
ab86b0
+
ab86b0
+		/* Get the struct dev that was just added. */
ab86b0
+		dev = (struct device *) dm_hash_lookup(_cache.names, name);
ab86b0
+
ab86b0
+		if (!dev) {
ab86b0
+			log_error("Failed to get device %s", name);
ab86b0
+			return NULL;
ab86b0
+		}
ab86b0
+
ab86b0
+		goto out;
ab86b0
 	}
ab86b0
 
ab86b0
+	if (dev && dm_list_empty(&dev->aliases)) {
ab86b0
+		/* shouldn't happen */
ab86b0
+		log_warn("Ignoring dev with no valid paths for %s.", name);
ab86b0
+		return NULL;
ab86b0
+	}
ab86b0
+
ab86b0
+	if (!dev && existing)
ab86b0
+		return_NULL;
ab86b0
+
ab86b0
 	/*
ab86b0
-	 * Either add a new struct dev for st_rdev and name,
ab86b0
-	 * or add name as a new alias for an existing struct dev
ab86b0
-	 * for st_rdev.
ab86b0
+	 * This case should never be hit for a PV. It should only
ab86b0
+	 * happen when the command is opening a new LV it has created.
ab86b0
+	 * Add an arg to all callers indicating when the arg should be
ab86b0
+	 * new (for an LV) and not existing.
ab86b0
+	 * FIXME: fix this further by not using dev-cache struct devs
ab86b0
+	 * at all for new dm devs (LVs) that lvm uses.  Make the
ab86b0
+	 * dev-cache contain only devs for PVs.
ab86b0
+	 * Places to fix that use a dev for LVs include:
ab86b0
+	 * . lv_resize opening lv to discard
ab86b0
+	 * . wipe_lv opening lv to zero it
ab86b0
+	 * . _extend_sanlock_lv opening lv to extend it
ab86b0
+	 * . _write_log_header opening lv to write header
ab86b0
+	 * Also, io to LVs should not go through bcache.
ab86b0
+	 * bcache should contain only labels and metadata
ab86b0
+	 * scanned from PVs.
ab86b0
 	 */
ab86b0
 	if (!dev) {
ab86b0
+		/*
ab86b0
+		 * This case should only be used for new devices created by this
ab86b0
+		 * command (opening LVs it's created), so if a dev exists for the
ab86b0
+		 * dev_t referenced by the name, then drop all aliases for before
ab86b0
+		 * _insert_dev adds the new name.  lvm commands actually hit this
ab86b0
+		 * fairly often when it uses some LV, deactivates the LV, then
ab86b0
+		 * creates some new LV which ends up with the same major:minor.
ab86b0
+		 * Without dropping the aliases, it's plausible that lvm commands
ab86b0
+		 * could end up using the wrong dm device.
ab86b0
+		 */
ab86b0
+		struct device *dev_by_devt = (struct device *) btree_lookup(_cache.devices, (uint32_t) st.st_rdev);
ab86b0
+		if (dev_by_devt) {
ab86b0
+			log_debug("Dropping aliases for %d:%d before adding new path %s.",
ab86b0
+				  (int)MAJOR(st.st_rdev), (int)(MINOR(st.st_rdev)), name);
ab86b0
+			_drop_all_aliases(dev_by_devt);
ab86b0
+		}
ab86b0
+
ab86b0
+#if 0
ab86b0
+		/*
ab86b0
+		 * I think only lvm's own dm devs should be added here, so use
ab86b0
+		 * a warning to look for any other unknown cases.
ab86b0
+		 */
ab86b0
+		if (MAJOR(st.st_rdev) != cmd->dev_types->device_mapper_major) {
ab86b0
+			log_warn("WARNING: new device appeared %d:%d %s",
ab86b0
+				  (int)MAJOR(st.st_rdev), (int)(MINOR(st.st_rdev)), name);
ab86b0
+		}
ab86b0
+#endif
ab86b0
+
ab86b0
 		if (!_insert_dev(name, st.st_rdev))
ab86b0
 			return_NULL;
ab86b0
 
ab86b0
@@ -1544,10 +1594,9 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
ab86b0
 			log_error("Failed to get device %s", name);
ab86b0
 			return NULL;
ab86b0
 		}
ab86b0
-
ab86b0
-		_verify_aliases(dev, name);
ab86b0
 	}
ab86b0
 
ab86b0
+ out:
ab86b0
 	/*
ab86b0
 	 * The caller passed a filter if they only want the dev if it
ab86b0
 	 * passes filters.
ab86b0
@@ -1577,6 +1626,16 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
ab86b0
 	return dev;
ab86b0
 }
ab86b0
 
ab86b0
+struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f)
ab86b0
+{
ab86b0
+	return _dev_cache_get(cmd, name, f, 1);
ab86b0
+}
ab86b0
+
ab86b0
+struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f)
ab86b0
+{
ab86b0
+	return _dev_cache_get(cmd, name, f, 0);
ab86b0
+}
ab86b0
+
ab86b0
 struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt)
ab86b0
 {
ab86b0
 	struct device *dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devt);
ab86b0
@@ -1653,8 +1712,10 @@ int dev_fd(struct device *dev)
ab86b0
 
ab86b0
 const char *dev_name(const struct device *dev)
ab86b0
 {
ab86b0
-	return (dev && dev->aliases.n) ? dm_list_item(dev->aliases.n, struct dm_str_list)->str :
ab86b0
-	    unknown_device_name();
ab86b0
+	if (dev && dev->aliases.n && !dm_list_empty(&dev->aliases))
ab86b0
+		return dm_list_item(dev->aliases.n, struct dm_str_list)->str;
ab86b0
+	else
ab86b0
+		return unknown_device_name();
ab86b0
 }
ab86b0
 
ab86b0
 bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
ab86b0
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
ab86b0
index 7305eeb0e..51c3fc6c3 100644
ab86b0
--- a/lib/device/dev-cache.h
ab86b0
+++ b/lib/device/dev-cache.h
ab86b0
@@ -53,7 +53,7 @@ int dev_cache_has_scanned(void);
ab86b0
 
ab86b0
 int dev_cache_add_dir(const char *path);
ab86b0
 struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
ab86b0
-
ab86b0
+struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f);
ab86b0
 struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
ab86b0
 
ab86b0
 struct device *dev_hash_get(const char *name);
ab86b0
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
ab86b0
index b4f1930b1..811ad8978 100644
ab86b0
--- a/lib/device/dev-io.c
ab86b0
+++ b/lib/device/dev-io.c
ab86b0
@@ -58,6 +58,9 @@ static int _dev_get_size_file(struct device *dev, uint64_t *size)
ab86b0
 	const char *name = dev_name(dev);
ab86b0
 	struct stat info;
ab86b0
 
ab86b0
+	if (dm_list_empty(&dev->aliases))
ab86b0
+		return_0;
ab86b0
+
ab86b0
 	if (dev->size_seqno == _dev_size_seqno) {
ab86b0
 		log_very_verbose("%s: using cached size %" PRIu64 " sectors",
ab86b0
 				 name, dev->size);
ab86b0
@@ -87,7 +90,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
ab86b0
 	int do_close = 0;
ab86b0
 
ab86b0
 	if (dm_list_empty(&dev->aliases))
ab86b0
-		return 0;
ab86b0
+		return_0;
ab86b0
 
ab86b0
 	if (dev->size_seqno == _dev_size_seqno) {
ab86b0
 		log_very_verbose("%s: using cached size %" PRIu64 " sectors",
ab86b0
@@ -305,6 +308,13 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
ab86b0
 	if ((flags & O_EXCL))
ab86b0
 		need_excl = 1;
ab86b0
 
ab86b0
+	if (dm_list_empty(&dev->aliases)) {
ab86b0
+		/* shouldn't happen */
ab86b0
+		log_print("Cannot open device %d:%d with no valid paths.", (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
ab86b0
+		return 0;
ab86b0
+	}
ab86b0
+	name = dev_name(dev);
ab86b0
+
ab86b0
 	if (dev->fd >= 0) {
ab86b0
 		if (((dev->flags & DEV_OPENED_RW) || !need_rw) &&
ab86b0
 		    ((dev->flags & DEV_OPENED_EXCL) || !need_excl)) {
ab86b0
@@ -314,7 +324,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
ab86b0
 
ab86b0
 		if (dev->open_count && !need_excl)
ab86b0
 			log_debug_devs("%s: Already opened read-only. Upgrading "
ab86b0
-				       "to read-write.", dev_name(dev));
ab86b0
+				       "to read-write.", name);
ab86b0
 
ab86b0
 		/* dev_close_immediate will decrement this */
ab86b0
 		dev->open_count++;
ab86b0
@@ -327,11 +337,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
ab86b0
 
ab86b0
 	if (critical_section())
ab86b0
 		/* FIXME Make this log_error */
ab86b0
-		log_verbose("dev_open(%s) called while suspended",
ab86b0
-			    dev_name(dev));
ab86b0
-
ab86b0
-	if (!(name = dev_name_confirmed(dev, quiet)))
ab86b0
-		return_0;
ab86b0
+		log_verbose("dev_open(%s) called while suspended", name);
ab86b0
 
ab86b0
 #ifdef O_DIRECT_SUPPORT
ab86b0
 	if (direct) {
ab86b0
@@ -372,9 +378,9 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
ab86b0
 		}
ab86b0
 #endif
ab86b0
 		if (quiet)
ab86b0
-			log_sys_debug("open", name);
ab86b0
+			log_debug("Failed to open device path %s (%d).", name, errno);
ab86b0
 		else
ab86b0
-			log_sys_error("open", name);
ab86b0
+			log_error("Failed to open device path %s (%d).", name, errno);
ab86b0
 
ab86b0
 		dev->flags |= DEV_OPEN_FAILURE;
ab86b0
 		return 0;
ab86b0
@@ -415,10 +421,12 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
ab86b0
 	if ((flags & O_CREAT) && !(flags & O_TRUNC))
ab86b0
 		dev->end = lseek(dev->fd, (off_t) 0, SEEK_END);
ab86b0
 
ab86b0
-	log_debug_devs("Opened %s %s%s%s", dev_name(dev),
ab86b0
-		       dev->flags & DEV_OPENED_RW ? "RW" : "RO",
ab86b0
-		       dev->flags & DEV_OPENED_EXCL ? " O_EXCL" : "",
ab86b0
-		       dev->flags & DEV_O_DIRECT ? " O_DIRECT" : "");
ab86b0
+	if (!quiet) {
ab86b0
+		log_debug_devs("Opened %s %s%s%s", name,
ab86b0
+				dev->flags & DEV_OPENED_RW ? "RW" : "RO",
ab86b0
+				dev->flags & DEV_OPENED_EXCL ? " O_EXCL" : "",
ab86b0
+				dev->flags & DEV_O_DIRECT ? " O_DIRECT" : "");
ab86b0
+	}
ab86b0
 
ab86b0
 	dev->flags &= ~DEV_OPEN_FAILURE;
ab86b0
 	return 1;
ab86b0
diff --git a/lib/device/device.h b/lib/device/device.h
ab86b0
index 8c3a8c30e..572994bb9 100644
ab86b0
--- a/lib/device/device.h
ab86b0
+++ b/lib/device/device.h
ab86b0
@@ -204,9 +204,6 @@ struct device *dev_create_file(const char *filename, struct device *dev,
ab86b0
 			       struct dm_str_list *alias, int use_malloc);
ab86b0
 void dev_destroy_file(struct device *dev);
ab86b0
 
ab86b0
-/* Return a valid device name from the alias list; NULL otherwise */
ab86b0
-const char *dev_name_confirmed(struct device *dev, int quiet);
ab86b0
-
ab86b0
 int dev_mpath_init(const char *config_wwids_file);
ab86b0
 void dev_mpath_exit(void);
ab86b0
 
ab86b0
-- 
ab86b0
2.34.3
ab86b0