mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-24 17:57:48 +03:00
lvmcache: remove unused function
Drop lvmcache_fmt_from_vgname(), the way it was called made it identical to the existing lvmcache_vginfo_from_vgname().
This commit is contained in:
parent
550536474f
commit
49b8846567
54
lib/cache/lvmcache.c
vendored
54
lib/cache/lvmcache.c
vendored
@ -278,60 +278,6 @@ struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname, const ch
|
||||
return vginfo;
|
||||
}
|
||||
|
||||
const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd,
|
||||
const char *vgname, const char *vgid,
|
||||
unsigned revalidate_labels)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
struct lvmcache_info *info;
|
||||
struct dm_list *devh, *tmp;
|
||||
struct dm_list devs;
|
||||
struct device_list *devl;
|
||||
char vgid_found[ID_LEN + 1] __attribute__((aligned(8)));
|
||||
|
||||
if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this function is called repeatedly, only the first one needs to revalidate.
|
||||
*/
|
||||
if (!revalidate_labels)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* This function is normally called before reading metadata so
|
||||
* we check cached labels here. Unfortunately vginfo is volatile.
|
||||
*/
|
||||
dm_list_init(&devs);
|
||||
dm_list_iterate_items(info, &vginfo->infos) {
|
||||
if (!(devl = malloc(sizeof(*devl)))) {
|
||||
log_error("device_list element allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
devl->dev = info->dev;
|
||||
dm_list_add(&devs, &devl->list);
|
||||
}
|
||||
|
||||
memcpy(vgid_found, vginfo->vgid, sizeof(vgid_found));
|
||||
|
||||
dm_list_iterate_safe(devh, tmp, &devs) {
|
||||
devl = dm_list_item(devh, struct device_list);
|
||||
label_read(devl->dev);
|
||||
dm_list_del(&devl->list);
|
||||
free(devl);
|
||||
}
|
||||
|
||||
/* If vginfo changed, caller needs to rescan */
|
||||
if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid_found)) ||
|
||||
strncmp(vginfo->vgid, vgid_found, ID_LEN))
|
||||
return NULL;
|
||||
|
||||
out:
|
||||
return vginfo->fmt;
|
||||
}
|
||||
|
||||
struct lvmcache_vginfo *lvmcache_vginfo_from_vgid(const char *vgid)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
|
1
lib/cache/lvmcache.h
vendored
1
lib/cache/lvmcache.h
vendored
@ -91,7 +91,6 @@ void lvmcache_lock_vgname(const char *vgname, int read_only);
|
||||
void lvmcache_unlock_vgname(const char *vgname);
|
||||
|
||||
/* Queries */
|
||||
const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd, const char *vgname, const char *vgid, unsigned revalidate_labels);
|
||||
int lvmcache_lookup_mda(struct lvmcache_vgsummary *vgsummary);
|
||||
|
||||
struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname,
|
||||
|
@ -71,7 +71,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
* then do the initial label scan which reads all devices and
|
||||
* populates lvmcache with any VG name it finds. If the VG name
|
||||
* we want to use exists, then the label scan will find it,
|
||||
* and the fmt_from_vgname call (used to check if the name exists)
|
||||
* and the vginfo_from_vgname call (used to check if the name exists)
|
||||
* will return non-NULL.
|
||||
*/
|
||||
|
||||
@ -82,7 +82,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
lvmcache_label_scan(cmd);
|
||||
|
||||
if (lvmcache_fmt_from_vgname(cmd, vp_new.vg_name, NULL, 0)) {
|
||||
if (lvmcache_vginfo_from_vgname(vp_new.vg_name, NULL)) {
|
||||
unlock_vg(cmd, NULL, vp_new.vg_name);
|
||||
log_error("A volume group called %s already exists.", vp_new.vg_name);
|
||||
return ECMD_FAILED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user