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

Use lvmcache_update_vgname_and_id throughout.

This commit is contained in:
Alasdair Kergon 2006-04-11 16:00:26 +00:00
parent cced28dac3
commit f9c232c2ee
5 changed files with 25 additions and 25 deletions

32
lib/cache/lvmcache.c vendored
View File

@ -348,7 +348,7 @@ static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid)
return 1;
}
int lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
static int _lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
{
if (!vgid || !info->vginfo || !strncmp(info->vginfo->vgid, vgid,
sizeof(info->vginfo->vgid)))
@ -375,7 +375,8 @@ int lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
return 1;
}
int lvmcache_update_vgname(struct lvmcache_info *info, const char *vgname)
static int _lvmcache_update_vgname(struct lvmcache_info *info,
const char *vgname)
{
struct lvmcache_vginfo *vginfo;
@ -434,25 +435,30 @@ int lvmcache_update_vgname(struct lvmcache_info *info, const char *vgname)
return 1;
}
int lvmcache_update_vgname_and_id(struct lvmcache_info *info, const char *vgname, const char *vgid)
{
if (!_lvmcache_update_vgname(info, vgname) ||
!_lvmcache_update_vgid(info, vgid))
return_0;
return 1;
}
int lvmcache_update_vg(struct volume_group *vg)
{
struct pv_list *pvl;
struct lvmcache_info *info;
char pvid_s[ID_LEN + 1];
int vgid_updated = 0;
pvid_s[sizeof(pvid_s) - 1] = '\0';
list_iterate_items(pvl, &vg->pvs) {
strncpy(pvid_s, (char *) &pvl->pv->id, sizeof(pvid_s) - 1);
/* FIXME Could pvl->pv->dev->pvid ever be different? */
if ((info = info_from_pvid(pvid_s))) {
lvmcache_update_vgname(info, vg->name);
if (!vgid_updated) {
lvmcache_update_vgid(info, (char *) &vg->id);
vgid_updated = 1;
}
}
if ((info = info_from_pvid(pvid_s)) &&
!lvmcache_update_vgname_and_id(info, vg->name,
(char *) &vg->id))
return_0;
}
return 1;
@ -556,7 +562,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
return NULL;
}
if (!lvmcache_update_vgname(info, vgname)) {
if (!lvmcache_update_vgname_and_id(info, vgname, vgid)) {
if (!existing) {
dm_hash_remove(_pvid_hash, pvid_s);
strcpy(info->dev->pvid, "");
@ -566,10 +572,6 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
return NULL;
}
if (!lvmcache_update_vgid(info, vgid))
/* Non-critical */
stack;
return info;
}

View File

@ -68,8 +68,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
void lvmcache_del(struct lvmcache_info *info);
/* Update things */
int lvmcache_update_vgname(struct lvmcache_info *info, const char *vgname);
int lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid);
int lvmcache_update_vgname_and_id(struct lvmcache_info *info, const char *vgname, const char *vgid);
int lvmcache_update_vg(struct volume_group *vg);
void lvmcache_lock_vgname(const char *vgname, int read_only);

View File

@ -219,7 +219,7 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
error:
if ((info = info_from_pvid(dev_area->dev->pvid)))
lvmcache_update_vgname(info, ORPHAN);
lvmcache_update_vgname_and_id(info, ORPHAN, NULL);
return NULL;
}

View File

@ -234,10 +234,9 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
list_iterate_items(mda, &info->mdas) {
mdac = (struct mda_context *) mda->metadata_locn;
if ((vgname = vgname_from_mda(info->fmt, &mdac->area,
&vgid))) {
lvmcache_update_vgname(info, vgname);
lvmcache_update_vgid(info, (char *) &vgid);
}
&vgid)) &&
!lvmcache_update_vgname_and_id(info, vgname, (char *) &vgid))
return_0;
}
info->status &= ~CACHE_INVALID;

View File

@ -175,7 +175,7 @@ static struct labeller *_find_labeller(struct device *dev, char *buf,
out:
if (!found) {
if ((info = info_from_pvid(dev->pvid)))
lvmcache_update_vgname(info, ORPHAN);
lvmcache_update_vgname_and_id(info, ORPHAN, NULL);
log_very_verbose("%s: No label detected", dev_name(dev));
}
@ -267,7 +267,7 @@ int label_read(struct device *dev, struct label **result)
stack;
if ((info = info_from_pvid(dev->pvid)))
lvmcache_update_vgname(info, ORPHAN);
lvmcache_update_vgname_and_id(info, ORPHAN, NULL);
goto out;
}
@ -348,7 +348,7 @@ int label_verify(struct device *dev)
stack;
if ((info = info_from_pvid(dev->pvid)))
lvmcache_update_vgname(info, ORPHAN);
lvmcache_update_vgname_and_id(info, ORPHAN, NULL);
goto out;
}