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

Use format instance mempool where possible and adequate.

This commit is contained in:
Peter Rajnoha 2011-03-11 15:10:16 +00:00
parent e8d4946ec7
commit ff4479414c
5 changed files with 17 additions and 19 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.85 -
===================================
Use format instance mempool where possible and adequate.
Call destroy_instance for any PVs found in VG structure during vg_free call.
Add new free_pv_fid fn and use it throughout to free all attached fids.
Use only vg_set_fid and new pv_set_fid fn to assign the format instance.

View File

@ -508,10 +508,9 @@ static struct format_instance *_format1_create_instance(const struct format_type
return_NULL;
/* Define a NULL metadata area */
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda)))) {
log_error("Unable to allocate metadata area structure "
"for lvm1 format");
dm_pool_free(fmt->cmd->mem, fid);
goto bad;
}

View File

@ -233,10 +233,9 @@ static struct format_instance *_pool_create_instance(const struct format_type *f
return_NULL;
/* Define a NULL metadata area */
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda)))) {
log_error("Unable to allocate metadata area structure "
"for pool format");
dm_pool_free(fmt->cmd->mem, fid);
goto bad;
}

View File

@ -1659,7 +1659,7 @@ static int _text_pv_setup(const struct format_type *fmt,
/* Be sure it's not already in VG's format instance! */
if (!fid_get_mda_indexed(vg->fid, pvid, ID_LEN, mda_index)) {
pv_mda_copy = mda_copy(vg->fid->fmt->cmd->mem, pv_mda);
pv_mda_copy = mda_copy(vg->fid->mem, pv_mda);
fid_add_mda(vg->fid, pv_mda_copy, pvid, ID_LEN, mda_index);
}
}
@ -1727,14 +1727,14 @@ static int _create_pv_text_instance(struct format_instance *fid,
struct lvmcache_info *info;
if (!(fid_pv_tc = (struct text_fid_pv_context *)
dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*fid_pv_tc)))) {
dm_pool_zalloc(fid->mem, sizeof(*fid_pv_tc)))) {
log_error("Couldn't allocate text_fid_pv_context.");
return 0;
}
fid_pv_tc->label_sector = -1;
fid->private = (void *) fid_pv_tc;
if (!(fid->metadata_areas_index.array = dm_pool_zalloc(fid->fmt->cmd->mem,
if (!(fid->metadata_areas_index.array = dm_pool_zalloc(fid->mem,
FMT_TEXT_MAX_MDAS_PER_PV *
sizeof(struct metadata_area *)))) {
log_error("Couldn't allocate format instance metadata index.");
@ -1811,7 +1811,7 @@ static int _create_vg_text_instance(struct format_instance *fid,
const char *vg_name, *vg_id;
if (!(fidtc = (struct text_fid_context *)
dm_pool_zalloc(fid->fmt->cmd->mem,sizeof(*fidtc)))) {
dm_pool_zalloc(fid->mem, sizeof(*fidtc)))) {
log_error("Couldn't allocate text_fid_context.");
return 0;
}
@ -1820,10 +1820,10 @@ static int _create_vg_text_instance(struct format_instance *fid,
fid->private = (void *) fidtc;
if (type & FMT_INSTANCE_PRIVATE_MDAS) {
if (!(mda = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mda))))
if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
return_0;
mda->ops = &_metadata_text_file_backup_ops;
mda->metadata_locn = _create_text_context(fid->fmt->cmd->mem, fic->context.private);
mda->metadata_locn = _create_text_context(fid->mem, fic->context.private);
mda->status = 0;
fid->metadata_areas_index.hash = NULL;
fid_add_mda(fid, mda, NULL, 0, 0);
@ -1845,12 +1845,12 @@ static int _create_vg_text_instance(struct format_instance *fid,
return 0;
}
if (!(mda = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mda))))
if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
return_0;
mda->ops = &_metadata_text_file_ops;
tc.path_live = path;
tc.path_edit = tc.desc = NULL;
mda->metadata_locn = _create_text_context(fid->fmt->cmd->mem, &tc);
mda->metadata_locn = _create_text_context(fid->mem, &tc);
mda->status = 0;
fid_add_mda(fid, mda, NULL, 0, 0);
}
@ -1861,10 +1861,10 @@ static int _create_vg_text_instance(struct format_instance *fid,
if (!_raw_holds_vgname(fid, &rl->dev_area, vg_name))
continue;
if (!(mda = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mda))))
if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
return_0;
if (!(mdac = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mdac))))
if (!(mdac = dm_pool_zalloc(fid->mem, sizeof(*mdac))))
return_0;
mda->metadata_locn = mdac;
/* FIXME Allow multiple dev_areas inside area */
@ -1912,12 +1912,12 @@ static int _add_metadata_area_to_pv(struct physical_volume *pv,
pv->fmt->name);
}
if (!(mda = dm_malloc(sizeof(struct metadata_area)))) {
if (!(mda = dm_pool_zalloc(pv->fid->mem, sizeof(struct metadata_area)))) {
log_error("struct metadata_area allocation failed");
return 0;
}
if (!(mdac = dm_malloc(sizeof(struct mda_context)))) {
if (!(mdac = dm_pool_zalloc(pv->fid->mem, sizeof(struct mda_context)))) {
log_error("struct mda_context allocation failed");
dm_free(mda);
return 0;
@ -2244,7 +2244,6 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
_create_pv_text_instance(fid, fic))
return fid;
dm_pool_free(fmt->cmd->mem, fid);
dm_pool_destroy(fid->mem);
return NULL;
}

View File

@ -4025,7 +4025,7 @@ struct format_instance *alloc_fid(const struct format_type *fmt,
if (!(mem = dm_pool_create("format_instance", 1024)))
return_NULL;
if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
if (!(fid = dm_pool_zalloc(mem, sizeof(*fid)))) {
log_error("Couldn't allocate format_instance object.");
goto bad;
}
@ -4117,7 +4117,7 @@ int fid_add_mdas(struct format_instance *fid, struct dm_list *mdas,
unsigned mda_index = 0;
dm_list_iterate_items(mda, mdas) {
mda_new = mda_copy(fid->fmt->cmd->mem, mda);
mda_new = mda_copy(fid->mem, mda);
if (!mda_new)
return_0;
fid_remove_mda(fid, NULL, key, key_len, mda_index);