o vgmerge working.
#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))
}
******************/
- 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
"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;
log_verbose("%-25s %d", dev_name(pv->dev), count);
}
+**********/
/********* FIXME "reads writes"
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(" ");
{
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);
if (lv_num == UNMAPPED_EXTENT)
continue;
-
- } else {
+ else {
lv_num--;
lvm = lvms[lv_num];
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)) {
vg->lv_count++;
list_add(&vg->lvs, &ll->list);
- lv->vg = vg;
return lv;
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;
#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))
#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
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,
/* 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) ||
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;
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))
/* 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;