diff options
author | Petr Rockai <prockai@redhat.com> | 2012-02-10 02:53:03 +0000 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2012-02-10 02:53:03 +0000 |
commit | 6e41729eb89cde4b4ad132a8bfbb207f684a6ff4 (patch) | |
tree | c60922bbce7787414db36eae9902f82d8e983dc3 /lib/format1 | |
parent | 0fbbc6ce13ea50bf0d48b04e49e1bd7be9e848fe (diff) | |
download | lvm2-6e41729eb89cde4b4ad132a8bfbb207f684a6ff4.tar.gz lvm2-6e41729eb89cde4b4ad132a8bfbb207f684a6ff4.tar.xz lvm2-6e41729eb89cde4b4ad132a8bfbb207f684a6ff4.zip |
Keep a global (per-format) orphan_vg and keep any and all orphan PVs linked to
it. Avoids the need for FMT_INSTANCE_PV and enables further simplifications. No
functional change, internal refactor only.
Diffstat (limited to 'lib/format1')
-rw-r--r-- | lib/format1/format1.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/format1/format1.c b/lib/format1/format1.c index 6b5bdb95..ee3d7251 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -546,6 +546,13 @@ static void _format1_destroy_instance(struct format_instance *fid) static void _format1_destroy(struct format_type *fmt) { + /* FIXME out of place, but the main (cmd) pool has been already + * destroyed and touching the fid (also via release_vg) will crash the + * program */ + dm_hash_destroy(fmt->orphan_vg->hostnames); + dm_pool_destroy(fmt->orphan_vg->fid->mem); + dm_pool_destroy(fmt->orphan_vg->vgmem); + dm_free(fmt); } @@ -570,6 +577,8 @@ struct format_type *init_format(struct cmd_context *cmd) #endif { struct format_type *fmt = dm_malloc(sizeof(*fmt)); + struct format_instance_ctx fic; + struct format_instance *fid; if (!fmt) return_NULL; @@ -596,6 +605,19 @@ struct format_type *init_format(struct cmd_context *cmd) return NULL; } + if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name))) { + log_error("Couldn't create lvm1 orphan VG."); + return NULL; + } + fic.type = FMT_INSTANCE_VG | 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))) { + log_error("Couldn't create lvm1 orphan VG format instance."); + return NULL; + } + vg_set_fid(fmt->orphan_vg, fid); + log_very_verbose("Initialised format: %s", fmt->name); return fmt; |