Skip to contentSkip to conversation

Remove empty "repaired" devices if empty in lvconvert.

PATCH New Milan Broz 1 participant 1 message Dec 20, 2009

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Remove empty "repaired" devices if empty in lvconvert.

beware: this is quite controversial patch

The logic was that lvconvert repair volumes, marking PV as MISSING and following vgreduce --removemissing removes these missing devices.

Previously dmeventd mirror DSO removed all LV and PV from VG by simply relying on
vgreduce --removemissing --force.

Now, there are two subsequent calls:
lvconvert --repair --use-policies
vgreduce --removemissing

So the VG is locked twice, opening space for all races between other running lvm processes. If the PV reappears with old metadata on it (so the winner performs autorepair, if locking VG for update) the situation is even worse.

Note, that failed log device blocks - so all scans are blocked too incereasing probabilyty of that race, all processes waiting for lvconvert repair and fires before vgreduce can take the action.

My patch simply adds removemissing PV functionality into lvconcert BUT ONLY if running with --repair and --use-policies and removing only these empty missing PVs which are involved in repair.
(This combination is expected to run only from dmeventd.)

Note, that if PV reapears, autorepair logic now decicdes to remove reappeared PV from VG.

---
 daemons/dmeventd/plugins/mirror/dmeventd_mirror.c |    6 +--
 tools/lvconvert.c                                 |   56 ++++++++++++++++++++-
 2 files changed, 56 insertions(+), 6 deletions(-)
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c +1 -5
index 00a15bb..d1d9ca6 100644
@@ -193,11 +193,7 @@ static int _remove_failed_devices(const char *device)
 
 	r = lvm2_run(_lvm_handle, cmd_str);
 
-	if (r == ECMD_PROCESSED) {
-		snprintf(cmd_str, CMD_SIZE, "vgreduce --removemissing %s", vg);
-		if (lvm2_run(_lvm_handle, cmd_str) != 1)
-			syslog(LOG_ERR, "Unable to remove failed PVs from VG %s", vg);
-	}
+	syslog(LOG_INFO, "Repair of mirrored LV %s/%s %s.", vg, lv, (r == ECMD_PROCESSED) ? "finished successfully" : "failed");
 
 	dm_pool_empty(_mem_pool);  /* FIXME: not safe with multiple threads */
 	return (r == ECMD_PROCESSED) ? 0 : -1;
tools/lvconvert.c +55 -1

86 lines not on this page · raw message

Signature · 1 line
1.6.5.7