1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

FMT_INSTANCE_VG is redundant now

This commit is contained in:
Alasdair Kergon 2012-02-12 23:01:19 +00:00
parent ba14fff2af
commit b719e3d323
8 changed files with 32 additions and 50 deletions

View File

@ -707,7 +707,7 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
if ((vg = vginfo->cached_vg))
goto out;
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = vginfo->vgname;
fic.context.vg_ref.vg_id = vgid;
if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt, &fic)))

View File

@ -609,7 +609,7 @@ struct format_type *init_format(struct cmd_context *cmd)
log_error("Couldn't create lvm1 orphan VG.");
return NULL;
}
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
fic.context.vg_ref.vg_id = NULL;
if (!(fid = _format1_create_instance(fmt, &fic))) {

View File

@ -322,7 +322,7 @@ struct format_type *init_format(struct cmd_context *cmd)
log_error("Couldn't create lvm1 orphan VG.");
return NULL;
}
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
fic.context.vg_ref.vg_id = NULL;
if (!(fid = _pool_create_instance(fmt, &fic))) {

View File

@ -310,7 +310,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
log_print(" ");
log_print("File:\t\t%s", af->path);
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
fic.type = FMT_INSTANCE_PRIVATE_MDAS;
fic.context.private = &tc;
if (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
log_error("Couldn't create text instance object.");

View File

@ -279,7 +279,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
.desc = cmd->cmd_line};
struct metadata_area *mda;
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
fic.type = FMT_INSTANCE_PRIVATE_MDAS;
fic.context.private = &tc;
if (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
log_error("Couldn't create text format object.");
@ -312,7 +312,7 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
*/
/* Attempt to write out using currently active format */
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = vg->name;
fic.context.vg_ref.vg_id = NULL;
if (!(fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
@ -409,7 +409,7 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
log_verbose("Creating volume group backup \"%s\" (seqno %u).", file, vg->seqno);
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
fic.type = FMT_INSTANCE_PRIVATE_MDAS;
fic.context.private = &tc;
if (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
log_error("Couldn't create backup object.");

View File

@ -1084,7 +1084,7 @@ static int _scan_file(const struct format_type *fmt, const char *vgname)
/* FIXME stat file to see if it's changed */
/* FIXME: Check this fid is OK! */
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
fic.type = FMT_INSTANCE_PRIVATE_MDAS;
fic.context.private = NULL;
fid = _text_create_text_instance(fmt, &fic);
if ((vg = _vg_read_file_name(fid, scanned_vgname,
@ -1513,7 +1513,7 @@ static int _text_pv_initialise(const struct format_type *fmt,
static void _text_destroy_instance(struct format_instance *fid)
{
if (--fid->ref_count <= 1) {
if (fid->type & FMT_INSTANCE_VG && fid->metadata_areas_index)
if (fid->metadata_areas_index)
dm_hash_destroy(fid->metadata_areas_index);
dm_pool_destroy(fid->mem);
}
@ -1671,12 +1671,6 @@ static int _text_pv_setup(const struct format_type *fmt,
return 1;
}
static int _create_pv_text_instance(struct format_instance *fid,
const struct format_instance_ctx *fic)
{
return 0; /* just fail */
}
static void *_create_text_context(struct dm_pool *mem, struct text_context *tc)
{
struct text_context *new_tc;
@ -2173,8 +2167,7 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
if (!(fid = alloc_fid(fmt, fic)))
return_NULL;
if (fid->type & FMT_INSTANCE_VG ? _create_vg_text_instance(fid, fic) :
_create_pv_text_instance(fid, fic))
if (_create_vg_text_instance(fid, fic))
return fid;
dm_pool_destroy(fid->mem);
@ -2342,7 +2335,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
return NULL;
}
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
fic.context.vg_ref.vg_id = NULL;
if (!(fid = _text_create_text_instance(fmt, &fic))) {

View File

@ -199,20 +199,15 @@ struct pv_segment {
#define pvseg_is_allocated(pvseg) ((pvseg)->lvseg)
/*
* These flags define the type of the format instance to be created.
* There used to be a PV-based type, but all are now VG-based.
* We can further control the format_instance initialisation and functionality
* by using the other flags. Today, the primary role of the format_instance
* is to temporarily store metadata area information we are working with. More
* flags can be defined to cover even more functionality in the future...
* Properties of each format instance type.
* The primary role of the format_instance is to temporarily store metadata
* area information we are working with.
*/
/* VG-based format instance */
#define FMT_INSTANCE_VG 0x00000001U
/* Include any existing PV mdas during format_instance initialisation */
#define FMT_INSTANCE_MDAS 0x00000002U
/* FIXME Define auxiliary here! */
/* Include any auxiliary mdas during format_instance intialisation */
#define FMT_INSTANCE_AUX_MDAS 0x00000004U

View File

@ -956,7 +956,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
vg->pv_count = 0;
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = vg_name;
fic.context.vg_ref.vg_id = NULL;
if (!(fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
@ -2940,7 +2940,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
use_precommitted = 0;
/* create format instance with appropriate metadata area */
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = vgname;
fic.context.vg_ref.vg_id = vgid;
if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
@ -3120,7 +3120,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
use_precommitted = 0;
/* create format instance with appropriate metadata area */
fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
fic.context.vg_ref.vg_name = vgname;
fic.context.vg_ref.vg_id = vgid;
if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
@ -4207,14 +4207,12 @@ int fid_add_mda(struct format_instance *fid, struct metadata_area *mda,
return 1;
/* Add metadata area to index. */
if (fid->type & FMT_INSTANCE_VG) {
if (!_convert_key_to_string(key, key_len, sub_key,
full_key, sizeof(full_key)))
return_0;
if (!_convert_key_to_string(key, key_len, sub_key,
full_key, sizeof(full_key)))
return_0;
dm_hash_insert(fid->metadata_areas_index,
full_key, mda);
}
dm_hash_insert(fid->metadata_areas_index,
full_key, mda);
return 1;
}
@ -4245,13 +4243,11 @@ struct metadata_area *fid_get_mda_indexed(struct format_instance *fid,
struct metadata_area *mda = NULL;
if (fid->type & FMT_INSTANCE_VG) {
if (!_convert_key_to_string(key, key_len, sub_key,
full_key, sizeof(full_key)))
return_NULL;
mda = (struct metadata_area *) dm_hash_lookup(fid->metadata_areas_index,
full_key);
}
if (!_convert_key_to_string(key, key_len, sub_key,
full_key, sizeof(full_key)))
return_NULL;
mda = (struct metadata_area *) dm_hash_lookup(fid->metadata_areas_index,
full_key);
return mda;
}
@ -4278,13 +4274,11 @@ int fid_remove_mda(struct format_instance *fid, struct metadata_area *mda,
mda = mda_indexed;
if (fid->type & FMT_INSTANCE_VG) {
if (!_convert_key_to_string(key, key_len, sub_key,
full_key, sizeof(full_key)))
return_0;
if (!_convert_key_to_string(key, key_len, sub_key,
full_key, sizeof(full_key)))
return_0;
dm_hash_remove(fid->metadata_areas_index, full_key);
}
dm_hash_remove(fid->metadata_areas_index, full_key);
}
dm_list_del(&mda->list);