Skip to contentSkip to conversation

2018-06-01-stable - pvscan lvmetad: use udev info to improve md component detection

PATCH David Teigland 1 participant 1 message Dec 3, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a188b1e513ed5ca0f5f3702c823490f5610d4495
Commit:        a188b1e513ed5ca0f5f3702c823490f5610d4495
Parent:        9764ee0b3f21ed717e1b6248ce4c41dd552bb0ec
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Nov 30 16:32:32 2018 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Dec 3 11:05:35 2018 -0600

pvscan lvmetad: use udev info to improve md component detection

When no md devs are started, pvscan will only scan the start of an md component, and if it has a superblock at the end may not exclude it. udev may already have info identifying it as an md component, so use that.

---
 lib/device/dev-md.c   |   14 +++++++++-
 lib/device/dev-type.c |   62 +++++++++++++++++++++++++++++++++++++++---------
 lib/device/dev-type.h |    1 +
 lib/label/label.c     |    6 ++++
 tools/pvscan.c        |    3 +-
 5 files changed, 71 insertions(+), 15 deletions(-)
lib/device/dev-md.c +12 -2
index 185499b..9728507 100644
@@ -190,14 +190,24 @@ out:
 
 int dev_is_md(struct device *dev, uint64_t *offset_found, int full)
 {
+	int ret;
 
 	/*
 	 * If non-native device status source is selected, use it
 	 * only if offset_found is not requested as this
 	 * information is not in udev db.
 	 */
-	if ((dev->ext.src == DEV_EXT_NONE) || offset_found)
-		return _native_dev_is_md(dev, offset_found, full);
+	if ((dev->ext.src == DEV_EXT_NONE) || offset_found) {
+		ret = _native_dev_is_md(dev, offset_found, full);
+
+		if (!full) {
+			if (!ret || (ret == -EAGAIN)) {
+				if (udev_dev_is_md_component(dev))
+					return 1;
+			}
+		}
+		return ret;
+	}
 
 	if (dev->ext.src == DEV_EXT_UDEV)
 		return _udev_dev_is_md(dev);
lib/device/dev-type.c +50 -12

111 lines not on this page · raw message

lib/device/dev-type.h +1 -0
index f629a02..2644383 100644
@@ -62,6 +62,7 @@ int dev_is_swap(struct device *dev, uint64_t *signature, int full);
 int dev_is_luks(struct device *dev, uint64_t *signature, int full);
 int dasd_is_cdl_formatted(struct device *dev);
 int udev_dev_is_mpath_component(struct device *dev);
+int udev_dev_is_md_component(struct device *dev);
 
 int dev_is_lvm1(struct device *dev, char *buf, int buflen);
 int dev_is_pool(struct device *dev, char *buf, int buflen);
lib/label/label.c +6 -0
index b26ff33..e01608d 100644
@@ -957,6 +957,12 @@ int label_scan_pvscan_all(struct cmd_context *cmd, struct dm_list *scan_devs)
 			bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
 			_scan_dev_close(dev);
 		}
+
+		if (dev_is_md_with_end_superblock(cmd->dev_types, dev)) {
+			cmd->use_full_md_check = 1;
+			use_full_md_check = 1;
+			log_debug("Found md component in sysfs with end superblock %s", dev_name(dev));
+		}
 	};
 	dev_iter_destroy(iter);
 
tools/pvscan.c +2 -1
index 3755684..877b6b2 100644
@@ -455,7 +455,8 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
 		if (dev_is_md_with_end_superblock(cmd->dev_types, dev)) {
 			cmd->use_full_md_check = 1;
 			use_full_md_check = 1;
-			log_debug("Found md with end superblock %s", dev_name(dev));
+			log_debug("Found md component in sysfs with end superblock %s", dev_name(dev));
+			break;
 		}
 	}
 	dev_iter_destroy(iter);