mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
metadata: add vg_from_config_tree
Add cmd/fmt args to import functions so that they can be used without the fid arg which.
This commit is contained in:
parent
13c629fb78
commit
74ad2cd76f
@ -47,11 +47,15 @@ enum pv_vg_lv_e {
|
||||
|
||||
struct text_vg_version_ops {
|
||||
int (*check_version) (const struct dm_config_tree * cf);
|
||||
struct volume_group *(*read_vg) (struct format_instance * fid,
|
||||
const struct dm_config_tree *cf,
|
||||
unsigned allow_lvmetad_extensions);
|
||||
|
||||
struct volume_group *(*read_vg) (struct cmd_context *cmd,
|
||||
const struct format_type *fmt,
|
||||
struct format_instance *fid,
|
||||
const struct dm_config_tree *cft);
|
||||
|
||||
void (*read_desc) (struct dm_pool * mem, const struct dm_config_tree *cf,
|
||||
time_t *when, char **desc);
|
||||
|
||||
int (*read_vgsummary) (const struct format_type *fmt,
|
||||
const struct dm_config_tree *cft,
|
||||
struct lvmcache_vgsummary *vgsummary);
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "lib/misc/lib.h"
|
||||
#include "lib/metadata/metadata.h"
|
||||
#include "lib/commands/toolcontext.h"
|
||||
#include "import-export.h"
|
||||
|
||||
/* FIXME Use tidier inclusion method */
|
||||
@ -181,7 +182,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
||||
if (!(*vsn)->check_version(cft))
|
||||
continue;
|
||||
|
||||
if (!(vg = (*vsn)->read_vg(fid, cft, 0)))
|
||||
if (!(vg = (*vsn)->read_vg(fid->fmt->cmd, fid->fmt, fid, cft)))
|
||||
goto_out;
|
||||
|
||||
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
|
||||
@ -210,9 +211,9 @@ struct volume_group *text_read_metadata_file(struct format_instance *fid,
|
||||
when, desc);
|
||||
}
|
||||
|
||||
static struct volume_group *_import_vg_from_config_tree(const struct dm_config_tree *cft,
|
||||
static struct volume_group *_import_vg_from_config_tree(struct cmd_context *cmd,
|
||||
struct format_instance *fid,
|
||||
unsigned allow_lvmetad_extensions)
|
||||
const struct dm_config_tree *cft)
|
||||
{
|
||||
struct volume_group *vg = NULL;
|
||||
struct text_vg_version_ops **vsn;
|
||||
@ -227,7 +228,7 @@ static struct volume_group *_import_vg_from_config_tree(const struct dm_config_t
|
||||
* The only path to this point uses cached vgmetadata,
|
||||
* so it can use cached PV state too.
|
||||
*/
|
||||
if (!(vg = (*vsn)->read_vg(fid, cft, allow_lvmetad_extensions)))
|
||||
if (!(vg = (*vsn)->read_vg(cmd, fid->fmt, fid, cft)))
|
||||
stack;
|
||||
else {
|
||||
set_pv_devices(fid, vg, NULL);
|
||||
@ -243,8 +244,21 @@ static struct volume_group *_import_vg_from_config_tree(const struct dm_config_t
|
||||
return vg;
|
||||
}
|
||||
|
||||
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
|
||||
struct format_instance *fid)
|
||||
struct volume_group *import_vg_from_config_tree(struct cmd_context *cmd,
|
||||
struct format_instance *fid,
|
||||
const struct dm_config_tree *cft)
|
||||
{
|
||||
return _import_vg_from_config_tree(cft, fid, 0);
|
||||
return _import_vg_from_config_tree(cmd, fid, cft);
|
||||
}
|
||||
|
||||
struct volume_group *vg_from_config_tree(struct cmd_context *cmd, const struct dm_config_tree *cft)
|
||||
{
|
||||
static struct text_vg_version_ops *ops;
|
||||
|
||||
_init_text_import();
|
||||
|
||||
ops = _text_vsn_list[0];
|
||||
|
||||
return ops->read_vg(cmd, cmd->fmt, NULL, cft);
|
||||
}
|
||||
|
||||
|
@ -993,7 +993,7 @@ static int _read_lvsegs(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
static int _read_sections(struct cmd_context *cmd,
|
||||
struct format_type *fmt,
|
||||
const struct format_type *fmt,
|
||||
struct format_instance *fid,
|
||||
struct dm_pool *mem,
|
||||
const char *section, section_fn fn,
|
||||
@ -1016,19 +1016,18 @@ static int _read_sections(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
for (n = n->child; n; n = n->sib) {
|
||||
if (!fn(cmd, fmt, fid, mem, vg, vgsummary, n, vgn, pv_hash, lv_hash))
|
||||
if (!fn(cmd, (struct format_type *)fmt, fid, mem, vg, vgsummary, n, vgn, pv_hash, lv_hash))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct volume_group *_read_vg(struct format_instance *fid,
|
||||
const struct dm_config_tree *cft,
|
||||
unsigned allow_lvmetad_extensions)
|
||||
static struct volume_group *_read_vg(struct cmd_context *cmd,
|
||||
const struct format_type *fmt,
|
||||
struct format_instance *fid,
|
||||
const struct dm_config_tree *cft)
|
||||
{
|
||||
struct cmd_context *cmd = fid->fmt->cmd;
|
||||
struct format_type *fmt = (struct format_type *)fid->fmt;
|
||||
struct dm_pool *mem;
|
||||
const struct dm_config_node *vgn;
|
||||
const struct dm_config_value *cv;
|
||||
@ -1234,6 +1233,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
||||
dm_hash_destroy(pv_hash);
|
||||
dm_hash_destroy(lv_hash);
|
||||
|
||||
if (fid)
|
||||
vg_set_fid(vg, fid);
|
||||
|
||||
/*
|
||||
|
@ -999,7 +999,7 @@ static int _vg_update_embedded_copy(struct volume_group *vg, struct volume_group
|
||||
if (!(cft = export_vg_to_config_tree(vg)))
|
||||
return_0;
|
||||
|
||||
if (!(*vg_embedded = import_vg_from_config_tree(cft, vg->fid))) {
|
||||
if (!(*vg_embedded = import_vg_from_config_tree(vg->cmd, vg->fid, cft))) {
|
||||
dm_config_destroy(cft);
|
||||
return_0;
|
||||
}
|
||||
@ -5220,7 +5220,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(vg->vg_committed = import_vg_from_config_tree(cft, vg->fid)))
|
||||
if (!(vg->vg_committed = import_vg_from_config_tree(cmd, vg->fid, cft)))
|
||||
log_warn("WARNING: vg_read no vg copy: copy import failed");
|
||||
|
||||
dm_config_destroy(cft);
|
||||
|
@ -477,8 +477,10 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea
|
||||
* For internal metadata caching.
|
||||
*/
|
||||
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
|
||||
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
|
||||
struct format_instance *fid);
|
||||
struct volume_group *import_vg_from_config_tree(struct cmd_context *cmd,
|
||||
struct format_instance *fid,
|
||||
const struct dm_config_tree *cft);
|
||||
struct volume_group *vg_from_config_tree(struct cmd_context *cmd, const struct dm_config_tree *cft);
|
||||
|
||||
/*
|
||||
* Mirroring functions
|
||||
|
Loading…
Reference in New Issue
Block a user