1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-04 09:18:36 +03:00

Use new alloc_fid fn for common format instance initialisation.

This commit is contained in:
Peter Rajnoha 2011-03-11 14:30:27 +00:00
parent a6f38f9d6a
commit 56f5b12eed
6 changed files with 41 additions and 41 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.85 - Version 2.02.85 -
=================================== ===================================
Use new alloc_fid fn for common format instance initialisation.
Optimise _get_token() and _eat_space(). Optimise _get_token() and _eat_space().
Add _lv_postorder_vg() to improve efficiency for all LVs in VG. Add _lv_postorder_vg() to improve efficiency for all LVs in VG.
Use hash tables to speedup string search in validate_vg(). Use hash tables to speedup string search in validate_vg().

View File

@ -504,15 +504,9 @@ static struct format_instance *_format1_create_instance(const struct format_type
struct format_instance *fid; struct format_instance *fid;
struct metadata_area *mda; struct metadata_area *mda;
if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid)))) if (!(fid = alloc_fid(fmt, fic)))
return_NULL; return_NULL;
fid->fmt = fmt;
fid->type = fic->type;
dm_list_init(&fid->metadata_areas_in_use);
dm_list_init(&fid->metadata_areas_ignored);
/* Define a NULL metadata area */ /* Define a NULL metadata area */
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) { if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
dm_pool_free(fmt->cmd->mem, fid); dm_pool_free(fmt->cmd->mem, fid);

View File

@ -228,17 +228,8 @@ static struct format_instance *_pool_create_instance(const struct format_type *f
struct format_instance *fid; struct format_instance *fid;
struct metadata_area *mda; struct metadata_area *mda;
if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) { if (!(fid = alloc_fid(fmt, fic)))
log_error("Unable to allocate format instance structure for " return_NULL;
"pool format");
return NULL;
}
fid->fmt = fmt;
fid->type = fic->type;
dm_list_init(&fid->metadata_areas_in_use);
dm_list_init(&fid->metadata_areas_ignored);
/* Define a NULL metadata area */ /* Define a NULL metadata area */
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) { if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {

View File

@ -2195,16 +2195,8 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
struct format_instance *fid; struct format_instance *fid;
int r; int r;
if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid)))) { if (!(fid = alloc_fid(fmt, fic)))
log_error("Couldn't allocate format instance object."); return_NULL;
return NULL;
}
fid->fmt = fmt;
fid->type = fic->type;
dm_list_init(&fid->metadata_areas_in_use);
dm_list_init(&fid->metadata_areas_ignored);
if (fid->type & FMT_INSTANCE_VG) if (fid->type & FMT_INSTANCE_VG)
r = _create_vg_text_instance(fid, fic); r = _create_vg_text_instance(fid, fic);

View File

@ -3941,6 +3941,25 @@ uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname)
return FAILED_EXIST; return FAILED_EXIST;
} }
struct format_instance *alloc_fid(const struct format_type *fmt,
const struct format_instance_ctx *fic)
{
struct format_instance *fid;
if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
log_error("Couldn't allocate format_instance object.");
return NULL;
}
fid->fmt = fmt;
fid->type = fic->type;
dm_list_init(&fid->metadata_areas_in_use);
dm_list_init(&fid->metadata_areas_ignored);
return fid;
}
void vg_set_fid(struct volume_group *vg, void vg_set_fid(struct volume_group *vg,
struct format_instance *fid) struct format_instance *fid)
{ {

View File

@ -191,6 +191,21 @@ struct metadata_area *mda_copy(struct dm_pool *mem,
unsigned mda_is_ignored(struct metadata_area *mda); unsigned mda_is_ignored(struct metadata_area *mda);
void mda_set_ignored(struct metadata_area *mda, unsigned ignored); void mda_set_ignored(struct metadata_area *mda, unsigned ignored);
unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2); unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2);
struct format_instance_ctx {
uint32_t type;
union {
const char *pv_id;
struct {
const char *vg_name;
const char *vg_id;
} vg_ref;
void *private;
} context;
};
struct format_instance *alloc_fid(const struct format_type *fmt,
const struct format_instance_ctx *fic);
void vg_set_fid(struct volume_group *vg, struct format_instance *fid); void vg_set_fid(struct volume_group *vg, struct format_instance *fid);
/* FIXME: Add generic interface for mda counts based on given key. */ /* FIXME: Add generic interface for mda counts based on given key. */
int fid_add_mda(struct format_instance *fid, struct metadata_area *mda, int fid_add_mda(struct format_instance *fid, struct metadata_area *mda,
@ -229,18 +244,6 @@ struct seg_list {
struct lv_segment *seg; struct lv_segment *seg;
}; };
struct format_instance_ctx {
uint32_t type;
union {
const char *pv_id;
struct {
const char *vg_name;
const char *vg_id;
} vg_ref;
void *private;
} context;
};
/* /*
* Ownership of objects passes to caller. * Ownership of objects passes to caller.
*/ */