mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Use new alloc_fid fn for common format instance initialisation.
This commit is contained in:
parent
a6f38f9d6a
commit
56f5b12eed
@ -1,5 +1,6 @@
|
||||
Version 2.02.85 -
|
||||
===================================
|
||||
Use new alloc_fid fn for common format instance initialisation.
|
||||
Optimise _get_token() and _eat_space().
|
||||
Add _lv_postorder_vg() to improve efficiency for all LVs in VG.
|
||||
Use hash tables to speedup string search in validate_vg().
|
||||
|
@ -504,15 +504,9 @@ static struct format_instance *_format1_create_instance(const struct format_type
|
||||
struct format_instance *fid;
|
||||
struct metadata_area *mda;
|
||||
|
||||
if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid))))
|
||||
if (!(fid = alloc_fid(fmt, fic)))
|
||||
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 */
|
||||
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
|
||||
dm_pool_free(fmt->cmd->mem, fid);
|
||||
|
@ -228,17 +228,8 @@ static struct format_instance *_pool_create_instance(const struct format_type *f
|
||||
struct format_instance *fid;
|
||||
struct metadata_area *mda;
|
||||
|
||||
if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
|
||||
log_error("Unable to allocate format instance structure for "
|
||||
"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);
|
||||
if (!(fid = alloc_fid(fmt, fic)))
|
||||
return_NULL;
|
||||
|
||||
/* Define a NULL metadata area */
|
||||
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
|
||||
|
@ -2195,16 +2195,8 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
|
||||
struct format_instance *fid;
|
||||
int r;
|
||||
|
||||
if (!(fid = dm_pool_alloc(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);
|
||||
if (!(fid = alloc_fid(fmt, fic)))
|
||||
return_NULL;
|
||||
|
||||
if (fid->type & FMT_INSTANCE_VG)
|
||||
r = _create_vg_text_instance(fid, fic);
|
||||
|
@ -3941,6 +3941,25 @@ uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname)
|
||||
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,
|
||||
struct format_instance *fid)
|
||||
{
|
||||
|
@ -191,6 +191,21 @@ struct metadata_area *mda_copy(struct dm_pool *mem,
|
||||
unsigned mda_is_ignored(struct metadata_area *mda);
|
||||
void mda_set_ignored(struct metadata_area *mda, unsigned ignored);
|
||||
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);
|
||||
/* FIXME: Add generic interface for mda counts based on given key. */
|
||||
int fid_add_mda(struct format_instance *fid, struct metadata_area *mda,
|
||||
@ -229,18 +244,6 @@ struct seg_list {
|
||||
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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user