1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

Invalidate cache if composition of VG changed externally.

This commit is contained in:
Alasdair Kergon 2006-04-21 19:12:41 +00:00
parent 16959f2f01
commit 26b2524996
5 changed files with 59 additions and 1 deletions

View File

@ -1 +1 @@
2.02.05-cvs (2006-04-21)
2.02.06-cvs (2006-04-21)

View File

@ -1,3 +1,7 @@
Version 2.02.06 -
=================================
Invalidate cache if composition of VG changed externally.
Version 2.02.05 - 21st April 2006
=================================
Fix vgid string termination in recent cache code.

26
lib/cache/lvmcache.c vendored
View File

@ -306,6 +306,32 @@ struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan)
return vgnames;
}
struct list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
const char *vgid)
{
struct list *pvids;
struct lvmcache_vginfo *vginfo;
struct lvmcache_info *info;
if (!(pvids = str_list_create(cmd->mem))) {
log_error("pvids list allocation failed");
return NULL;
}
if (!(vginfo = vginfo_from_vgname(vgname, vgid)))
return pvids;
list_iterate_items(info, &vginfo->infos) {
if (!str_list_add(cmd->mem, pvids,
dm_pool_strdup(cmd->mem, info->dev->pvid))) {
log_error("strlist allocation failed");
return NULL;
}
}
return pvids;
}
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
{
struct label *label;

View File

@ -101,4 +101,8 @@ struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan);
/* Set full_scan to 1 to reread every filtered device label */
struct list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan);
/* Returns list of struct str_lists containing pool-allocated copy of pvids */
struct list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
const char *vgid);
#endif

View File

@ -919,6 +919,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
struct metadata_area *mda;
int inconsistent = 0;
int use_precommitted = precommitted;
struct list *pvids;
struct pv_list *pvl;
if (!*vgname) {
if (use_precommitted) {
@ -950,6 +952,12 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
if (use_precommitted && !(fmt->features & FMT_PRECOMMIT))
use_precommitted = 0;
/* Store pvids for later so we can check if any are missing */
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid))) {
stack;
return NULL;
}
/* create format instance with appropriate metadata area */
if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
log_error("Failed to create format instance");
@ -977,6 +985,22 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
}
}
/* Ensure every PV in the VG was in the cache */
if (correct_vg) {
if (list_size(&correct_vg->pvs) != list_size(pvids)) {
log_debug("Cached VG %s had incorrect PV list",
vg->name);
correct_vg = NULL;
} else list_iterate_items(pvl, &correct_vg->pvs) {
if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
log_debug("Cached VG %s had incorrect PV list",
vg->name);
correct_vg = NULL;
break;
}
}
}
/* Failed to find VG where we expected it - full scan and retry */
if (!correct_vg) {
inconsistent = 0;