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

Cleanup fid finalization code in free_vg and allow exactly the same fid to be set again for a PV/VG.

Actually, we can call vg_set_fid(vg, NULL) instead of calling
destroy_instance for all PV structs and a VG struct - it's the same
code we already have in the vg_set_fid.

Also, allow exactly the same fid to be set again for the same PV/VG
Before, this could end up with the fid destroyed because we destroyed
existing fid first and then we used the new one and we didn't care
whether existing one == new one by chance.
This commit is contained in:
Peter Rajnoha 2011-04-01 14:54:20 +00:00
parent 2c67b829a5
commit 29684f590c

View File

@ -3243,19 +3243,10 @@ void free_pv_fid(struct physical_volume *pv)
void free_vg(struct volume_group *vg)
{
struct pv_list *pvl;
if (!vg)
return;
dm_list_iterate_items(pvl, &vg->pvs)
pvl->pv->fid->fmt->ops->destroy_instance(pvl->pv->fid);
dm_list_iterate_items(pvl, &vg->removed_pvs)
pvl->pv->fid->fmt->ops->destroy_instance(pvl->pv->fid);
if (vg->fid)
vg->fid->fmt->ops->destroy_instance(vg->fid);
vg_set_fid(vg, NULL);
if (vg->cmd && vg->vgmem == vg->cmd->mem) {
log_error(INTERNAL_ERROR "global memory pool used for VG %s",
@ -4048,12 +4039,13 @@ bad:
void pv_set_fid(struct physical_volume *pv,
struct format_instance *fid)
{
if (fid)
fid->ref_count++;
if (pv->fid)
pv->fid->fmt->ops->destroy_instance(pv->fid);
pv->fid = fid;
if (fid)
fid->ref_count++;
}
void vg_set_fid(struct volume_group *vg,
@ -4061,15 +4053,19 @@ void vg_set_fid(struct volume_group *vg,
{
struct pv_list *pvl;
if (vg->fid)
vg->fid->fmt->ops->destroy_instance(vg->fid);
vg->fid = fid;
if (fid)
fid->ref_count++;
dm_list_iterate_items(pvl, &vg->pvs)
pv_set_fid(pvl->pv, fid);
dm_list_iterate_items(pvl, &vg->removed_pvs)
pv_set_fid(pvl->pv, fid);
if (vg->fid)
vg->fid->fmt->ops->destroy_instance(vg->fid);
vg->fid = fid;
}
static int _convert_key_to_string(const char *key, size_t key_len,