mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
manip: optimize lvs_using_lv
Instead of checking all LVs in a VG - do just a direct copy of LVs from the existing list ->segs_using_thin_lv. TODO: maybe it could be better to expose seg_list to /tools...
This commit is contained in:
parent
c21440536d
commit
3d9fc7d6f3
@ -1323,10 +1323,8 @@ struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
struct logical_volume *lv)
|
struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
struct dm_list *lvs;
|
struct dm_list *lvs;
|
||||||
struct logical_volume *lv1;
|
struct lv_list *lvl;
|
||||||
struct lv_list *lvl, *lvl1;
|
struct seg_list *sl;
|
||||||
struct lv_segment *seg;
|
|
||||||
uint32_t s;
|
|
||||||
|
|
||||||
if (!(lvs = dm_pool_alloc(cmd->mem, sizeof(*lvs)))) {
|
if (!(lvs = dm_pool_alloc(cmd->mem, sizeof(*lvs)))) {
|
||||||
log_error("lvs list alloc failed.");
|
log_error("lvs list alloc failed.");
|
||||||
@ -1335,29 +1333,14 @@ struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
|
|
||||||
dm_list_init(lvs);
|
dm_list_init(lvs);
|
||||||
|
|
||||||
/* Loop through all LVs except the one supplied */
|
dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
|
||||||
dm_list_iterate_items(lvl1, &vg->lvs) {
|
|
||||||
lv1 = lvl1->lv;
|
|
||||||
if (lv1 == lv)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Find whether any segment points at the supplied LV */
|
/* Find whether any segment points at the supplied LV */
|
||||||
dm_list_iterate_items(seg, &lv1->segments) {
|
|
||||||
for (s = 0; s < seg->area_count; s++) {
|
|
||||||
if (seg_type(seg, s) != AREA_LV ||
|
|
||||||
seg_lv(seg, s) != lv)
|
|
||||||
continue;
|
|
||||||
if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl)))) {
|
if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl)))) {
|
||||||
log_error("lv_list alloc failed.");
|
log_error("lv_list alloc failed.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
lvl->lv = lv1;
|
lvl->lv = sl->seg->lv;
|
||||||
dm_list_add(lvs, &lvl->list);
|
dm_list_add(lvs, &lvl->list);
|
||||||
goto next_lv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next_lv:
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return lvs;
|
return lvs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user