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-03 17:40:31 +0100
commit6464cb3a42e861a1c7ab80a99e29c4afff225eff (patch)
treed7b04dbc2913f976bc2309faa69678a5acdec82e
parenta138742e4e2f884d3105f30bb1aa25209f335459 (diff)
downloadlvm2-6464cb3a42e861a1c7ab80a99e29c4afff225eff.tar.gz
metadata: format_text: import dead LVs
Import dead LV list from metadata and add it to struct volume_group's dead_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..eccef6781 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_removed_lvnames(struct format_instance *fid __attribute__((unused)),
+ struct volume_group *vg, const struct dm_config_node *rlvn,
+ 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->dead = dm_pool_zalloc(mem, sizeof(struct dead_logical_volume))) ||
+ !(glvl = dm_pool_zalloc(mem, sizeof(struct glv_list)))) {
+ log_error("Removed logical volume structure allocation failed");
+ goto bad;
+ }
+
+ glv->is_dead = 1;
+ glv->dead->vg = vg;
+ dm_list_init(&glv->dead->indirect_users);
+
+ if (!(glv->dead->dname = dm_pool_strdup(mem, rlvn->key)))
+ goto_bad;
+
+ if (!(rlvn = rlvn->child)) {
+ log_error("Empty removed logical volume section.");
+ goto_bad;
+ }
+
+ if (!_read_id(&glv->dead->lvid.id[1], rlvn, "id")) {
+ log_error("Couldn't read uuid for removed logical volume %s in vg %s.",
+ glv->dead->dname, vg->name);
+ return 0;
+ }
+ memcpy(&glv->dead->lvid.id[0], &glv->dead->vg->id, sizeof(glv->dead->lvid.id[0]));
+
+ if (dm_config_get_str(rlvn, "name", &str)) {
+ if (!(glv->dead->name = dm_pool_strdup(mem, str)))
+ goto_bad;
+ }
+
+ if (dm_config_has_node(rlvn, "creation_time")) {
+ if (!_read_uint64(rlvn, "creation_time", &timestamp)) {
+ log_error("Invalid creation_time for removed logical volume %s.", str);
+ goto bad;
+ }
+ glv->dead->timestamp = timestamp;
+ }
+
+ if (dm_config_has_node(rlvn, "removal_time")) {
+ if (!_read_uint64(rlvn, "removal_time", &timestamp)) {
+ log_error("Invalid removal_time for removed logical volume %s.", str);
+ goto bad;
+ }
+ glv->dead->timestamp_removed = timestamp;
+ }
+
+ glvl->glv = glv;
+ dm_list_add(&vg->dead_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, "removed_logical_volumes", _read_removed_lvnames, vg,
+ vgn, pv_hash, lv_hash, 1, NULL)) {
+ log_error("Couldn't read all removed 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 "