mirror of
git://sourceware.org/git/lvm2.git
synced 2025-10-28 15:33:16 +03:00
lvmcache: Drop a superfluous "fmt" pointer from lvmcache_info.
This commit is contained in:
24
lib/cache/lvmcache.c
vendored
24
lib/cache/lvmcache.c
vendored
@@ -39,7 +39,6 @@ struct lvmcache_info {
|
||||
struct dm_list list; /* Join VG members together */
|
||||
struct lvmcache_vginfo *vginfo; /* NULL == unknown */
|
||||
struct label *label; /* move to PV */
|
||||
const struct format_type *fmt;
|
||||
uint64_t device_size; /* move to label */ /* Bytes */
|
||||
uint32_t status;
|
||||
};
|
||||
@@ -1277,7 +1276,7 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
|
||||
if (!vgname && !info->vginfo) {
|
||||
log_error(INTERNAL_ERROR "NULL vgname handed to cache");
|
||||
/* FIXME Remove this */
|
||||
vgname = info->fmt->orphan_vg_name;
|
||||
vgname = label_fmt(info->label)->orphan_vg_name;
|
||||
vgid = vgname;
|
||||
}
|
||||
|
||||
@@ -1296,7 +1295,7 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
|
||||
info->status &= ~CACHE_INVALID;
|
||||
|
||||
if (!_lvmcache_update_vgname(info, vgname, vgid, vgstatus,
|
||||
creation_host, info->fmt) ||
|
||||
creation_host, label_fmt(info->label)) ||
|
||||
!_lvmcache_update_vgid(info, info->vginfo, vgid) ||
|
||||
!_lvmcache_update_vgstatus(info, vgstatus, creation_host))
|
||||
return_0;
|
||||
@@ -1423,7 +1422,6 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
label = info->label;
|
||||
}
|
||||
|
||||
info->fmt = (const struct format_type *) labeller->private;
|
||||
info->status |= CACHE_INVALID;
|
||||
|
||||
if (!_lvmcache_update_pvid(info, pvid_s)) {
|
||||
@@ -1546,7 +1544,7 @@ static int _get_pv_if_in_vg(struct lvmcache_info *info,
|
||||
strcpy(vgname, info->vginfo->vgname);
|
||||
memcpy(vgid, info->vginfo->vgid, sizeof(vgid));
|
||||
|
||||
if (get_pv_from_vg_by_id(info->fmt, vgname, vgid,
|
||||
if (get_pv_from_vg_by_id(label_fmt(info->label), vgname, vgid,
|
||||
info->label->dev->pvid, pv))
|
||||
return 1;
|
||||
}
|
||||
@@ -1566,7 +1564,7 @@ int lvmcache_populate_pv_fields(struct lvmcache_info *info,
|
||||
|
||||
/* Perform full scan (just the first time) and try again */
|
||||
if (!scan_label_only && !critical_section() && !full_scan_done()) {
|
||||
lvmcache_label_scan(info->fmt->cmd, 2);
|
||||
lvmcache_label_scan(label_fmt(info->label)->cmd, 2);
|
||||
|
||||
if (_get_pv_if_in_vg(info, pv))
|
||||
return 1;
|
||||
@@ -1574,7 +1572,7 @@ int lvmcache_populate_pv_fields(struct lvmcache_info *info,
|
||||
|
||||
/* Orphan */
|
||||
pv->dev = info->label->dev;
|
||||
pv->fmt = info->fmt;
|
||||
pv->fmt = label_fmt(info->label);
|
||||
pv->size = info->device_size >> SECTOR_SHIFT;
|
||||
pv->vg_name = FMT_TEXT_ORPHAN_VG_NAME;
|
||||
memcpy(&pv->id, &info->label->dev->pvid, sizeof(pv->id));
|
||||
@@ -1606,9 +1604,9 @@ int lvmcache_populate_pv_fields(struct lvmcache_info *info,
|
||||
|
||||
int lvmcache_check_format(struct lvmcache_info *info, const struct format_type *fmt)
|
||||
{
|
||||
if (info->fmt != fmt) {
|
||||
if (label_fmt(info->label) != fmt) {
|
||||
log_error("PV %s is a different format (seqno %s)",
|
||||
dev_name(info->label->dev), info->fmt->name);
|
||||
dev_name(info->label->dev), label_fmt(info->label)->name);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -1638,7 +1636,7 @@ void lvmcache_del_bas(struct lvmcache_info *info)
|
||||
int lvmcache_add_mda(struct lvmcache_info *info, struct device *dev,
|
||||
uint64_t start, uint64_t size, unsigned ignored)
|
||||
{
|
||||
return add_mda(info->fmt, NULL, &info->label->mdas, dev, start, size, ignored);
|
||||
return add_mda(label_fmt(info->label), NULL, &info->label->mdas, dev, start, size, ignored);
|
||||
}
|
||||
|
||||
int lvmcache_add_da(struct lvmcache_info *info, uint64_t start, uint64_t size)
|
||||
@@ -1655,7 +1653,9 @@ void lvmcache_update_pv(struct lvmcache_info *info, struct physical_volume *pv,
|
||||
const struct format_type *fmt)
|
||||
{
|
||||
info->device_size = pv->size << SECTOR_SHIFT;
|
||||
info->fmt = fmt;
|
||||
if (label_fmt(info->label) != fmt)
|
||||
log_error(INTERNAL_ERROR "Unexpected format mismatch on %s: %s found while %s expected.",
|
||||
dev_name(pv->dev), fmt->name, label_fmt(info->label)->name);
|
||||
}
|
||||
|
||||
int lvmcache_update_das(struct lvmcache_info *info, struct physical_volume *pv)
|
||||
@@ -1812,5 +1812,5 @@ uint64_t lvmcache_smallest_mda_size(struct lvmcache_info *info)
|
||||
}
|
||||
|
||||
const struct format_type *lvmcache_fmt(struct lvmcache_info *info) {
|
||||
return info->fmt;
|
||||
return label_fmt(info->label);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ struct labeller *lvm1_labeller_create(struct format_type *fmt)
|
||||
}
|
||||
|
||||
l->ops = &_lvm1_ops;
|
||||
l->private = (const void *) fmt;
|
||||
l->fmt = fmt;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ struct labeller *pool_labeller_create(struct format_type *fmt)
|
||||
}
|
||||
|
||||
l->ops = &_pool_ops;
|
||||
l->private = (const void *) fmt;
|
||||
l->fmt = fmt;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ struct _update_mda_baton {
|
||||
static int _update_mda(struct metadata_area *mda, void *baton)
|
||||
{
|
||||
struct _update_mda_baton *p = baton;
|
||||
const struct format_type *fmt = p->label->labeller->private; // Oh dear.
|
||||
const struct format_type *fmt = label_fmt(p->label);
|
||||
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
|
||||
struct mda_header *mdah;
|
||||
const char *vgname = NULL;
|
||||
@@ -473,7 +473,7 @@ struct labeller *text_labeller_create(const struct format_type *fmt)
|
||||
}
|
||||
|
||||
l->ops = &_text_ops;
|
||||
l->private = (const void *) fmt;
|
||||
l->fmt = fmt;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -392,3 +392,8 @@ struct label *label_create(struct labeller *labeller)
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
const struct format_type *label_fmt(struct label *label)
|
||||
{
|
||||
return label->labeller->fmt;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ struct label_ops {
|
||||
|
||||
struct labeller {
|
||||
struct label_ops *ops;
|
||||
const void *private;
|
||||
const struct format_type *fmt;
|
||||
};
|
||||
|
||||
int label_init(void);
|
||||
@@ -107,5 +107,6 @@ int label_write(struct device *dev, struct label *label);
|
||||
int label_verify(struct device *dev);
|
||||
struct label *label_create(struct labeller *labeller);
|
||||
void label_destroy(struct label *label);
|
||||
const struct format_type *label_fmt(struct label *label);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user