Skip to contentSkip to conversation

master - pvscan: avoid full scan for activation

PATCH David Teigland 1 participant 1 message Sep 3, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=25b58310e3d606a85abc9bd50991ccb7ddcbfe25
Commit:        25b58310e3d606a85abc9bd50991ccb7ddcbfe25
Parent:        98d420200e16b450b6b7e33b83bdf36a59196d6d
Author:        David Teigland <[email protected]>
AuthorDate:    Mon Aug 26 17:07:18 2019 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Tue Sep 3 10:11:16 2019 -0500

pvscan: avoid full scan for activation

When an online PV completed a VG, the standard activation functions were used to activate the VG. These functions use a full scan of all devs. When many pvscans are run during startup and need to activate many VGs, scanning all devs from all the pvscans can take a long time.

Optimize VG activation in pvscan to scan only the devs in the VG being activated. This makes use of the online file info that was used to determine the VG was complete.

The downside of this approach is that pvscan activation will not detect duplicate PVs and block activation, where a normal activation command (which scans all devices) would.

---
 lib/metadata/metadata-exported.h |    7 +
 lib/metadata/metadata.c          |    3 +-
 test/shell/duplicate-pvs-md1.sh  |  108 +++++++---
 test/shell/metadata-bad-text.sh  |  106 +++++++++
 tools/pvscan.c                   |  452 +++++++++++++++++++++++++++++++-------
 tools/toollib.c                  |    6 -
 6 files changed, 568 insertions(+), 114 deletions(-)
lib/metadata/metadata-exported.h +7 -0
index e1767b7..a910aa3 100644
@@ -186,6 +186,7 @@
 #define READ_FOR_UPDATE		0x00100000U /* command tells vg_read it plans to write the vg */
 #define PROCESS_SKIP_SCAN	0x00200000U /* skip lvmcache_label_scan in process_each_pv */
 #define READ_FOR_ACTIVATE	0x00400000U /* command tells vg_read it plans to activate the vg */
+#define READ_WITHOUT_LOCK	0x00800000U /* caller responsible for vg lock */
 
 /* vg_read returns these in error_flags */
 #define FAILED_NOT_ENABLED	0x00000001U
@@ -559,6 +560,12 @@ struct vgnameid_list {
 	const char *vgid;
 };
 
+struct device_id_list {
+	struct dm_list list;
+	struct device *dev;
+	char pvid[ID_LEN + 1];
+};
+
 #define PV_PE_START_CALC ((uint64_t) -1) /* Calculate pe_start value */
 
 /*
lib/metadata/metadata.c +2 -1
index 61906cc..b434967 100644
@@ -4917,7 +4917,8 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
 	 * of needing to write to them.
 	 */
 
-	if (!lock_vol(cmd, vg_name, (writing || activating) ? LCK_VG_WRITE : LCK_VG_READ, NULL)) {
+	if (!(read_flags & READ_WITHOUT_LOCK) &&
+	    !lock_vol(cmd, vg_name, (writing || activating) ? LCK_VG_WRITE : LCK_VG_READ, NULL)) {
 		log_error("Can't get lock for %s", vg_name);
 		failure |= FAILED_LOCKING;
 		goto_bad;
test/shell/duplicate-pvs-md1.sh +76 -32

161 lines not on this page · raw message

test/shell/metadata-bad-text.sh +106 -0

115 lines not on this page · raw message

tools/pvscan.c +377 -75

653 lines not on this page · raw message

tools/toollib.c +0 -6
index 1f41feb..bb97e15 100644
@@ -26,12 +26,6 @@
 					((ret_code) == ECMD_PROCESSED) ? REPORT_OBJECT_CMDLOG_SUCCESS \
 								   : REPORT_OBJECT_CMDLOG_FAILURE, (ret_code))
 
-struct device_id_list {
-	struct dm_list list;
-	struct device *dev;
-	char pvid[ID_LEN + 1];
-};
-
 const char *command_name(struct cmd_context *cmd)
 {
 	return cmd->command->name;