mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o Get format1 building.
This commit is contained in:
parent
da4e57f2ba
commit
adbc44560b
@ -60,8 +60,6 @@ int import_pv(struct pool *mem, struct device *dev,
|
||||
pv->pe_count = pvd->pe_total;
|
||||
pv->pe_allocated = pvd->pe_allocated;
|
||||
|
||||
init_list(&pv->allocated);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -207,7 +205,6 @@ int export_vg(struct vg_disk *vgd, struct volume_group *vg)
|
||||
|
||||
int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd)
|
||||
{
|
||||
int len;
|
||||
memset(&lv->id, 0, sizeof(lv->id));
|
||||
if (!(lv->name = _create_lv_name(mem, lvd->lv_name))) {
|
||||
stack;
|
||||
@ -244,18 +241,11 @@ int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd)
|
||||
lv->status |= ALLOC_SIMPLE;
|
||||
|
||||
lv->read_ahead = lvd->lv_read_ahead;
|
||||
lv->stripes = lvd->lv_stripes;
|
||||
|
||||
lv->size = lvd->lv_size;
|
||||
lv->le_count = lvd->lv_allocated_le;
|
||||
|
||||
list_init(&lv->segments);
|
||||
|
||||
if (!lv->segments) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -289,7 +279,8 @@ void export_lv(struct lv_disk *lvd, struct volume_group *vg,
|
||||
lvd->lv_status |= LV_SPINDOWN;
|
||||
|
||||
lvd->lv_read_ahead = lv->read_ahead;
|
||||
lvd->lv_stripes = lv->stripes;
|
||||
lvd->lv_stripes = list_item(lv->segments.n,
|
||||
struct stripe_segment)->stripes;
|
||||
|
||||
lvd->lv_size = lv->size;
|
||||
lvd->lv_allocated_le = lv->le_count;
|
||||
@ -311,22 +302,19 @@ int export_extents(struct disk_list *dl, int lv_num,
|
||||
struct list *segh;
|
||||
struct pe_disk *ped;
|
||||
struct stripe_segment *seg;
|
||||
uint32_t pe;
|
||||
struct span *pes;
|
||||
uint32_t pe, s;
|
||||
|
||||
list_iterate (segh, &lv->segments) {
|
||||
seg = list_item(segh, struct stripe_segment);
|
||||
|
||||
for (a = 0; a < seg->stripes; a++) {
|
||||
if (seg->areas[a].pv != pv)
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
if (seg->area[s].pv != pv)
|
||||
continue; /* not our pv */
|
||||
|
||||
pes = seg->areas[a].pes;
|
||||
|
||||
for (pe = 0; pe < pe->len; pe++) {
|
||||
ped = &dl->extents[pe + pes->start];
|
||||
for (pe = 0; pe < seg->len; pe++) {
|
||||
ped = &dl->extents[pe + seg->area[s].pe];
|
||||
ped->lv_num = lv_num;
|
||||
ped->le_num = seg->le + a +
|
||||
ped->le_num = seg->le + s +
|
||||
(seg->stripes * pe);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@
|
||||
#include "metadata.h"
|
||||
#include "hash.h"
|
||||
#include "dbg_malloc.h"
|
||||
#include "log.h"
|
||||
#include "pool.h"
|
||||
#include "disk-rep.h"
|
||||
|
||||
/*
|
||||
* After much thought I have decided it is easier,
|
||||
@ -25,6 +28,8 @@ struct pe_specifier {
|
||||
|
||||
struct lv_map {
|
||||
struct logical_volume *lv;
|
||||
uint32_t stripes;
|
||||
uint32_t stripe_size;
|
||||
struct pe_specifier *map;
|
||||
};
|
||||
|
||||
@ -50,14 +55,14 @@ _create_lv_maps(struct pool *mem, struct volume_group *vg)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
lvm->lv = ll->lv;
|
||||
if (!(lvm->map = pool_zalloc(sizeof(*lvm->map)
|
||||
* ll->lv->le_count))) {
|
||||
lvm->lv = &ll->lv;
|
||||
if (!(lvm->map = pool_zalloc(mem, sizeof(*lvm->map)
|
||||
* ll->lv.le_count))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!hash_insert(maps, ll->lv->name, lvm)) {
|
||||
if (!hash_insert(maps, ll->lv.name, lvm)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
@ -87,16 +92,24 @@ static int _fill_lv_array(struct lv_map **lvs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
lvm->stripes = ll->lvd.lv_stripes;
|
||||
lvm->stripe_size = ll->lvd.lv_stripesize;
|
||||
|
||||
lvs[i++] = lvm;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _fill_maps(struct hash_table *maps, struct list *pvds)
|
||||
static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
|
||||
struct list *pvds)
|
||||
{
|
||||
struct list *pvdh;
|
||||
struct lv_map *map;
|
||||
struct disk_list *dl;
|
||||
struct physical_volume *pv;
|
||||
struct lv_map *lvms[MAX_LV], *lvm;
|
||||
struct pe_disk *e;
|
||||
uint32_t i, lv_num, le;
|
||||
|
||||
list_iterate(pvdh, pvds) {
|
||||
dl = list_item(pvdh, struct disk_list);
|
||||
@ -104,7 +117,7 @@ static int _fill_maps(struct hash_table *maps, struct list *pvds)
|
||||
e = dl->extents;
|
||||
|
||||
/* build an array of lv's for this pv */
|
||||
if (!_fill_lv_array(lvs, vg, dl)) {
|
||||
if (!_fill_lv_array(lvms, maps, dl)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -121,7 +134,7 @@ static int _fill_maps(struct hash_table *maps, struct list *pvds)
|
||||
|
||||
} else {
|
||||
lv_num--;
|
||||
lvm = lvs[lv_num];
|
||||
lvm = lvms[lv_num];
|
||||
le = e[i].le_num;
|
||||
|
||||
if (le >= lvm->lv->le_count) {
|
||||
@ -156,6 +169,7 @@ static int _check_single_map(struct lv_map *lvm)
|
||||
static int _check_maps_are_complete(struct hash_table *maps)
|
||||
{
|
||||
struct hash_node *n;
|
||||
struct lv_map *lvm;
|
||||
|
||||
for (n = hash_get_first(maps); n; n = hash_get_next(maps, n)) {
|
||||
lvm = (struct lv_map *) hash_get_data(maps, n);
|
||||
@ -174,7 +188,7 @@ static int _same_segment(struct stripe_segment *seg, struct lv_map *lvm,
|
||||
uint32_t s;
|
||||
uint32_t le = seg->le + (count * seg->stripes);
|
||||
|
||||
for (s = 0; s < stripes; s++) {
|
||||
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;
|
||||
@ -184,8 +198,8 @@ static int _same_segment(struct stripe_segment *seg, struct lv_map *lvm,
|
||||
|
||||
static int _build_segments(struct pool *mem, struct lv_map *lvm)
|
||||
{
|
||||
uint32_t stripes = lvm->lv->stripes;
|
||||
uint32_t le;
|
||||
uint32_t stripes = lvm->stripes;
|
||||
uint32_t le, s, count;
|
||||
struct stripe_segment *seg;
|
||||
size_t len;
|
||||
|
||||
@ -215,7 +229,7 @@ static int _build_segments(struct pool *mem, struct lv_map *lvm)
|
||||
|
||||
} while (_same_segment(seg, lvm, count++));
|
||||
|
||||
list_add(&lvm->lv->segments, seg);
|
||||
list_add(&lvm->lv->segments, &seg->list);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -254,7 +268,7 @@ int import_extents(struct pool *mem, struct volume_group *vg,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!_fill_maps(maps, pvds)) {
|
||||
if (!_fill_maps(maps, vg, pvds)) {
|
||||
log_err("Couldn't fill logical volume maps.");
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user