main - cleanup: compare only LV uuid part
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6d6e1ae8873cc4b91425e8f2edeba88cf79d8321 Commit: 6d6e1ae8873cc4b91425e8f2edeba88cf79d8321 Parent: 64447e9d9b237bf7955a84ab028a0d9b552e6ac7 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Mar 8 08:07:47 2021 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Mar 8 15:43:27 2021 +0100
cleanup: compare only LV uuid part
Match VG uuid just once per list of all LVs in VG.
TODO: maybe some more efficeint tree or hash could be better here, but since it's used not so often, the total benefit is not so great, so ATM just reducing amount of checked bytes.
--- lib/metadata/metadata.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/metadata/metadata.c +5 -2
@@ -1664,9 +1664,12 @@ struct logical_volume *find_lv_in_vg_by_lvid(struct volume_group *vg, {struct lv_list *lvl; +if (memcmp (&lvid->id[0 ], &vg->id,sizeof (vg->id))) +return NULL ;/* Check VG does not match */ + dm_list_iterate_items(lvl, &vg->lvs) -if (!strncmp (lvl->lv->lvid.s, lvid->s,sizeof (*lvid))) -return lvl->lv; +if (!memcmp (&lvid->id[1 ], &lvl->lv->lvid.id[1 ],sizeof (lvid->id[1 ]))) +return lvl->lv;/* LV uuid match */ return NULL ; }