Skip to contentSkip to conversation

master - metadata: create historical LVs when LVs are removed and interconnect with live LVs

PATCH Peter Rajnoha 1 participant 1 message Mar 3, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=790b2e874822767808f3c5bcc4ce1499944969ff
Commit:        790b2e874822767808f3c5bcc4ce1499944969ff
Parent:        eeaa5a4481e04c0131152fd88e6ea2651949ae35
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Tue Mar 1 15:20:09 2016 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Thu Mar 3 11:26:51 2016 +0100

metadata: create historical LVs when LVs are removed and interconnect with live LVs

When an LV is being removed, we create an instance of "struct historical_logical_volume" wrapped up in "struct generic_logical_volume".

All instances of "struct historical_logical_volume" are then recorded in "historical_lvs" list which is part of "struct volume_group".

The "historical LV" is then interconnected with "live LVs" to connect a history chain for the live LV.

---
 lib/metadata/metadata.c   |   25 ++++++++++
 lib/metadata/pool_manip.c |  118 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 143 insertions(+), 0 deletions(-)
lib/metadata/metadata.c +25 -0
index 5e84e96..0d2211a 100644
@@ -32,6 +32,7 @@
 #include "archiver.h"
 #include "defaults.h"
 #include "lvmlockd.h"
+#include "time.h"
 
 #include <math.h>
 #include <sys/param.h>
@@ -3182,6 +3183,25 @@ static int _check_old_pv_ext_for_vg(struct volume_group *vg)
 	return 1;
 }
 
+static int _handle_historical_lvs(struct volume_group *vg)
+{
+	struct glv_list *glvl;
+	time_t current_timestamp = 0;
+	struct historical_logical_volume *hlv;
+
+	dm_list_iterate_items(glvl, &vg->historical_lvs) {
+		hlv = glvl->glv->historical;
+
+		if (!hlv->timestamp_removed) {
+			if (!current_timestamp)
+				current_timestamp = time(NULL);
+			hlv->timestamp_removed = (uint64_t) current_timestamp;
+		}
+	}
+
+	return 1;
+}
+
 /*
  * After vg_write() returns success,
  * caller MUST call either vg_commit() or vg_revert()
@@ -3205,6 +3225,11 @@ int vg_write(struct volume_group *vg)
 		}
 	}
 
+	if (!_handle_historical_lvs(vg)) {
+		log_error("Failed to handle historical LVs in VG %s.", vg->name);
+		return 0;
+	}
+
 	if (!vg_validate(vg))
 		return_0;
 
lib/metadata/pool_manip.c +118 -0

153 lines not on this page · raw message