mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +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:
parent
b2b5a2268a
commit
6890aea4ca
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.92 -
|
Version 2.02.92 -
|
||||||
====================================
|
====================================
|
||||||
|
Add free_orphan_vg.
|
||||||
Skip pv/vg_set_fid processing if the fid is same.
|
Skip pv/vg_set_fid processing if the fid is same.
|
||||||
Check for foreach loop errors in _vg_read_orphans() (2.02.91).
|
Check for foreach loop errors in _vg_read_orphans() (2.02.91).
|
||||||
Clean error paths for format instance creation (2.02.91).
|
Clean error paths for format instance creation (2.02.91).
|
||||||
|
@ -546,12 +546,8 @@ static void _format1_destroy_instance(struct format_instance *fid)
|
|||||||
|
|
||||||
static void _format1_destroy(struct format_type *fmt)
|
static void _format1_destroy(struct format_type *fmt)
|
||||||
{
|
{
|
||||||
/* FIXME out of place, but the main (cmd) pool has been already
|
if (fmt->orphan_vg)
|
||||||
* destroyed and touching the fid (also via release_vg) will crash the
|
free_orphan_vg(fmt->orphan_vg);
|
||||||
* program */
|
|
||||||
dm_hash_destroy(fmt->orphan_vg->hostnames);
|
|
||||||
dm_pool_destroy(fmt->orphan_vg->fid->mem);
|
|
||||||
dm_pool_destroy(fmt->orphan_vg->vgmem);
|
|
||||||
|
|
||||||
dm_free(fmt);
|
dm_free(fmt);
|
||||||
}
|
}
|
||||||
|
@ -259,12 +259,8 @@ static void _pool_destroy_instance(struct format_instance *fid)
|
|||||||
|
|
||||||
static void _pool_destroy(struct format_type *fmt)
|
static void _pool_destroy(struct format_type *fmt)
|
||||||
{
|
{
|
||||||
/* FIXME out of place, but the main (cmd) pool has been already
|
if (fmt->orphan_vg)
|
||||||
* destroyed and touching the fid (also via release_vg) will crash the
|
free_orphan_vg(fmt->orphan_vg);
|
||||||
* program */
|
|
||||||
dm_hash_destroy(fmt->orphan_vg->hostnames);
|
|
||||||
dm_pool_destroy(fmt->orphan_vg->fid->mem);
|
|
||||||
dm_pool_destroy(fmt->orphan_vg->vgmem);
|
|
||||||
|
|
||||||
dm_free(fmt);
|
dm_free(fmt);
|
||||||
}
|
}
|
||||||
|
@ -1541,13 +1541,8 @@ static void _free_raws(struct dm_list *raw_list)
|
|||||||
|
|
||||||
static void _text_destroy(struct format_type *fmt)
|
static void _text_destroy(struct format_type *fmt)
|
||||||
{
|
{
|
||||||
/* FIXME out of place, but the main (cmd) pool has been already
|
if (fmt->orphan_vg)
|
||||||
* destroyed and touching the fid (also via release_vg) will crash the
|
free_orphan_vg(fmt->orphan_vg);
|
||||||
* 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->private) {
|
if (fmt->private) {
|
||||||
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
|
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
|
||||||
|
@ -1551,7 +1551,6 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd,
|
|||||||
return pv;
|
return pv;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
free_pv_fid(pv);
|
|
||||||
return NULL;
|
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
|
* pv_create - initialize a physical volume for use with a volume group
|
||||||
|
* created PV belongs to Orphan VG.
|
||||||
*
|
*
|
||||||
* @fmt: format type
|
* @fmt: format type
|
||||||
* @dev: PV device to initialize
|
* @dev: PV device to initialize
|
||||||
@ -1609,9 +1609,10 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
|
|||||||
unsigned metadataignore)
|
unsigned metadataignore)
|
||||||
{
|
{
|
||||||
const struct format_type *fmt = cmd->fmt;
|
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);
|
struct physical_volume *pv = _alloc_pv(mem, dev);
|
||||||
unsigned mda_index;
|
unsigned mda_index;
|
||||||
|
struct pv_list *pvl;
|
||||||
|
|
||||||
if (!pv)
|
if (!pv)
|
||||||
return_NULL;
|
return_NULL;
|
||||||
@ -1650,7 +1651,6 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pv_list *pvl;
|
|
||||||
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
|
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
|
||||||
log_error("pv_list allocation in pv_create failed");
|
log_error("pv_list allocation in pv_create failed");
|
||||||
goto bad;
|
goto bad;
|
||||||
@ -1687,8 +1687,9 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
|
|||||||
return pv;
|
return pv;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
free_pv_fid(pv);
|
// FIXME: detach from orphan in error path
|
||||||
dm_pool_free(mem, pv);
|
//free_pv_fid(pv);
|
||||||
|
//dm_pool_free(mem, pv);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,18 @@ void release_vg(struct volume_group *vg)
|
|||||||
_free_vg(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)
|
char *vg_fmt_dup(const struct volume_group *vg)
|
||||||
{
|
{
|
||||||
if (!vg->fid || !vg->fid->fmt)
|
if (!vg->fid || !vg->fid->fmt)
|
||||||
|
@ -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.
|
* by vg_create() or vg_read_internal() to free it when no longer required.
|
||||||
*/
|
*/
|
||||||
void release_vg(struct volume_group *vg);
|
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_fmt_dup(const struct volume_group *vg);
|
||||||
char *vg_name_dup(const struct volume_group *vg);
|
char *vg_name_dup(const struct volume_group *vg);
|
||||||
|
@ -117,7 +117,6 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
ret = ECMD_FAILED;
|
ret = ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
free_pv_fid(pv);
|
|
||||||
unlock_vg(cmd, VG_ORPHANS);
|
unlock_vg(cmd, VG_ORPHANS);
|
||||||
if (sigint_caught())
|
if (sigint_caught())
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -146,7 +146,6 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
|||||||
pv_dev_name(pv));
|
pv_dev_name(pv));
|
||||||
log_error("Use pvcreate and vgcfgrestore to repair "
|
log_error("Use pvcreate and vgcfgrestore to repair "
|
||||||
"from archived metadata.");
|
"from archived metadata.");
|
||||||
free_pv_fid(pv);
|
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,13 +156,10 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
|||||||
pv_dev_name(pv));
|
pv_dev_name(pv));
|
||||||
log_error("Use pvcreate and vgcfgrestore to repair "
|
log_error("Use pvcreate and vgcfgrestore to repair "
|
||||||
"from archived metadata.");
|
"from archived metadata.");
|
||||||
free_pv_fid(pv);
|
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
log_verbose("Physical volume \"%s\" successfully created",
|
log_verbose("Physical volume \"%s\" successfully created",
|
||||||
pv_dev_name(pv));
|
pv_dev_name(pv));
|
||||||
|
|
||||||
free_pv_fid(pv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Deleting existing metadata for VG %s", vg_name);
|
log_verbose("Deleting existing metadata for VG %s", vg_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user