1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

lvmetad: include both vgid and vgname in lookup request

When the command already knows both the vgid and vgname,
it should send both to lvmetad for a more exact request,
and it can save lvmetad the work of a name lookup.
This commit is contained in:
David Teigland 2015-11-24 14:47:53 -06:00
parent cd4d2cff97
commit 1f357532bb

25
lib/cache/lvmetad.c vendored
View File

@ -520,18 +520,29 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
if (vgid) { if (vgid) {
if (!id_write_format((const struct id*)vgid, uuid, sizeof(uuid))) if (!id_write_format((const struct id*)vgid, uuid, sizeof(uuid)))
return_NULL; return_NULL;
log_debug_lvmetad("Asking lvmetad for VG %s (%s)", uuid, vgname ? : "name unknown"); }
if (vgid && vgname) {
log_debug_lvmetad("Asking lvmetad for VG %s %s", uuid, vgname);
reply = _lvmetad_send("vg_lookup",
"uuid = %s", uuid,
"name = %s", vgname,
NULL);
diag_name = uuid;
} else if (vgid) {
log_debug_lvmetad("Asking lvmetad for VG vgid %s", uuid);
reply = _lvmetad_send("vg_lookup", "uuid = %s", uuid, NULL); reply = _lvmetad_send("vg_lookup", "uuid = %s", uuid, NULL);
diag_name = uuid; diag_name = uuid;
} else {
if (!vgname) { } else if (vgname) {
log_error(INTERNAL_ERROR "VG name required (VGID not available)");
reply = _lvmetad_send("vg_lookup", "name = %s", "MISSING", NULL);
goto out;
}
log_debug_lvmetad("Asking lvmetad for VG %s", vgname); log_debug_lvmetad("Asking lvmetad for VG %s", vgname);
reply = _lvmetad_send("vg_lookup", "name = %s", vgname, NULL); reply = _lvmetad_send("vg_lookup", "name = %s", vgname, NULL);
diag_name = vgname; diag_name = vgname;
} else {
log_error(INTERNAL_ERROR "VG name required (VGID not available)");
goto out;
} }
if (_lvmetad_handle_reply(reply, "lookup VG", diag_name, &found) && found) { if (_lvmetad_handle_reply(reply, "lookup VG", diag_name, &found) && found) {