mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
save vg cft from scan and reuse in vg_read
needs some more work
This commit is contained in:
parent
d650be1eb4
commit
d665912d4d
37
lib/cache/lvmcache.c
vendored
37
lib/cache/lvmcache.c
vendored
@ -55,6 +55,7 @@ struct lvmcache_vginfo {
|
||||
struct dm_list infos; /* List head for lvmcache_infos */
|
||||
struct dm_list outdated_infos; /* vg_read moves info from infos to outdated_infos */
|
||||
struct dm_list pvsummaries; /* pv_list taken directly from vgsummary */
|
||||
struct dm_config_tree *cft;
|
||||
const struct format_type *fmt;
|
||||
char *vgname; /* "" == orphan */
|
||||
uint32_t status;
|
||||
@ -1747,6 +1748,8 @@ int lvmcache_pvid_in_unused_duplicates(const char *pvid)
|
||||
|
||||
static void _free_vginfo(struct lvmcache_vginfo *vginfo)
|
||||
{
|
||||
if (vginfo->cft)
|
||||
config_destroy(vginfo->cft);
|
||||
free(vginfo->vgname);
|
||||
free(vginfo->system_id);
|
||||
free(vginfo->creation_host);
|
||||
@ -3058,6 +3061,40 @@ bool lvmcache_scan_mismatch(struct cmd_context *cmd, const char *vgname, const c
|
||||
return true;
|
||||
}
|
||||
|
||||
int lvmcache_save_cft(struct lvmcache_info *info, struct dm_config_tree *cft)
|
||||
{
|
||||
if (info->vginfo && !info->vginfo->cft) {
|
||||
info->vginfo->cft = cft;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lvmcache_forget_cft(const char *vg_name, struct id *vg_id)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
|
||||
char vgid[ID_LEN+1] = { 0 };
|
||||
|
||||
memcpy(&vgid, vg_id, ID_LEN);
|
||||
|
||||
if ((vginfo = lvmcache_vginfo_from_vgname(vg_name, vgid)))
|
||||
vginfo->cft = NULL;
|
||||
}
|
||||
|
||||
struct dm_config_tree *lvmcache_get_cft(struct device *dev, uint32_t checksum)
|
||||
{
|
||||
struct lvmcache_info *info;
|
||||
|
||||
if (!(info = lvmcache_info_from_pvid(dev->pvid, NULL, 0)))
|
||||
return NULL;
|
||||
|
||||
if (info->vginfo && info->vginfo->mda_checksum == checksum)
|
||||
return info->vginfo->cft;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uint64_t _max_metadata_size;
|
||||
|
||||
void lvmcache_save_metadata_size(uint64_t val)
|
||||
|
5
lib/cache/lvmcache.h
vendored
5
lib/cache/lvmcache.h
vendored
@ -60,6 +60,7 @@ struct lvmcache_vgsummary {
|
||||
unsigned zero_offset:1;
|
||||
unsigned mismatch:1; /* lvmcache sets if this summary differs from previous values */
|
||||
struct dm_list pvsummaries;
|
||||
struct dm_config_tree *cft;
|
||||
};
|
||||
|
||||
int lvmcache_init(struct cmd_context *cmd);
|
||||
@ -228,4 +229,8 @@ unsigned int lvmcache_vg_info_count(void);
|
||||
|
||||
int lvmcache_pvsummary_count(const char *vgname);
|
||||
|
||||
int lvmcache_save_cft(struct lvmcache_info *info, struct dm_config_tree *cft);
|
||||
struct dm_config_tree *lvmcache_get_cft(struct device *dev, uint32_t checksum);
|
||||
void lvmcache_forget_cft(const char *vg_name, struct id *vg_id);
|
||||
|
||||
#endif
|
||||
|
@ -95,7 +95,7 @@ int text_read_metadata_summary(const struct format_type *fmt,
|
||||
}
|
||||
|
||||
out:
|
||||
config_destroy(cft);
|
||||
vgsummary->cft = cft;
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
||||
{
|
||||
struct volume_group *vg = NULL;
|
||||
struct dm_config_tree *cft;
|
||||
struct dm_config_tree *cft_summary = NULL;
|
||||
const struct text_vg_version_ops **vsn;
|
||||
int skip_parse;
|
||||
|
||||
@ -150,6 +151,16 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
||||
|
||||
|
||||
if (dev) {
|
||||
/* FIXME: also pass mda_size to get_cft to compare */
|
||||
if ((cft_summary = lvmcache_get_cft(dev, checksum))) {
|
||||
log_debug("vg cft used from scan summary checksum %x", checksum);
|
||||
config_destroy(cft);
|
||||
cft = cft_summary;
|
||||
goto parse_cft;
|
||||
} else {
|
||||
log_debug("vg cft not used from scan summary");
|
||||
}
|
||||
|
||||
log_debug_metadata("Reading metadata from %s at %llu size %d (+%d)",
|
||||
dev_name(dev), (unsigned long long)offset,
|
||||
size, size2);
|
||||
@ -167,6 +178,8 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
||||
}
|
||||
}
|
||||
|
||||
parse_cft:
|
||||
|
||||
if (skip_parse) {
|
||||
if (use_previous_vg)
|
||||
*use_previous_vg = 1;
|
||||
@ -200,7 +213,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
||||
*use_previous_vg = 0;
|
||||
|
||||
out:
|
||||
if (cft)
|
||||
if (cft && !cft_summary)
|
||||
config_destroy(cft);
|
||||
return vg;
|
||||
}
|
||||
|
@ -564,6 +564,10 @@ static int _text_read(struct cmd_context *cmd, struct labeller *labeller, struct
|
||||
} else {
|
||||
/* The normal success path */
|
||||
log_debug("Found metadata seqno %u in mda1 on %s", vgsummary.seqno, dev_name(dev));
|
||||
if (!lvmcache_save_cft(info, vgsummary.cft)) {
|
||||
config_destroy(vgsummary.cft);
|
||||
vgsummary.cft = NULL;
|
||||
}
|
||||
good_mda_count++;
|
||||
}
|
||||
}
|
||||
@ -614,6 +618,10 @@ static int _text_read(struct cmd_context *cmd, struct labeller *labeller, struct
|
||||
} else {
|
||||
/* The normal success path */
|
||||
log_debug("Found metadata seqno %u in mda2 on %s", vgsummary.seqno, dev_name(dev));
|
||||
if (!lvmcache_save_cft(info, vgsummary.cft)) {
|
||||
config_destroy(vgsummary.cft);
|
||||
vgsummary.cft = NULL;
|
||||
}
|
||||
good_mda_count++;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "lib/commands/toolcontext.h"
|
||||
#include "lib/format_text/archiver.h"
|
||||
#include "lib/datastruct/str_list.h"
|
||||
#include "lib/cache/lvmcache.h"
|
||||
|
||||
struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
|
||||
const char *vg_name)
|
||||
@ -77,8 +78,10 @@ static void _free_vg(struct volume_group *vg)
|
||||
|
||||
log_debug_mem("Freeing VG %s at %p.", vg->name ? : "<no name>", (void *)vg);
|
||||
|
||||
if (vg->committed_cft)
|
||||
if (vg->committed_cft) {
|
||||
config_destroy(vg->committed_cft);
|
||||
lvmcache_forget_cft(vg->name, &vg->id);
|
||||
}
|
||||
dm_pool_destroy(vg->vgmem);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user