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:
parent
30f7ee62e8
commit
e68b5e3029
@ -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,33 +104,30 @@ 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,
|
/* FIXME pv->pv_number, Derive or remove? */
|
||||||
pv->size,
|
pv->status, /* FIXME Support old or new format here? */
|
||||||
/* FIXME pv->pv_number, Derive or remove? */
|
pv->status & ALLOCATED_PV, /* FIXME Remove? */
|
||||||
pv->status, /* FIXME Support old or new format here? */
|
/* FIXME pv->lv_cur, Remove? */
|
||||||
pv->status & ALLOCATED_PV, /* FIXME Remove? */
|
pv->pe_size / 2,
|
||||||
/* FIXME pv->lv_cur, Remove? */
|
pv->pe_count,
|
||||||
pv->pe_size / 2,
|
pv->pe_count - pv->pe_allocated,
|
||||||
pv->pe_count,
|
pv->pe_allocated, *uuid ? uuid : "none");
|
||||||
pv->pe_count - pv->pe_allocated,
|
|
||||||
pv->pe_allocated,
|
|
||||||
*uuid ? uuid : "none");
|
|
||||||
|
|
||||||
dbg_free(uuid);
|
dbg_free(uuid);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pvdisplay_full(struct physical_volume * pv)
|
void pvdisplay_full(struct physical_volume *pv)
|
||||||
{
|
{
|
||||||
char *uuid;
|
char *uuid;
|
||||||
char *size, *size1; /*, *size2; */
|
char *size, *size1; /*, *size2; */
|
||||||
|
|
||||||
uint64_t pe_free;
|
uint64_t pe_free;
|
||||||
|
|
||||||
if (!pv)
|
if (!pv)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uuid = display_uuid(pv->id.uuid);
|
uuid = display_uuid(pv->id.uuid);
|
||||||
|
|
||||||
@ -140,15 +138,14 @@ void pvdisplay_full(struct physical_volume * pv)
|
|||||||
size = display_size(pv->size / 2, SIZE_SHORT);
|
size = display_size(pv->size / 2, SIZE_SHORT);
|
||||||
if (pv->pe_size && pv->pe_count) {
|
if (pv->pe_size && pv->pe_count) {
|
||||||
size1 = display_size((pv->size - pv->pe_count * pv->pe_size)
|
size1 = display_size((pv->size - pv->pe_count * pv->pe_size)
|
||||||
/ 2, SIZE_SHORT);
|
/ 2, SIZE_SHORT);
|
||||||
|
|
||||||
/******** FIXME display LVM on-disk data size
|
/******** FIXME display LVM on-disk data size
|
||||||
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);
|
||||||
/* dbg_free(size2); */
|
/* dbg_free(size2); */
|
||||||
@ -161,7 +158,7 @@ void pvdisplay_full(struct physical_volume * pv)
|
|||||||
**********/
|
**********/
|
||||||
|
|
||||||
log_print("PV Status %savailable",
|
log_print("PV Status %savailable",
|
||||||
(pv->status & ACTIVE) ? "" : "NOT ");
|
(pv->status & ACTIVE) ? "" : "NOT ");
|
||||||
|
|
||||||
pe_free = pv->pe_count - pv->pe_allocated;
|
pe_free = pv->pe_count - pv->pe_allocated;
|
||||||
if (pv->pe_count && (pv->status & ALLOCATED_PV))
|
if (pv->pe_count && (pv->status & ALLOCATED_PV))
|
||||||
@ -198,10 +195,10 @@ void pv_display_short(struct physical_volume *pv)
|
|||||||
log_print("PV Name %s ", dev_name(pv->dev));
|
log_print("PV Name %s ", dev_name(pv->dev));
|
||||||
/* FIXME pv->pv_number); */
|
/* FIXME pv->pv_number); */
|
||||||
log_print("PV Status %savailable / %sallocatable",
|
log_print("PV Status %savailable / %sallocatable",
|
||||||
(pv->status & ACTIVE) ? "" : "NOT ",
|
(pv->status & ACTIVE) ? "" : "NOT ",
|
||||||
(pv->status & ALLOCATED_PV) ? "" : "NOT ");
|
(pv->status & ALLOCATED_PV) ? "" : "NOT ");
|
||||||
log_print("Total PE / Free PE %u / %u",
|
log_print("Total PE / Free PE %u / %u",
|
||||||
pv->pe_count, pv->pe_count - pv->pe_allocated);
|
pv->pe_count, pv->pe_count - pv->pe_allocated);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -211,24 +208,17 @@ void lvdisplay_colons(struct logical_volume *lv)
|
|||||||
log_print("%s/%s:%s:%d:%d:-1:%d:%llu:%d:-1:%d:%d:-1:-1",
|
log_print("%s/%s:%s:%d:%d:-1:%d:%llu:%d:-1:%d:%d:-1:-1",
|
||||||
/* FIXME Prefix - attach to struct volume_group? */
|
/* FIXME Prefix - attach to struct volume_group? */
|
||||||
lv->vg->name,
|
lv->vg->name,
|
||||||
lv->name,
|
lv->name,
|
||||||
lv->vg->name,
|
lv->vg->name,
|
||||||
(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,
|
/* FIXME device num MAJOR(lv->lv_dev), MINOR(lv->lv_dev) */
|
||||||
lv->read_ahead
|
);
|
||||||
/* FIXME device num MAJOR(lv->lv_dev), MINOR(lv->lv_dev) */
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lvdisplay_extents(struct logical_volume *lv)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,14 +227,14 @@ void lvdisplay_full(struct logical_volume *lv)
|
|||||||
char *size;
|
char *size;
|
||||||
uint32_t alloc;
|
uint32_t alloc;
|
||||||
|
|
||||||
log_print("--- Logical volume ---");
|
log_print("--- Logical volume ---");
|
||||||
|
|
||||||
/* FIXME prefix */
|
/* FIXME prefix */
|
||||||
log_print("LV Name %s/%s", lv->vg->name, lv->name);
|
log_print("LV Name %s/%s", lv->vg->name, lv->name);
|
||||||
log_print("VG Name %s", lv->vg->name);
|
log_print("VG Name %s", lv->vg->name);
|
||||||
|
|
||||||
log_print("LV Write Access %s",
|
log_print("LV Write Access %s",
|
||||||
(lv->status & LVM_WRITE) ? "read/write" : "read only");
|
(lv->status & LVM_WRITE) ? "read/write" : "read only");
|
||||||
|
|
||||||
/******* FIXME Snapshot
|
/******* FIXME Snapshot
|
||||||
if (lv->status & (LVM_SNAPSHOT_ORG | LVM_SNAPSHOT)) {
|
if (lv->status & (LVM_SNAPSHOT_ORG | LVM_SNAPSHOT)) {
|
||||||
@ -291,8 +281,8 @@ void lvdisplay_full(struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
***********/
|
***********/
|
||||||
|
|
||||||
log_print("LV Status %savailable",
|
log_print("LV Status %savailable",
|
||||||
(lv->status & ACTIVE) ? "" : "NOT ");
|
(lv->status & ACTIVE) ? "" : "NOT ");
|
||||||
|
|
||||||
/********* FIXME lv_number
|
/********* FIXME lv_number
|
||||||
log_print("LV # %u", lv->lv_number + 1);
|
log_print("LV # %u", lv->lv_number + 1);
|
||||||
@ -313,12 +303,11 @@ 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);
|
||||||
|
|
||||||
log_print("Current LE %u", lv->le_count);
|
log_print("Current LE %u", lv->le_count);
|
||||||
|
|
||||||
/********** FIXME allocation
|
/********** FIXME allocation
|
||||||
log_print("Allocated LE %u", lv->allocated_le);
|
log_print("Allocated LE %u", lv->allocated_le);
|
||||||
@ -356,13 +345,12 @@ void lvdisplay_full(struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
******************/
|
******************/
|
||||||
|
|
||||||
if (lv->stripes > 1) {
|
if (lv->stripes > 1) {
|
||||||
log_print("Stripes %u", lv->stripes);
|
log_print("Stripes %u", lv->stripes);
|
||||||
/*********** FIXME stripesize
|
/*********** FIXME stripesize
|
||||||
log_print("Stripe size (KByte) %u", lv->stripesize / 2);
|
log_print("Stripe size (KByte) %u", lv->stripesize / 2);
|
||||||
***********/
|
***********/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
#ifdef LVM_FUTURE
|
#ifdef LVM_FUTURE
|
||||||
@ -374,15 +362,17 @@ 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);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
#ifdef LVM_FUTURE
|
#ifdef LVM_FUTURE
|
||||||
@ -399,6 +389,46 @@ void lvdisplay_full(struct logical_volume *lv)
|
|||||||
MAJOR(lv->lv_dev), MINOR(lv->lv_dev));
|
MAJOR(lv->lv_dev), MINOR(lv->lv_dev));
|
||||||
*************/
|
*************/
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
|
|
||||||
/* FIXME: This should be an enum rather than a bitset,
|
/* FIXME: This should be an enum rather than a bitset,
|
||||||
remove from status - EJT */
|
remove from status - EJT */
|
||||||
#define ALLOC_SIMPLE 0x00001000 /* LV */
|
#define ALLOC_SIMPLE 0x00001000 /* LV */
|
||||||
#define ALLOC_STRICT 0x00002000 /* LV */
|
#define ALLOC_STRICT 0x00002000 /* LV */
|
||||||
#define ALLOC_CONTIGUOUS 0x00004000 /* LV */
|
#define ALLOC_CONTIGUOUS 0x00004000 /* LV */
|
||||||
|
|
||||||
#define SNAPSHOT 0x00010000 /* LV */
|
#define SNAPSHOT 0x00010000 /* LV */
|
||||||
#define SNAPSHOT_ORG 0x00020000 /* LV */
|
#define SNAPSHOT_ORG 0x00020000 /* LV */
|
||||||
|
@ -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);
|
||||||
@ -167,8 +167,7 @@ struct list *create_pv_maps(struct pool *mem, struct volume_group *vg,
|
|||||||
|
|
||||||
return maps;
|
return maps;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
pool_free(mem, maps);
|
pool_free(mem, maps);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ int lvcreate(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc) {
|
if (argc) {
|
||||||
/* Build up list of PVs */
|
/* Build up list of PVs */
|
||||||
if (!(pvh = pool_alloc(fid->cmd->mem, sizeof (struct list)))) {
|
if (!(pvh = pool_alloc(fid->cmd->mem, sizeof(struct list)))) {
|
||||||
log_error("pvh list allocation failed");
|
log_error("pvh list allocation failed");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
@ -147,8 +147,8 @@ int lvcreate(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (list_item(pvl, struct pv_list)->pv.pe_count ==
|
if (list_item(pvl, struct pv_list)->pv.pe_count ==
|
||||||
list_item(pvl, struct pv_list)->pv.pe_allocated) {
|
list_item(pvl, struct pv_list)->pv.pe_allocated) {
|
||||||
log_error("No free extents on physical volume"
|
log_error("No free extents on physical volume"
|
||||||
" %s", argv[opt]);
|
" %s", argv[opt]);
|
||||||
continue;
|
continue;
|
||||||
/* FIXME But check not null at end! */
|
/* FIXME But check not null at end! */
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ int lvcreate(int argc, char **argv)
|
|||||||
|
|
||||||
extents += vg->extent_size - extents % vg->extent_size;
|
extents += vg->extent_size - extents % vg->extent_size;
|
||||||
log_print("Rounding up size to full physical extent %s",
|
log_print("Rounding up size to full physical extent %s",
|
||||||
(s1 = display_size(extents / 2, SIZE_SHORT)));
|
(s1 = display_size(extents / 2, SIZE_SHORT)));
|
||||||
dbg_free(s1);
|
dbg_free(s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,13 +248,13 @@ int lvcreate(int argc, char **argv)
|
|||||||
/* FIXME 2 blocks */
|
/* FIXME 2 blocks */
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
memset(buf, 0, sizeof (buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
log_verbose("Zeroing start of logical volume %s", lv_name);
|
log_verbose("Zeroing start of logical volume %s", lv_name);
|
||||||
|
|
||||||
/* FIXME get dev = dev_cache_get(lv_name, fid->cmd->filter); */
|
/* FIXME get dev = dev_cache_get(lv_name, fid->cmd->filter); */
|
||||||
/* FIXME Add fsync! */
|
/* FIXME Add fsync! */
|
||||||
if (!(dev_write(dev, 0, sizeof (buf), &buf) == sizeof (buf))) {
|
if (!(dev_write(dev, 0, sizeof(buf), &buf) == sizeof(buf))) {
|
||||||
log_error("Initialisation of %s failed", dev_name(dev));
|
log_error("Initialisation of %s failed", dev_name(dev));
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user