1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

experimental: lv section in separate function

Just to see whether it makes code more readable
if we 'extract' just parsing of lv section
to standalone function

(also could be called maybe instead from _read_lvsegs
so _read_lvnames is only radix_treeing  lvname)
This commit is contained in:
Zdenek Kabelac 2024-10-29 17:48:55 +01:00
parent c0f6c2b259
commit 070a271b04

View File

@ -679,20 +679,16 @@ static int _read_segments(struct cmd_context *cmd,
return 1;
}
static int _read_lvnames(struct cmd_context *cmd,
struct format_type *fmt,
struct format_instance *fid __attribute__((unused)),
struct dm_pool *mem,
struct volume_group *vg,
struct lvmcache_vgsummary *vgsummary,
const struct dm_config_node *lvn,
const struct dm_config_node *vgn __attribute__((unused)))
static int _read_lv_section(struct cmd_context *cmd,
struct format_type *fmt,
struct dm_pool *mem,
struct volume_group *vg,
struct logical_volume *lv,
const struct dm_config_node *lvn)
{
struct logical_volume *lv;
const char *str;
const struct dm_config_value *tags_cv = NULL;
const char *hostname = NULL;
uint64_t timestamp = 0, lvstatus = 0;
uint64_t timestamp = 0, lvstatus = lv->status;
const char *alloc = NULL, *profile = NULL, *lock_args = NULL;
unsigned seg_count = 0;
uint32_t read_ahead = UINT32_C(-2);
@ -716,25 +712,6 @@ static int _read_lvnames(struct cmd_context *cmd,
{ "tags", &tags_cv, CONFIG_VALUE_LIST, },
};
if (!(str = dm_pool_strdup(mem, lvn->key)))
return_0;
if (!(lvn = lvn->child)) {
log_error("Empty logical volume section for %s.", str);
return 0;
}
if (!(lv = alloc_lv(mem)))
return_0;
if (!link_lv_to_vg(vg, lv))
return_0;
if (!lv_set_name(lv, str))
return_0;
log_debug_metadata("Importing logical volume %s.", lv->name);
if (!text_import_values(lvn, values, DM_ARRAY_SIZE(values))) {
log_error("Could not import values for logical volume %s.",
display_lvname(lv));
@ -888,6 +865,43 @@ static int _read_lvnames(struct cmd_context *cmd,
return 1;
}
static int _read_lvnames(struct cmd_context *cmd,
struct format_type *fmt,
struct format_instance *fid __attribute__((unused)),
struct dm_pool *mem,
struct volume_group *vg,
struct lvmcache_vgsummary *vgsummary,
const struct dm_config_node *lvn,
const struct dm_config_node *vgn __attribute__((unused)))
{
struct logical_volume *lv;
const char *str;
if (!(str = dm_pool_strdup(mem, lvn->key)))
return_0;
if (!(lvn = lvn->child)) {
log_error("Empty logical volume section for %s.", str);
return 0;
}
if (!(lv = alloc_lv(mem)))
return_0;
if (!link_lv_to_vg(vg, lv))
return_0;
if (!lv_set_name(lv, str))
return_0;
log_debug_metadata("Importing logical volume %s.", lv->name);
if (!_read_lv_section(cmd, fmt, mem, vg, lv, lvn))
return_0;
return 1;
}
static int _read_historical_lvnames(struct cmd_context *cmd,
struct format_type *fmt,
struct format_instance *fid __attribute__((unused)),