Skip to contentSkip to conversation

master - scan: add PV summary info to lvmcache

PATCH David Teigland 1 participant 1 message Sep 30, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f3084ee2e577abe05e4707730f3cb96f2cb5ec45
Commit:        f3084ee2e577abe05e4707730f3cb96f2cb5ec45
Parent:        0c23d3fc8402e49e61c9c490d9c2c9c2d58596e8
Author:        David Teigland <[email protected]>
AuthorDate:    Thu Sep 26 11:27:38 2019 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Sep 30 11:38:10 2019 -0500

scan: add PV summary info to lvmcache

Expand the lvmcache info that is saved by the scan to include PV info from the metadata.

---
 lib/cache/lvmcache.c          |   16 +++++++
 lib/cache/lvmcache.h          |   12 ++---
 lib/format_text/format-text.c |    2 +
 lib/format_text/import_vsn1.c |   96 +++++++++++++++++++++++++++++++++-------
 lib/format_text/text_label.c  |    2 +
 5 files changed, 103 insertions(+), 25 deletions(-)
lib/cache/lvmcache.c +16 -0
index 29d6446..7ee94c2 100644
@@ -53,6 +53,7 @@ struct lvmcache_vginfo {
 	struct dm_list list;	/* Join these vginfos together */
 	struct dm_list infos;	/* List head for lvmcache_infos */
 	struct dm_list outdated_infos; /* vg_read moves info from infos to outdated_infos */
+	struct dm_list pvsummaries; /* pv_list taken directly from vgsummary */
 	const struct format_type *fmt;
 	char *vgname;		/* "" == orphan */
 	uint32_t status;
@@ -1295,6 +1296,7 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
 		}
 		dm_list_init(&vginfo->infos);
 		dm_list_init(&vginfo->outdated_infos);
+		dm_list_init(&vginfo->pvsummaries);
 
 		/*
 		 * A different VG (different uuid) can exist with the same name.
@@ -1418,6 +1420,18 @@ int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt)
 	return _lvmcache_update_vgname(NULL, vgname, vgname, 0, "", fmt);
 }
 
+static void _lvmcache_update_pvsummaries(struct lvmcache_vginfo *vginfo, struct lvmcache_vgsummary *vgsummary)
+{
+	struct pv_list *pvl, *safe;
+
+	dm_list_init(&vginfo->pvsummaries);
+
+	dm_list_iterate_items_safe(pvl, safe, &vgsummary->pvsummaries) {
+		dm_list_del(&pvl->list);
+		dm_list_add(&vginfo->pvsummaries, &pvl->list);
+	}
+}
+
 /*
  * Returning 0 causes the caller to remove the info struct for this
  * device from lvmcache, which will make it look like a missing device.
@@ -1582,6 +1596,8 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info, struct lvmcache_vg
 		log_error("Failed to update VG %s info in lvmcache.", vgname);
 	}
 
+	_lvmcache_update_pvsummaries(vginfo, vgsummary);
+
 	return 1;
 }
 
lib/cache/lvmcache.h +4 -8
index 89fbe6f..1401974 100644
@@ -41,14 +41,9 @@ struct lvmcache_vginfo;
 
 /*
  * vgsummary represents a summary of the VG that is read
- * without a lock.  The info does not come through vg_read(),
- * but through reading mdas.  It provides information about
- * the VG that is needed to lock the VG and then read it fully
- * with vg_read(), after which the VG summary should be checked
- * against the full VG metadata to verify it was correct (since
- * it was read without a lock.)
- *
- * Once read, vgsummary information is saved in lvmcache_vginfo.
+ * without a lock during label scan.  It's used to populate
+ * basic lvmcache vginfo/info during label scan prior to
+ * vg_read().
  */
 struct lvmcache_vgsummary {
 	const char *vgname;
@@ -63,6 +58,7 @@ struct lvmcache_vgsummary {
 	int mda_num; /* 1 = summary from mda1, 2 = summary from mda2 */
 	unsigned mda_ignored:1;
 	unsigned zero_offset:1;
+	struct dm_list pvsummaries;
 };
 
 int lvmcache_init(struct cmd_context *cmd);
lib/format_text/format-text.c +2 -0
index 2a5c8ec..be4730b 100644
@@ -278,6 +278,8 @@ static struct raw_locn *_read_metadata_location_vg(struct device_area *dev_area,
 	};
 	int rlocn_was_ignored;
 
+	dm_list_init(&vgsummary_orphan.pvsummaries);
+
 	memcpy(&vgsummary_orphan.vgid, FMT_TEXT_ORPHAN_VG_NAME, sizeof(FMT_TEXT_ORPHAN_VG_NAME));
 
 	rlocn = mdah->raw_locns;	/* Slot 0 */
lib/format_text/import_vsn1.c +79 -17

192 lines not on this page · raw message

lib/format_text/text_label.c +2 -0
index 934bc73..41276be 100644
@@ -498,6 +498,7 @@ static int _text_read(struct labeller *labeller, struct device *dev, void *label
 	if (mda1) {
 		log_debug_metadata("Scanning %s mda1 summary.", dev_name(dev));
 		memset(&vgsummary, 0, sizeof(vgsummary));
+		dm_list_init(&vgsummary.pvsummaries);
 		bad_fields = 0;
 		vgsummary.mda_num = 1;
 
@@ -541,6 +542,7 @@ static int _text_read(struct labeller *labeller, struct device *dev, void *label
 	if (mda2) {
 		log_debug_metadata("Scanning %s mda2 summary.", dev_name(dev));
 		memset(&vgsummary, 0, sizeof(vgsummary));
+		dm_list_init(&vgsummary.pvsummaries);
 		bad_fields = 0;
 		vgsummary.mda_num = 2;