summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2015-08-11 15:00:11 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-02-19 14:40:22 +0100
commit82de78c12a068668bf52c43762ac3989238bca6d (patch)
tree3e847827b232ea63628f0bc9d1de278b361e75b3
parent79ddeee2e7e297e92e5f631e47d8fe2448f73520 (diff)
downloadlvm2-82de78c12a068668bf52c43762ac3989238bca6d.tar.gz
metadata: format_text: import former LVs
Import former LV list from metadata and add it to struct volume_group's former_lvs list.
-rw-r--r--lib/format_text/import_vsn1.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 71181bde4..d4a0afc6b 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -699,6 +699,77 @@ static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
return 1;
}
+static int _read_former_lvnames(struct format_instance *fid __attribute__((unused)),
+ struct volume_group *vg, const struct dm_config_node *flvn,
+ const struct dm_config_node *vgn __attribute__((unused)),
+ struct dm_hash_table *pv_hash __attribute__((unused)),
+ struct dm_hash_table *lv_hash __attribute__((unused)),
+ unsigned *scan_done_once __attribute__((unused)),
+ unsigned report_missing_devices __attribute__((unused)))
+{
+ struct dm_pool *mem = vg->vgmem;
+ struct generic_logical_volume *glv;
+ struct glv_list *glvl;
+ const char *str;
+ uint64_t timestamp;
+
+ if (!(glv = dm_pool_zalloc(mem, sizeof(struct generic_logical_volume))) ||
+ !(glv->former = dm_pool_zalloc(mem, sizeof(struct former_logical_volume))) ||
+ !(glvl = dm_pool_zalloc(mem, sizeof(struct glv_list)))) {
+ log_error("Removed logical volume structure allocation failed");
+ goto bad;
+ }
+
+ glv->is_former = 1;
+ glv->former->vg = vg;
+ dm_list_init(&glv->former->indirect_glvs);
+
+ if (!(glv->former->name = dm_pool_strdup(mem, flvn->key)))
+ goto_bad;
+
+ if (!(flvn = flvn->child)) {
+ log_error("Empty removed logical volume section.");
+ goto_bad;
+ }
+
+ if (!_read_id(&glv->former->lvid.id[1], flvn, "id")) {
+ log_error("Couldn't read uuid for removed logical volume %s in vg %s.",
+ glv->former->name, vg->name);
+ return 0;
+ }
+ memcpy(&glv->former->lvid.id[0], &glv->former->vg->id, sizeof(glv->former->lvid.id[0]));
+
+ if (dm_config_get_str(flvn, "name", &str)) {
+ if (!(glv->former->name = dm_pool_strdup(mem, str)))
+ goto_bad;
+ }
+
+ if (dm_config_has_node(flvn, "creation_time")) {
+ if (!_read_uint64(flvn, "creation_time", &timestamp)) {
+ log_error("Invalid creation_time for removed logical volume %s.", str);
+ goto bad;
+ }
+ glv->former->timestamp = timestamp;
+ }
+
+ if (dm_config_has_node(flvn, "removal_time")) {
+ if (!_read_uint64(flvn, "removal_time", &timestamp)) {
+ log_error("Invalid removal_time for removed logical volume %s.", str);
+ goto bad;
+ }
+ glv->former->timestamp_removed = timestamp;
+ }
+
+ glvl->glv = glv;
+ dm_list_add(&vg->former_lvs, &glvl->list);
+
+ return 1;
+bad:
+ if (glv)
+ dm_pool_free(mem, glv);
+ return 0;
+}
+
static int _read_lvsegs(struct format_instance *fid,
struct volume_group *vg, const struct dm_config_node *lvn,
const struct dm_config_node *vgn __attribute__((unused)),
@@ -982,6 +1053,13 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
+ if (!_read_sections(fid, "former_logical_volumes", _read_former_lvnames, vg,
+ vgn, pv_hash, lv_hash, 1, NULL)) {
+ log_error("Couldn't read all former logical volumes for volume "
+ "group %s.", vg->name);
+ goto bad;
+ }
+
if (!_read_sections(fid, "logical_volumes", _read_lvsegs, vg,
vgn, pv_hash, lv_hash, 1, NULL)) {
log_error("Couldn't read all logical volumes for "