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

o I was reading striped volumes incorrectly.

This commit is contained in:
Joe Thornber 2001-11-29 14:13:43 +00:00
parent d5880f97c5
commit 74af29faae
2 changed files with 59 additions and 32 deletions

View File

@ -311,7 +311,7 @@ int export_extents(struct disk_list *dl, int lv_num,
if (seg->area[s].pv != pv) if (seg->area[s].pv != pv)
continue; /* not our pv */ continue; /* not our pv */
for (pe = 0; pe < seg->len; pe++) { for (pe = 0; pe < (seg->len / seg->stripes); pe++) {
ped = &dl->extents[pe + seg->area[s].pe]; ped = &dl->extents[pe + seg->area[s].pe];
ped->lv_num = lv_num; ped->lv_num = lv_num;
ped->le_num = seg->le + s + ped->le_num = seg->le + s +

View File

@ -128,6 +128,7 @@ static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
if (lv_num == UNMAPPED_EXTENT) if (lv_num == UNMAPPED_EXTENT)
continue; continue;
else { else {
lv_num--; lv_num--;
lvm = lvms[lv_num]; lvm = lvms[lv_num];
@ -190,53 +191,44 @@ static int _check_maps_are_complete(struct hash_table *maps)
return 1; return 1;
} }
static int _same_segment(struct stripe_segment *seg, struct lv_map *lvm, static struct stripe_segment *_alloc_seg(struct pool *mem, uint32_t stripes)
uint32_t count)
{ {
uint32_t s;
uint32_t le = seg->le + (count * seg->stripes);
for (s = 0; s < seg->stripes; s++) {
if ((lvm->map[le + s].pv != seg->area[s].pv) ||
(lvm->map[le + s].pe != seg->area[s].pe + count))
return 0;
}
return 1;
}
static int _build_segments(struct pool *mem, struct lv_map *lvm)
{
uint32_t stripes = lvm->stripes;
uint32_t le, s, count;
struct stripe_segment *seg; struct stripe_segment *seg;
size_t len; uint32_t len = sizeof(*seg) + (stripes * sizeof(seg->area[0]));
len = sizeof(*seg) * (stripes * sizeof(seg->area[0]));
le = 0;
while (le < lvm->lv->le_count) {
if (!(seg = pool_zalloc(mem, len))) { if (!(seg = pool_zalloc(mem, len))) {
stack; stack;
return 0; return NULL;
} }
return seg;
}
static int _read_linear(struct pool *mem, struct lv_map *lvm)
{
uint32_t le = 0;
struct stripe_segment *seg;
while (le < lvm->lv->le_count) {
seg = _alloc_seg(mem, 1);
seg->lv = lvm->lv; seg->lv = lvm->lv;
seg->le = le; seg->le = le;
seg->len = 0; seg->len = 0;
seg->stripe_size = lvm->stripe_size; seg->stripe_size = 0;
seg->stripes = stripes; seg->stripes = 1;
for (s = 0; s < stripes; s++) { seg->area[0].pv = lvm->map[le].pv;
seg->area[s].pv = lvm->map[le + s].pv; seg->area[0].pe = lvm->map[le].pe;
seg->area[s].pe = lvm->map[le + s].pe;
}
count = 1; do
do { seg->len++;
le += stripes;
seg->len += stripes;
} while (_same_segment(seg, lvm, count++)); while ((lvm->map[le + seg->len].pv == seg->area[0].pv) &&
(lvm->map[le + seg->len].pe == seg->area[0].pe +
seg->len));
le += seg->len;
list_add(&lvm->lv->segments, &seg->list); list_add(&lvm->lv->segments, &seg->list);
} }
@ -244,6 +236,41 @@ static int _build_segments(struct pool *mem, struct lv_map *lvm)
return 1; return 1;
} }
static int _read_stripes(struct pool *mem, struct lv_map *lvm)
{
uint32_t stripes = lvm->stripes, s;
uint32_t stripe_len = lvm->lv->le_count / stripes;
struct stripe_segment *seg;
struct pe_specifier *pes;
if (!(seg = _alloc_seg(mem, stripes))) {
stack;
return 0;
}
seg->lv = lvm->lv;
seg->le = 0;
seg->len = lvm->lv->le_count;
seg->stripe_size = lvm->stripe_size;
seg->stripes = stripes;
for (s = 0; s < stripes; s++) {
pes = &lvm->map[s * stripe_len];
seg->area[s].pv = pes->pv;
seg->area[s].pe = pes->pe;
}
list_add(&lvm->lv->segments, &seg->list);
return 1;
}
static int _build_segments(struct pool *mem, struct lv_map *lvm)
{
return (lvm->stripes > 1 ? _read_stripes(mem, lvm) :
_read_linear(mem, lvm));
}
static int _build_all_segments(struct pool *mem, struct hash_table *maps) static int _build_all_segments(struct pool *mem, struct hash_table *maps)
{ {
struct hash_node *n; struct hash_node *n;