Skip to contentSkip to conversation

master - metadata: add historical_glv_remove

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=f833a6d074979813e8bd9980b719b09758bd833a
Commit:        f833a6d074979813e8bd9980b719b09758bd833a
Parent:        ccebf3100deec6196c1a66301a36cad6892ff0aa
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Tue Mar 1 15:26:57 2016 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Thu Mar 3 13:50:57 2016 +0100

metadata: add historical_glv_remove

---
 lib/format_text/import_vsn1.c    |    4 +-
 lib/metadata/lv_manip.c          |   68 ++++++++++++++++++++++++++++++++++++-
 lib/metadata/metadata-exported.h |    4 ++
 lib/metadata/metadata.c          |    5 ++-
 lib/metadata/vg.c                |    1 +
 lib/metadata/vg.h                |    5 +++
 6 files changed, 82 insertions(+), 5 deletions(-)
lib/format_text/import_vsn1.c +2 -2
index 163ea38..3bf5f7b 100644
@@ -788,7 +788,7 @@ static int _read_historical_lvnames_interconnections(struct format_instance *fid
 	historical_lv_name = hlvn->key;
 	hlvn = hlvn->child;
 
-	if (!(glv = find_historical_glv(vg, historical_lv_name, NULL))) {
+	if (!(glv = find_historical_glv(vg, historical_lv_name, 0, NULL))) {
 		log_error("Unknown historical logical volume %s/%s%s",
 			  vg->name, HISTORICAL_LV_PREFIX, historical_lv_name);
 		goto bad;
@@ -828,7 +828,7 @@ static int _read_historical_lvnames_interconnections(struct format_instance *fid
 		glvl->glv = glv;
 
 		if (!strncmp(origin_name, HISTORICAL_LV_PREFIX, strlen(HISTORICAL_LV_PREFIX))) {
-			if (!(origin_glv = find_historical_glv(vg, origin_name + strlen(HISTORICAL_LV_PREFIX), NULL))) {
+			if (!(origin_glv = find_historical_glv(vg, origin_name + strlen(HISTORICAL_LV_PREFIX), 0, NULL))) {
 				log_error("Unknown origin %s for historical logical volume %s/%s%s",
 					  origin_name, vg->name, HISTORICAL_LV_PREFIX, historical_lv_name);
 				goto bad;
lib/metadata/lv_manip.c +66 -2

86 lines not on this page · raw message

lib/metadata/metadata-exported.h +4 -0
index b8699f7..d81166d 100644
@@ -807,6 +807,9 @@ int lv_extend(struct logical_volume *lv,
 /* lv must be part of lv->vg->lvs */
 int lv_remove(struct logical_volume *lv);
 
+/* historical_glv must be part of lv->vg->historical_lvs */
+int historical_glv_remove(struct generic_logical_volume *historical_glv);
+
 int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
 		     force_t force, int suppress_remove_message);
 
@@ -1029,6 +1032,7 @@ struct logical_volume *find_lv(const struct volume_group *vg,
 
 struct generic_logical_volume *find_historical_glv(const struct volume_group *vg,
 						    const char *historical_lv_name,
+						    int check_removed_list,
 						    struct glv_list **glvl_found);
 
 struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
lib/metadata/metadata.c +4 -1
index 8b3c53c..c37c7ba 100644
@@ -2122,10 +2122,13 @@ struct logical_volume *find_lv(const struct volume_group *vg,
 
 struct generic_logical_volume *find_historical_glv(const struct volume_group *vg,
 					       const char *historical_lv_name,
+					       int check_removed_list,
 					       struct glv_list **glvl_found)
 {
 	struct glv_list *glvl;
 	const char *ptr;
+	const struct dm_list *list = check_removed_list ? &vg->removed_historical_lvs
+							: &vg->historical_lvs;
 
 	/* Use last component */
 	if ((ptr = strrchr(historical_lv_name, '/')))
@@ -2133,7 +2136,7 @@ struct generic_logical_volume *find_historical_glv(const struct volume_group *vg
 	else
 		ptr = historical_lv_name;
 
-	dm_list_iterate_items(glvl, &vg->historical_lvs) {
+	dm_list_iterate_items(glvl, list) {
 		if (!strcmp(glvl->glv->historical->name, ptr)) {
 			if (glvl_found)
 				*glvl_found = glvl;
lib/metadata/vg.c +1 -0
index 90c459e..7ac1a2c 100644
@@ -67,6 +67,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
 	dm_list_init(&vg->historical_lvs);
 	dm_list_init(&vg->tags);
 	dm_list_init(&vg->removed_lvs);
+	dm_list_init(&vg->removed_historical_lvs);
 	dm_list_init(&vg->removed_pvs);
 
 	log_debug_mem("Allocated VG %s at %p.", vg->name, vg);
lib/metadata/vg.h +5 -0
index c5197cb..069cdc8 100644
@@ -142,6 +142,11 @@ struct volume_group {
 	struct dm_list removed_lvs;
 
 	/*
+	 * List of removed historical logical volumes by historical_glv_remove.
+	 */
+	struct dm_list removed_historical_lvs;
+
+	/*
 	 * List of removed physical volumes by pvreduce.
 	 * They have to get cleared on vg_commit.
 	 */