Move commod code to destroy orphan VG into free_orphan_vg() function.
Use orphan vgmem for creation of PV lists.
Remove some free_pv_fid() calls (FIXME: check all of them)
FIXME: Check whether we could merge release_vg back again for all VGs.
Version 2.02.92 -
====================================
+ Add free_orphan_vg.
Skip pv/vg_set_fid processing if the fid is same.
Check for foreach loop errors in _vg_read_orphans() (2.02.91).
Clean error paths for format instance creation (2.02.91).
static void _format1_destroy(struct format_type *fmt)
{
- /* FIXME out of place, but the main (cmd) pool has been already
- * destroyed and touching the fid (also via release_vg) will crash the
- * program */
- dm_hash_destroy(fmt->orphan_vg->hostnames);
- dm_pool_destroy(fmt->orphan_vg->fid->mem);
- dm_pool_destroy(fmt->orphan_vg->vgmem);
+ if (fmt->orphan_vg)
+ free_orphan_vg(fmt->orphan_vg);
dm_free(fmt);
}
static void _pool_destroy(struct format_type *fmt)
{
- /* FIXME out of place, but the main (cmd) pool has been already
- * destroyed and touching the fid (also via release_vg) will crash the
- * program */
- dm_hash_destroy(fmt->orphan_vg->hostnames);
- dm_pool_destroy(fmt->orphan_vg->fid->mem);
- dm_pool_destroy(fmt->orphan_vg->vgmem);
+ if (fmt->orphan_vg)
+ free_orphan_vg(fmt->orphan_vg);
dm_free(fmt);
}
static void _text_destroy(struct format_type *fmt)
{
- /* FIXME out of place, but the main (cmd) pool has been already
- * destroyed and touching the fid (also via release_vg) will crash the
- * program */
- dm_hash_destroy(fmt->orphan_vg->fid->metadata_areas_index);
- dm_hash_destroy(fmt->orphan_vg->hostnames);
- dm_pool_destroy(fmt->orphan_vg->fid->mem);
- dm_pool_destroy(fmt->orphan_vg->vgmem);
+ if (fmt->orphan_vg)
+ free_orphan_vg(fmt->orphan_vg);
if (fmt->private) {
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
return pv;
bad:
- free_pv_fid(pv);
return NULL;
}
/**
* pv_create - initialize a physical volume for use with a volume group
+ * created PV belongs to Orphan VG.
*
* @fmt: format type
* @dev: PV device to initialize
unsigned metadataignore)
{
const struct format_type *fmt = cmd->fmt;
- struct dm_pool *mem = fmt->cmd->mem;
+ struct dm_pool *mem = fmt->orphan_vg->vgmem;
struct physical_volume *pv = _alloc_pv(mem, dev);
unsigned mda_index;
+ struct pv_list *pvl;
if (!pv)
return_NULL;
goto bad;
}
- struct pv_list *pvl;
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
log_error("pv_list allocation in pv_create failed");
goto bad;
return pv;
bad:
- free_pv_fid(pv);
- dm_pool_free(mem, pv);
+ // FIXME: detach from orphan in error path
+ //free_pv_fid(pv);
+ //dm_pool_free(mem, pv);
return NULL;
}
_free_vg(vg);
}
+/*
+ * FIXME out of place, but the main (cmd) pool has been already
+ * destroyed and touching the fid (also via release_vg) will crash the
+ * program
+ *
+ * For now quick wrapper to allow destroy of orphan vg
+ */
+void free_orphan_vg(struct volume_group *vg)
+{
+ _free_vg(vg);
+}
+
char *vg_fmt_dup(const struct volume_group *vg)
{
if (!vg->fid || !vg->fid->fmt)
* by vg_create() or vg_read_internal() to free it when no longer required.
*/
void release_vg(struct volume_group *vg);
+void free_orphan_vg(struct volume_group *vg);
char *vg_fmt_dup(const struct volume_group *vg);
char *vg_name_dup(const struct volume_group *vg);
ret = ECMD_FAILED;
}
- free_pv_fid(pv);
unlock_vg(cmd, VG_ORPHANS);
if (sigint_caught())
return ret;
pv_dev_name(pv));
log_error("Use pvcreate and vgcfgrestore to repair "
"from archived metadata.");
- free_pv_fid(pv);
return ECMD_FAILED;
}
pv_dev_name(pv));
log_error("Use pvcreate and vgcfgrestore to repair "
"from archived metadata.");
- free_pv_fid(pv);
return ECMD_FAILED;
}
log_verbose("Physical volume \"%s\" successfully created",
pv_dev_name(pv));
-
- free_pv_fid(pv);
}
log_verbose("Deleting existing metadata for VG %s", vg_name);