1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

o calculate pv_numbers and lv_numbers for LVM1 support

This commit is contained in:
Joe Thornber 2001-10-11 10:55:19 +00:00
parent 491ae26f6c
commit ab47fb661f
3 changed files with 44 additions and 0 deletions

View File

@ -216,5 +216,7 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
int export_uuids(struct disk_list *dl, struct volume_group *vg); int export_uuids(struct disk_list *dl, struct volume_group *vg);
void export_numbers(struct list_head *pvs, struct volume_group *vg);
#endif #endif

View File

@ -149,6 +149,8 @@ static int _flatten_vg(struct pool *mem, struct volume_group *vg,
list_add(&data->list, pvs); list_add(&data->list, pvs);
} }
export_numbers(pvs, vg);
return 1; return 1;
} }

View File

@ -526,3 +526,43 @@ int export_uuids(struct disk_list *dl, struct volume_group *vg)
} }
return 1; return 1;
} }
static int _get_lv_number(struct volume_group *vg, const char *name)
{
/* FIXME: inefficient */
struct list_head *tmp;
struct lv_list *ll;
int r = 0;
list_for_each (tmp, &vg->lvs) {
ll = list_entry(tmp, struct lv_list, list);
if (!strcmp(ll->lv.name, name))
break;
r++;
}
return r;
}
/*
* This calculates the nasty pv_number and
* lv_number fields used by LVM1. Very
* inefficient code.
*/
void export_numbers(struct list_head *pvs, struct volume_group *vg)
{
struct list_head *tmp, *tmp2;
struct disk_list *dl;
struct lvd_list *ll;
int pv_num = 0;
list_for_each (tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
dl->pv.pv_number = pv_num++;
list_for_each (tmp2, &dl->lvs) {
ll = list_entry(tmp2, struct lvd_list, list);
ll->lv.lv_number = _get_lv_number(vg, ll->lv.lv_name);
}
}
}