Skip to contentSkip to conversation

master - lvmlockd: enable repairing shared VG while reading it

PATCH David Teigland 1 participant 1 message May 31, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6cd052333719e4ae23bfaaa03011ed1a2f384f69
Commit:        6cd052333719e4ae23bfaaa03011ed1a2f384f69
Parent:        063d065388b6437b77815cb1d13a72395a46fd45
Author:        David Teigland <[email protected]>
AuthorDate:    Wed May 30 12:48:18 2018 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Wed May 30 12:56:46 2018 -0500

lvmlockd: enable repairing shared VG while reading it

When the lvmlockd lock is shared, upgrade it to ex when repair (writing) is needed during vg_read.

Pass the lockd state through additional read-related functions so the instances of repair scattered through vg_read can be handled.

(Temporary solution until the ad hoc repairs can be pulled out of vg_read into a top level, centralized repair function.)

---
 daemons/clvmd/lvm-functions.c    |    2 +-
 lib/metadata/metadata-exported.h |    2 +-
 lib/metadata/metadata.c          |   75 +++++++++++++++++++++-----------------
 tools/toollib.c                  |    2 +-
 4 files changed, 45 insertions(+), 36 deletions(-)
daemons/clvmd/lvm-functions.c +1 -1
index 34da66d..24ed7a0 100644
@@ -832,7 +832,7 @@ void lvm_do_backup(const char *vgname)
 
 	pthread_mutex_lock(&lvm_lock);
 
-	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, WARN_PV_READ, &consistent);
+	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, 0, WARN_PV_READ, &consistent);
 
 	if (vg && consistent)
 		check_current_backup(vg);
lib/metadata/metadata-exported.h +1 -1
index 97184ed..ccf6004 100644
@@ -652,7 +652,7 @@ int vg_write(struct volume_group *vg);
 int vg_commit(struct volume_group *vg);
 void vg_revert(struct volume_group *vg);
 struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
-				      const char *vgid, uint32_t warn_flags, int *consistent);
+				      const char *vgid, uint32_t lockd_state, uint32_t warn_flags, int *consistent);
 
 #define get_pvs( cmd ) get_pvs_internal((cmd), NULL, NULL)
 #define get_pvs_perserve_vg( cmd, pv_list, vg_list ) get_pvs_internal((cmd), (pv_list), (vg_list))
lib/metadata/metadata.c +42 -33

209 lines not on this page · raw message

tools/toollib.c +1 -1
index 0fc86cf..19f4c33 100644
@@ -5730,7 +5730,7 @@ do_command:
 	if (pp->preserve_existing && pp->orphan_vg_name) {
 		log_debug("Using existing orphan PVs in %s.", pp->orphan_vg_name);
 
-		if (!(orphan_vg = vg_read_internal(cmd, pp->orphan_vg_name, NULL, 0, &consistent))) {
+		if (!(orphan_vg = vg_read_internal(cmd, pp->orphan_vg_name, NULL, 0, 0, &consistent))) {
 			log_error("Cannot read orphans VG %s.", pp->orphan_vg_name);
 			goto bad;
 		}