diff options
author | Alasdair Kergon <agk@redhat.com> | 2001-12-07 21:17:12 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2001-12-07 21:17:12 +0000 |
commit | b74c8033a262d2338bf592d8e7f9640f44fca577 (patch) | |
tree | 39b81a280361d81caf2603a85aaf3b940ae8e5a8 /lib/metadata/pv_map.c | |
parent | b6af4a0aab6ff1215c9429ab8b0c4f7f531c6b9c (diff) | |
download | lvm2-b74c8033a262d2338bf592d8e7f9640f44fca577.tar.gz |
Fixes for allocation of striped volumes.
Diffstat (limited to 'lib/metadata/pv_map.c')
-rw-r--r-- | lib/metadata/pv_map.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/metadata/pv_map.c b/lib/metadata/pv_map.c index efb8b31c8..14ecfe783 100644 --- a/lib/metadata/pv_map.c +++ b/lib/metadata/pv_map.c @@ -49,7 +49,11 @@ static int _set_allocated(struct hash_table *hash, } /* sanity check */ - assert(!bit(pvm->allocated_extents, pe)); + if (bit(pvm->allocated_extents, pe)) { + log_error("Physical extent %d of %s referenced by more than " + "one logical volume", pe, dev_name(pv->dev)); + return 0; + } bit_set(pvm->allocated_extents, pe); return 1; @@ -60,9 +64,10 @@ static int _fill_bitsets(struct volume_group *vg, struct list *maps) struct list *lvh, *pvmh, *segh; struct logical_volume *lv; struct pv_map *pvm; - uint32_t i, r = 0; + uint32_t s, pe; struct hash_table *hash; struct stripe_segment *seg; + int r = 0; if (!(hash = hash_create(128))) { log_err("Couldn't create hash table for pv maps."); @@ -85,13 +90,16 @@ static int _fill_bitsets(struct volume_group *vg, struct list *maps) list_iterate (segh, &lv->segments) { seg = list_item(segh, struct stripe_segment); - for (i = 0; i < seg->len; i++) { - if (!_set_allocated(hash, - seg->area[i % seg->stripes].pv, - seg->area[i % seg->stripes].pe + - (i / seg->stripes))) { - stack; - goto out; + for (s = 0; s < seg->stripes; s++) { + for (pe = 0; pe < (seg->len / seg->stripes); + pe++) { + if (!_set_allocated(hash, + seg->area[s].pv, + seg->area[s].pe + + pe)) { + stack; + goto out; + } } } } |