mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-13 17:18:32 +03:00
o Tool support for segments.
o vgmerge working.
This commit is contained in:
parent
170f08cee0
commit
579944d327
@ -49,6 +49,16 @@ static inline int list_empty(struct list *head) {
|
||||
#define list_iterate(v, head) \
|
||||
for (v = (head)->n; v != head; v = v->n)
|
||||
|
||||
static inline int list_size(struct list *head) {
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
#define list_item(v, t) \
|
||||
((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
|
||||
|
||||
|
@ -359,12 +359,11 @@ int lvdisplay_full(struct logical_volume *lv)
|
||||
}
|
||||
******************/
|
||||
|
||||
if (lv->stripes > 1) {
|
||||
log_print("Stripes %u", lv->stripes);
|
||||
/*********** FIXME stripesize
|
||||
log_print("Segments %u", list_size(&lv->segments));
|
||||
|
||||
/********* FIXME Stripes & stripesize for each segment
|
||||
log_print("Stripe size (KByte) %u", lv->stripesize / 2);
|
||||
***********/
|
||||
}
|
||||
|
||||
/**************
|
||||
#ifdef LVM_FUTURE
|
||||
@ -417,6 +416,7 @@ void lvdisplay_extents(struct logical_volume *lv)
|
||||
"volumes ---");
|
||||
log_verbose("PV Name PE on PV ");
|
||||
|
||||
/********* FIXME Segments & Stripes
|
||||
list_iterate(pvh, &lv->vg->pvs) {
|
||||
int count = 0;
|
||||
pv = &list_item(pvh, struct pv_list)->pv;
|
||||
@ -427,6 +427,7 @@ void lvdisplay_extents(struct logical_volume *lv)
|
||||
log_verbose("%-25s %d", dev_name(pv->dev), count);
|
||||
}
|
||||
|
||||
**********/
|
||||
/********* FIXME "reads writes"
|
||||
|
||||
|
||||
@ -439,10 +440,12 @@ void lvdisplay_extents(struct logical_volume *lv)
|
||||
log_verbose("--- Logical extents ---");
|
||||
log_verbose("LE PV PE");
|
||||
|
||||
/******** FIXME Segments & Stripes
|
||||
for (le = 0; le < lv->le_count; le++) {
|
||||
log_verbose("%05d %-25s %05u ", le,
|
||||
dev_name(lv->map[le].pv->dev), lv->map[le].pe);
|
||||
}
|
||||
******/
|
||||
|
||||
log_verbose(" ");
|
||||
|
||||
|
@ -80,13 +80,13 @@ static int _fill_lv_array(struct lv_map **lvs,
|
||||
{
|
||||
struct list *lvh;
|
||||
struct lv_map *lvm;
|
||||
int i = 0;
|
||||
|
||||
memset(lvs, 0, sizeof(*lvs) * MAX_LV);
|
||||
list_iterate(lvh, &dl->lvds) {
|
||||
struct lvd_list *ll = list_item(lvh, struct lvd_list);
|
||||
|
||||
if (!(lvm = hash_lookup(maps, ll->lvd.lv_name))) {
|
||||
if (!(lvm = hash_lookup(maps, strrchr(ll->lvd.lv_name, '/')
|
||||
+ 1 ))) {
|
||||
log_err("Physical volume (%s) contains an "
|
||||
"unknown logical volume (%s).",
|
||||
dev_name(dl->dev), ll->lvd.lv_name);
|
||||
@ -128,8 +128,7 @@ static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
|
||||
|
||||
if (lv_num == UNMAPPED_EXTENT)
|
||||
continue;
|
||||
|
||||
} else {
|
||||
else {
|
||||
lv_num--;
|
||||
lvm = lvms[lv_num];
|
||||
|
||||
|
@ -319,6 +319,7 @@ struct logical_volume *lv_create(const char *name,
|
||||
lv->read_ahead = 0;
|
||||
lv->size = extents * vg->extent_size;
|
||||
lv->le_count = extents;
|
||||
lv->vg = vg;
|
||||
list_init(&lv->segments);
|
||||
|
||||
if (!_allocate(vg, lv, acceptable_pvs, 0u, stripes, stripe_size)) {
|
||||
@ -328,7 +329,6 @@ struct logical_volume *lv_create(const char *name,
|
||||
|
||||
vg->lv_count++;
|
||||
list_add(&vg->lvs, &ll->list);
|
||||
lv->vg = vg;
|
||||
|
||||
return lv;
|
||||
|
||||
|
@ -274,7 +274,7 @@ struct logical_volume *find_lv(struct volume_group *vg, const char *lv_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct physical_volume *_find_pv(struct volume_group *vg, struct device *dev)
|
||||
struct physical_volume *find_pv(struct volume_group *vg, struct device *dev)
|
||||
{
|
||||
struct list *pvh;
|
||||
struct physical_volume *pv;
|
||||
|
@ -49,6 +49,16 @@ static inline int list_empty(struct list *head) {
|
||||
#define list_iterate(v, head) \
|
||||
for (v = (head)->n; v != head; v = v->n)
|
||||
|
||||
static inline int list_size(struct list *head) {
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
#define list_item(v, t) \
|
||||
((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
|
||||
|
||||
|
@ -58,7 +58,7 @@ CFLAGS+=-g -fno-omit-frame-pointer
|
||||
#CFLAGS+=-pg
|
||||
#LD_FLAGS=-pg
|
||||
|
||||
CFLAGS+=-DDEBUG_MEM -DDEBUG -DDEBUG_POOL
|
||||
CFLAGS+=-DDEBUG_MEM -DDEBUG #-DDEBUG_POOL
|
||||
#CFLAGS+=-DBOUNDS_CHECK
|
||||
|
||||
INCLUDES+=-I. -I$(top_srcdir)/include
|
||||
|
@ -34,9 +34,8 @@ int lvresize(int argc, char **argv)
|
||||
char *st;
|
||||
char *dummy;
|
||||
const char *cmd_name;
|
||||
struct list *lvh, *pvh, *pvl;
|
||||
struct list *lvh, *pvh, *pvl, *segh;
|
||||
int opt = 0;
|
||||
int seg;
|
||||
|
||||
enum {
|
||||
LV_ANY = 0,
|
||||
@ -179,9 +178,13 @@ int lvresize(int argc, char **argv)
|
||||
|
||||
/* If extending, find stripes, stripesize & size of last segment */
|
||||
if (extents > lv->le_count && (!stripes || !stripesize)) {
|
||||
for (seg = 0; seg < lv->segment_count; seg++) {
|
||||
uint32_t sz = lv->segments[seg]->stripesize;
|
||||
uint32_t str = lv->segments[seg]->stripes;
|
||||
list_iterate(segh, &lv->segments) {
|
||||
struct stripe_segment *seg;
|
||||
uint32_t sz, str;
|
||||
|
||||
seg = list_item(segh, struct stripe_segment);
|
||||
sz = seg->stripe_size;
|
||||
str = seg->stripes;
|
||||
|
||||
if ((seg_stripesize && seg_stripesize != sz
|
||||
&& !stripesize) ||
|
||||
@ -211,12 +214,16 @@ int lvresize(int argc, char **argv)
|
||||
if (stripes || stripesize)
|
||||
log_error("Ignoring stripes and stripesize arguments "
|
||||
"when reducing");
|
||||
for (seg = 0; seg < lv->segment_count; seg++) {
|
||||
uint32_t seg_extents = lv->segments[seg]->pe_count *
|
||||
vg->extent_size;
|
||||
|
||||
seg_stripesize = lv->segments[seg]->stripesize;
|
||||
seg_stripes = lv->segments[seg]->stripes;
|
||||
list_iterate(segh, &lv->segments) {
|
||||
struct stripe_segment *seg;
|
||||
uint32_t seg_extents;
|
||||
|
||||
seg = list_item(segh, struct stripe_segment);
|
||||
seg_extents = seg->len;
|
||||
|
||||
seg_stripesize = seg->stripe_size;
|
||||
seg_stripes = seg->stripes;
|
||||
|
||||
if (extents <= extents_used + seg_extents)
|
||||
break;
|
||||
|
@ -94,9 +94,11 @@ static int lvscan_single(struct logical_volume *lv)
|
||||
dbg_free(dummy);
|
||||
|
||||
/* FIXME sprintf? */
|
||||
/* FIXME Handle segments? */
|
||||
|
||||
/*********** FIXME Handle segments?
|
||||
if (lv->segments[0]->stripes > 1 && !(lv->status & SNAPSHOT))
|
||||
log_print(" striped[%u]", lv->segments[0]->stripes);
|
||||
****************/
|
||||
|
||||
/******** FIXME Device number display & Snapshot
|
||||
if (arg_count(blockdevice_ARG))
|
||||
|
@ -116,14 +116,22 @@ int vgmerge_single(const char *vg_name_to, const char *vg_name_from)
|
||||
|
||||
/* Merge volume groups */
|
||||
while (!list_empty(&vg_from->pvs)) {
|
||||
list_del(&vg_from->pvs);
|
||||
list_add(&vg_to->pvs, &vg_from->pvs);
|
||||
struct list *pvh = vg_from->pvs.n;
|
||||
struct physical_volume *pv;
|
||||
|
||||
list_del(pvh);
|
||||
list_add(&vg_to->pvs, pvh);
|
||||
|
||||
pv = &list_item(pvh, struct pv_list)->pv;
|
||||
pv->vg_name = pool_strdup(fid->cmd->mem, vg_to->name);
|
||||
}
|
||||
vg_to->pv_count += vg_from->pv_count;
|
||||
|
||||
while (!list_empty(&vg_from->lvs)) {
|
||||
list_del(&vg_from->lvs);
|
||||
list_add(&vg_to->lvs, &vg_from->lvs);
|
||||
struct list *lvh = vg_from->lvs.n;
|
||||
|
||||
list_del(lvh);
|
||||
list_add(&vg_to->lvs, lvh);
|
||||
}
|
||||
vg_to->lv_count += vg_from->lv_count;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user