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

Fix up cache for PVs without mdas after consistent VG metadata is processed.

This commit is contained in:
Alasdair Kergon 2008-06-27 15:18:31 +00:00
parent 6db4136358
commit 59743245b4
3 changed files with 57 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.39 -
================================
Fix up cache for PVs without mdas after consistent VG metadata is processed.
Update validation of safe mirror log type conversions in lvconvert.
Fix lvconvert to disallow snapshot and mirror combinations.
Fix reporting of LV fields alongside unallocated PV segments.

22
lib/cache/lvmcache.c vendored
View File

@ -845,6 +845,7 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
{
struct lvmcache_vginfo *vginfo, *primary_vginfo, *orphan_vginfo;
struct lvmcache_info *info2, *info3;
char mdabuf[32];
// struct lvmcache_vginfo *old_vginfo, *next;
if (!vgname || (info && info->vginfo && !strcmp(info->vginfo->vgname, vgname)))
@ -914,11 +915,16 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
orphan_vginfo = vginfo_from_vgname(primary_vginfo->fmt->orphan_vg_name, NULL);
_drop_vginfo(info2, primary_vginfo);
_vginfo_attach_info(orphan_vginfo, info2);
log_debug("lvmcache: %s: now in VG %s%s%s%s",
if (info2->mdas.n)
sprintf(mdabuf, " with %u mdas",
list_size(&info2->mdas));
else
mdabuf[0] = '\0';
log_debug("lvmcache: %s: now in VG %s%s%s%s%s",
dev_name(info2->dev),
vgname, orphan_vginfo->vgid[0] ? " (" : "",
orphan_vginfo->vgid[0] ? orphan_vginfo->vgid : "",
orphan_vginfo->vgid[0] ? ")" : "");
orphan_vginfo->vgid[0] ? ")" : "", mdabuf);
}
if (!_insert_vginfo(vginfo, vgid, vgstatus, creation_host,
@ -947,13 +953,17 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
/* FIXME Check consistency of list! */
vginfo->fmt = fmt;
if (info)
log_debug("lvmcache: %s: now in VG %s%s%s%s",
if (info) {
if (info->mdas.n)
sprintf(mdabuf, " with %u mdas", list_size(&info->mdas));
else
mdabuf[0] = '\0';
log_debug("lvmcache: %s: now in VG %s%s%s%s%s",
dev_name(info->dev),
vgname, vginfo->vgid[0] ? " (" : "",
vginfo->vgid[0] ? vginfo->vgid : "",
vginfo->vgid[0] ? ")" : "");
else
vginfo->vgid[0] ? ")" : "", mdabuf);
} else
log_debug("lvmcache: initialised VG %s", vgname);
return 1;

View File

@ -1488,8 +1488,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
const struct format_type *fmt;
struct volume_group *vg, *correct_vg = NULL;
struct metadata_area *mda;
struct lvmcache_info *info;
int inconsistent = 0;
int inconsistent_vgid = 0;
int inconsistent_pvs = 0;
unsigned use_precommitted = precommitted;
struct list *pvids;
struct pv_list *pvl, *pvl2;
@ -1564,6 +1566,44 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
/* Ensure every PV in the VG was in the cache */
if (correct_vg) {
/*
* If the VG has PVs without mdas, they may still be
* orphans in the cache: update the cache state here.
*/
if (!inconsistent &&
list_size(&correct_vg->pvs) > list_size(pvids)) {
list_iterate_items(pvl, &correct_vg->pvs) {
if (!pvl->pv->dev) {
inconsistent_pvs = 1;
break;
}
if (str_list_match_item(pvids, pvl->pv->dev->pvid))
continue;
/*
* PV not marked as belonging to this VG in cache.
* Check it's an orphan without metadata area.
*/
if (!(info = info_from_pvid(pvl->pv->dev->pvid, 1)) ||
!info->vginfo || !is_orphan_vg(info->vginfo->vgname) ||
list_size(&info->mdas)) {
inconsistent_pvs = 1;
break;
}
}
/* If the check passed, let's update VG and recalculate pvids */
if (!inconsistent_pvs) {
log_debug("Updating cache for PVs without mdas "
"in VG %s.", vgname);
lvmcache_update_vg(correct_vg, use_precommitted);
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
return_NULL;
}
}
if (list_size(&correct_vg->pvs) != list_size(pvids)) {
log_debug("Cached VG %s had incorrect PV list",
vgname);