1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Add free_orphan_vg

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.
This commit is contained in:
Zdenek Kabelac 2012-02-13 11:03:59 +00:00
parent 65079de265
commit 52f2f3eae4
9 changed files with 26 additions and 29 deletions

View File

@ -1,5 +1,6 @@
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).

View File

@ -546,12 +546,8 @@ static void _format1_destroy_instance(struct format_instance *fid)
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);
}

View File

@ -259,12 +259,8 @@ static void _pool_destroy_instance(struct format_instance *fid)
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);
}

View File

@ -1541,13 +1541,8 @@ static void _free_raws(struct dm_list *raw_list)
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);

View File

@ -1551,7 +1551,6 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd,
return pv;
bad:
free_pv_fid(pv);
return NULL;
}
@ -1575,6 +1574,7 @@ static struct physical_volume *_alloc_pv(struct dm_pool *mem, struct device *dev
/**
* 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
@ -1609,9 +1609,10 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
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;
@ -1650,7 +1651,6 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
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;
@ -1687,8 +1687,9 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
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;
}

View File

@ -90,6 +90,18 @@ void release_vg(struct volume_group *vg)
_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)

View File

@ -121,6 +121,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
* 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);

View File

@ -117,7 +117,6 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
ret = ECMD_FAILED;
}
free_pv_fid(pv);
unlock_vg(cmd, VG_ORPHANS);
if (sigint_caught())
return ret;

View File

@ -146,7 +146,6 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
pv_dev_name(pv));
log_error("Use pvcreate and vgcfgrestore to repair "
"from archived metadata.");
free_pv_fid(pv);
return ECMD_FAILED;
}
@ -157,13 +156,10 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
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);