1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

o lvdisplay now shows LE / PV map

o fix LE allocation when first PV is full
o reduce VG free_count when removing PVs from VG
This commit is contained in:
Alasdair Kergon 2001-11-13 17:53:06 +00:00
parent 30f7ee62e8
commit e68b5e3029
5 changed files with 113 additions and 82 deletions

View File

@ -65,7 +65,8 @@ char *display_size(unsigned long long size, size_len_t sl)
* creates a new uuid string with -'s in it. It would be better if * creates a new uuid string with -'s in it. It would be better if
* the destination was passed in as well. EJT * the destination was passed in as well. EJT
*/ */
char *display_uuid(char *uuidstr) { char *display_uuid(char *uuidstr)
{
int i, j; int i, j;
char *uuid; char *uuid;
@ -103,9 +104,7 @@ void pvdisplay_colons(struct physical_volume *pv)
uuid = display_uuid(pv->id.uuid); uuid = display_uuid(pv->id.uuid);
log_print("%s:%s:%llu:-1:%u:%u:-1:%llu:%u:%u:%u:%s", log_print("%s:%s:%llu:-1:%u:%u:-1:%llu:%u:%u:%u:%s",
dev_name(pv->dev), dev_name(pv->dev), pv->vg_name, pv->size,
pv->vg_name,
pv->size,
/* FIXME pv->pv_number, Derive or remove? */ /* FIXME pv->pv_number, Derive or remove? */
pv->status, /* FIXME Support old or new format here? */ pv->status, /* FIXME Support old or new format here? */
pv->status & ALLOCATED_PV, /* FIXME Remove? */ pv->status & ALLOCATED_PV, /* FIXME Remove? */
@ -113,8 +112,7 @@ void pvdisplay_colons(struct physical_volume *pv)
pv->pe_size / 2, pv->pe_size / 2,
pv->pe_count, pv->pe_count,
pv->pe_count - pv->pe_allocated, pv->pe_count - pv->pe_allocated,
pv->pe_allocated, pv->pe_allocated, *uuid ? uuid : "none");
*uuid ? uuid : "none");
dbg_free(uuid); dbg_free(uuid);
@ -146,8 +144,7 @@ void pvdisplay_full(struct physical_volume * pv)
size2 = display_size(pv->size / 2, SIZE_SHORT); size2 = display_size(pv->size / 2, SIZE_SHORT);
********/ ********/
log_print("PV Size %s" log_print("PV Size %s" " / not usable %s", /* [LVM: %s]", */
" / not usable %s", /* [LVM: %s]", */
size, size1); /* , size2); */ size, size1); /* , size2); */
dbg_free(size1); dbg_free(size1);
@ -216,22 +213,15 @@ void lvdisplay_colons(struct logical_volume *lv)
(lv->status & (LVM_READ | LVM_WRITE)) >> 8, (lv->status & (LVM_READ | LVM_WRITE)) >> 8,
lv->status & ACTIVE, lv->status & ACTIVE,
/* FIXME lv->lv_number, */ /* FIXME lv->lv_number, */
lvs_in_vg_opened(lv->vg), lvs_in_vg_opened(lv->vg), lv->size, lv->le_count,
lv->size, /* FIXME Add num allocated to struct! lv->lv_allocated_le, */
lv->le_count, ((lv->status & ALLOC_STRICT) +
/* FIXME num allocated? */ (lv->status & ALLOC_CONTIGUOUS) * 2), lv->read_ahead
(lv->status & (ALLOC_STRICT | ALLOC_CONTIGUOUS)) >> 12,
lv->read_ahead
/* FIXME device num MAJOR(lv->lv_dev), MINOR(lv->lv_dev) */ /* FIXME device num MAJOR(lv->lv_dev), MINOR(lv->lv_dev) */
); );
return; return;
} }
void lvdisplay_extents(struct logical_volume *lv)
{
return;
}
void lvdisplay_full(struct logical_volume *lv) void lvdisplay_full(struct logical_volume *lv)
{ {
char *size; char *size;
@ -313,7 +303,6 @@ void lvdisplay_full(struct logical_volume *lv)
#endif #endif
********/ ********/
size = display_size(lv->size / 2, SIZE_SHORT); size = display_size(lv->size / 2, SIZE_SHORT);
log_print("LV Size %s", size); log_print("LV Size %s", size);
dbg_free(size); dbg_free(size);
@ -363,7 +352,6 @@ void lvdisplay_full(struct logical_volume *lv)
***********/ ***********/
} }
/************** /**************
#ifdef LVM_FUTURE #ifdef LVM_FUTURE
printf("Bad block "); printf("Bad block ");
@ -374,13 +362,15 @@ void lvdisplay_full(struct logical_volume *lv)
#endif #endif
***************/ ***************/
/* FIXME next free == ALLOC_SIMPLE */
alloc = lv->status & (ALLOC_STRICT | ALLOC_CONTIGUOUS); alloc = lv->status & (ALLOC_STRICT | ALLOC_CONTIGUOUS);
log_print("Allocation %s%s%s%s", log_print("Allocation %s%s%s%s",
!(alloc & (ALLOC_STRICT | ALLOC_CONTIGUOUS)) ? "next free" : "", !(alloc & (ALLOC_STRICT | ALLOC_CONTIGUOUS)) ? "next free" :
(alloc == ALLOC_STRICT) ? "strict" : "", "", (alloc == ALLOC_STRICT) ? "strict" : "",
(alloc == ALLOC_CONTIGUOUS) ? "contiguous" : "", (alloc == ALLOC_CONTIGUOUS) ? "contiguous" : "",
(alloc == (ALLOC_STRICT | ALLOC_CONTIGUOUS)) ? "strict/contiguous" : "" (alloc ==
); (ALLOC_STRICT | ALLOC_CONTIGUOUS)) ? "strict/contiguous" :
"");
log_print("Read ahead sectors %u\n", lv->read_ahead); log_print("Read ahead sectors %u\n", lv->read_ahead);
@ -402,3 +392,43 @@ void lvdisplay_full(struct logical_volume *lv)
return; return;
} }
void lvdisplay_extents(struct logical_volume *lv)
{
int le;
struct list *pvh;
struct physical_volume *pv;
log_verbose("--- Distribution of logical volume on physical "
"volumes ---");
log_verbose("PV Name PE on PV ");
list_iterate(pvh, &lv->vg->pvs) {
int count = 0;
pv = &list_item(pvh, struct pv_list)->pv;
for (le = 0; le < lv->le_count; le++)
if (lv->map[le].pv->dev == pv->dev)
count++;
if (count)
log_verbose("%-25s %d", dev_name(pv->dev), count);
}
/********* FIXME "reads writes"
printf("\n --- logical volume i/o statistic ---\n"
" %d reads %d writes\n", sum_reads, sum_writes);
******* */
log_verbose(" ");
log_verbose("--- Logical extents ---");
log_verbose("LE PV PE");
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);
}
return;
}

View File

@ -7,7 +7,6 @@
#include "pv_map.h" #include "pv_map.h"
#include "log.h" #include "log.h"
static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps) static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
{ {
struct list *tmp; struct list *tmp;
@ -29,6 +28,8 @@ static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
return 0; return 0;
} }
list_init(&pvm->areas);
list_add(maps, &pvm->list); list_add(maps, &pvm->list);
} }
@ -97,7 +98,6 @@ static int _create_single_area(struct pool *mem, struct pv_map *pvm,
return 0; return 0;
} }
list_init(&pvm->areas);
pva->start = b; pva->start = b;
pva->count = e - b; pva->count = e - b;
list_add(&pvm->areas, &pva->list); list_add(&pvm->areas, &pva->list);
@ -171,4 +171,3 @@ struct list *create_pv_maps(struct pool *mem, struct volume_group *vg,
pool_free(mem, maps); pool_free(mem, maps);
return NULL; return NULL;
} }

View File

@ -113,6 +113,8 @@ static int vgreduce_single(struct volume_group *vg, struct physical_volume *pv)
list_del(pvh); list_del(pvh);
*pv->vg_name = '\0'; *pv->vg_name = '\0';
vg->pv_count--; vg->pv_count--;
vg->free_count -= pv->pe_count - pv->pe_allocated;
vg->extent_count -= pv->pe_count;
if (!(fid->ops->vg_write(fid, vg))) { if (!(fid->ops->vg_write(fid, vg))) {
log_error("Removal of physical volume %s from %s failed", log_error("Removal of physical volume %s from %s failed",