1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

set_lv_segment_area_pv/lv

This commit is contained in:
Alasdair Kergon 2005-04-22 15:43:02 +00:00
parent c54a940540
commit e40d124e14
7 changed files with 41 additions and 36 deletions

View File

@ -1,5 +1,6 @@
Version 2.01.10 -
================================
Tidy lv_segment interface.
Initial pv_segment support.
vgchange --physicalextentsize
Internal snapshot restructuring.

View File

@ -224,9 +224,7 @@ static int _read_linear(struct cmd_context *cmd, struct lv_map *lvm)
seg->area_len = 0;
seg->stripe_size = 0;
seg->area[0].type = AREA_PV;
seg->area[0].u.pv.pv = lvm->map[le].pv;
seg->area[0].u.pv.pe = lvm->map[le].pe;
set_lv_segment_area_pv(seg, 0, lvm->map[le].pv, lvm->map[le].pe);
do {
seg->len++;

View File

@ -225,6 +225,7 @@ static int _add_stripe_seg(struct pool *mem,
seg->stripe_size = usp->striping;
seg->status |= 0;
seg->le += *le_cur;
seg->lv = lv;
/* add the subpool type to the segment tag list */
str_list_add(mem, &seg->tags, _cvt_sptype(usp->type));
@ -239,13 +240,12 @@ static int _add_stripe_seg(struct pool *mem,
seg->area_len = (usp->devs[j].blocks) / POOL_PE_SIZE;
seg->len += seg->area_len;
*le_cur += seg->area_len;
seg->lv = lv;
seg->area[j].type = AREA_PV;
seg->area[j].u.pv.pv = usp->devs[j].pv;
seg->area[j].u.pv.pe = 0;
set_lv_segment_area_pv(seg, j, usp->devs[j].pv, 0);
}
list_add(&lv->segments, &seg->list);
return 1;
}
@ -280,9 +280,7 @@ static int _add_linear_seg(struct pool *mem,
seg->area_len = (usp->devs[j].blocks) / POOL_PE_SIZE;
seg->len = seg->area_len;
*le_cur += seg->len;
seg->area[0].type = AREA_PV;
seg->area[0].u.pv.pv = usp->devs[j].pv;
seg->area[0].u.pv.pe = 0;
set_lv_segment_area_pv(seg, 0, usp->devs[j].pv, 0);
list_add(&lv->segments, &seg->list);
}
return 1;

View File

@ -369,19 +369,14 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
/* FIXME Cope if LV not yet read in */
if ((pv = hash_lookup(pv_hash, cv->v.str))) {
seg->area[s].type = AREA_PV;
seg->area[s].u.pv.pv = pv;
seg->area[s].u.pv.pe = cv->next->v.i;
set_lv_segment_area_pv(seg, s, pv, cv->next->v.i);
/*
* Adjust extent counts in the pv and vg.
*/
pv->pe_alloc_count += seg->area_len;
seg->lv->vg->free_count -= seg->area_len;
} else if ((lv1 = find_lv(seg->lv->vg, cv->v.str))) {
seg->area[s].type = AREA_LV;
seg->area[s].u.lv.lv = lv1;
seg->area[s].u.lv.le = cv->next->v.i;
set_lv_segment_area_lv(seg, s, lv1, cv->next->v.i);
} else {
log_error("Couldn't find volume '%s' "
"for segment '%s'.",

View File

@ -20,4 +20,9 @@ struct lv_segment *alloc_lv_segment(struct pool *mem, uint32_t num_areas);
struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
uint32_t allocated);
void set_lv_segment_area_pv(struct lv_segment *seg, uint32_t area_num,
struct physical_volume *pv, uint32_t pe);
void set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,
struct logical_volume *lv, uint32_t le);
#endif

View File

@ -77,6 +77,23 @@ struct lv_segment *alloc_lv_segment(struct pool *mem, uint32_t num_areas)
return seg;
}
void set_lv_segment_area_pv(struct lv_segment *seg, uint32_t area_num,
struct physical_volume *pv, uint32_t pe)
{
seg->area[area_num].type = AREA_PV;
seg->area[area_num].u.pv.pv = pv;
seg->area[area_num].u.pv.pe = pe;
seg->area[area_num].u.pv.pvseg = NULL;
}
void set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,
struct logical_volume *lv, uint32_t le)
{
seg->area[area_num].type = AREA_LV;
seg->area[area_num].u.lv.lv = lv;
seg->area[area_num].u.lv.le = le;
}
static int _alloc_parallel_area(struct logical_volume *lv, uint32_t area_count,
uint32_t stripe_size,
struct segment_type *segtype,
@ -113,9 +130,7 @@ static int _alloc_parallel_area(struct logical_volume *lv, uint32_t area_count,
for (s = 0; s < area_count; s++) {
struct pv_area *pva = areas[s];
seg->area[s].type = AREA_PV;
seg->area[s].u.pv.pv = pva->map->pvl->pv;
seg->area[s].u.pv.pe = pva->start;
set_lv_segment_area_pv(seg, s, pva->map->pvl->pv, pva->start);
consume_pv_area(pva, area_len);
}
@ -241,9 +256,7 @@ static int _alloc_linear_area(struct logical_volume *lv, uint32_t *ix,
seg->len = count;
seg->area_len = count;
seg->stripe_size = 0;
seg->area[0].type = AREA_PV;
seg->area[0].u.pv.pv = map->pvl->pv;
seg->area[0].u.pv.pe = pva->start;
set_lv_segment_area_pv(seg, 0, map->pvl->pv, pva->start);
list_add(&lv->segments, &seg->list);
@ -280,12 +293,8 @@ static int _alloc_mirrored_area(struct logical_volume *lv, uint32_t *ix,
seg->stripe_size = 0;
seg->extents_copied = 0u;
/* FIXME Remove AREA_PV restriction here? */
seg->area[0].type = AREA_PV;
seg->area[0].u.pv.pv = mirrored_pv;
seg->area[0].u.pv.pe = mirrored_pe;
seg->area[1].type = AREA_PV;
seg->area[1].u.pv.pv = map->pvl->pv;
seg->area[1].u.pv.pe = pva->start;
set_lv_segment_area_pv(seg, 0, mirrored_pv, mirrored_pe);
set_lv_segment_area_pv(seg, 1, map->pvl->pv, pva->start);
list_add(&lv->segments, &seg->list);
consume_pv_area(pva, count);

View File

@ -19,6 +19,7 @@
#include "segtype.h"
#include "display.h"
#include "activate.h"
#include "lv_alloc.h"
/*
* Replace any LV segments on given PV with temporary mirror.
@ -153,9 +154,7 @@ int insert_pvmove_mirrors(struct cmd_context *cmd,
"temporary LV for pvmove.");
return 0;
}
seg->area[s].type = AREA_LV;
seg->area[s].u.lv.lv = lv_mirr;
seg->area[s].u.lv.le = start_le;
set_lv_segment_area_lv(seg, s, lv_mirr, start_le);
extent_count += seg->area_len;
@ -225,9 +224,9 @@ int remove_pvmove_mirrors(struct volume_group *vg,
else
c = 0;
seg->area[s].type = AREA_PV;
seg->area[s].u.pv.pv = mir_seg->area[c].u.pv.pv;
seg->area[s].u.pv.pe = mir_seg->area[c].u.pv.pe;
set_lv_segment_area_pv(seg, s,
mir_seg->area[c].u.pv.pv,
mir_seg->area[c].u.pv.pe);
/* Replace mirror with old area */
if (!