mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
pvdisplay
This commit is contained in:
parent
e7af89f900
commit
cd77c5a7b7
@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "display.h"
|
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "dbg_malloc.h"
|
#include "dbg_malloc.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
#define SIZE_BUF 128
|
#define SIZE_BUF 128
|
||||||
|
|
||||||
@ -92,3 +92,254 @@ char *display_uuid(char *uuidstr) {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pvdisplay_colons(struct physical_volume *pv)
|
||||||
|
{
|
||||||
|
char *uuid;
|
||||||
|
|
||||||
|
if (!pv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uuid = display_uuid(pv->id.uuid);
|
||||||
|
|
||||||
|
log_print("%s:%s:%llu:-1:%u:%u:-1:%llu:%u:%u:%u:%s",
|
||||||
|
pv->dev->name,
|
||||||
|
pv->vg_name,
|
||||||
|
pv->size,
|
||||||
|
/* FIXME pv->pv_number, Derive or remove? */
|
||||||
|
pv->status, /* FIXME Support old or new format here? */
|
||||||
|
pv->status & ALLOCATED_PV, /* FIXME Remove? */
|
||||||
|
/* FIXME pv->lv_cur, Remove? */
|
||||||
|
pv->pe_size / 2,
|
||||||
|
pv->pe_count,
|
||||||
|
pv->pe_count - pv->pe_allocated,
|
||||||
|
pv->pe_allocated,
|
||||||
|
*uuid ? uuid : "none");
|
||||||
|
|
||||||
|
dbg_free(uuid);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pvdisplay_full(struct physical_volume * pv)
|
||||||
|
{
|
||||||
|
char *uuid;
|
||||||
|
char *size, *size1; /*, *size2; */
|
||||||
|
|
||||||
|
uint64_t pe_free;
|
||||||
|
|
||||||
|
if (!pv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uuid = display_uuid(pv->id.uuid);
|
||||||
|
|
||||||
|
log_print("--- %sPhysical volume ---", pv->pe_size ? "" : "NEW ");
|
||||||
|
log_print("PV Name %s", pv->dev->name);
|
||||||
|
log_print("VG Name %s", pv->vg_name);
|
||||||
|
|
||||||
|
size = display_size(pv->size / 2, SIZE_SHORT);
|
||||||
|
if (pv->pe_size && pv->pe_count) {
|
||||||
|
size1 = display_size((pv->size - pv->pe_count * pv->pe_size)
|
||||||
|
/ 2, SIZE_SHORT);
|
||||||
|
|
||||||
|
/******** FIXME display LVM on-disk data size
|
||||||
|
size2 = display_size(pv->size / 2, SIZE_SHORT);
|
||||||
|
********/
|
||||||
|
|
||||||
|
log_print("PV Size %s"
|
||||||
|
" / not usable %s", /* [LVM: %s]", */
|
||||||
|
size, size1); /* , size2); */
|
||||||
|
|
||||||
|
dbg_free(size1);
|
||||||
|
/* dbg_free(size2); */
|
||||||
|
} else
|
||||||
|
log_print("PV Size %s", size);
|
||||||
|
dbg_free(size);
|
||||||
|
|
||||||
|
/*********FIXME Anything use this?
|
||||||
|
log_print("PV# %u", pv->pv_number);
|
||||||
|
**********/
|
||||||
|
|
||||||
|
log_print("PV Status %savailable",
|
||||||
|
(pv->status & ACTIVE) ? "" : "NOT ");
|
||||||
|
|
||||||
|
pe_free = pv->pe_count - pv->pe_allocated;
|
||||||
|
if (pv->pe_count && (pv->status & ALLOCATED_PV))
|
||||||
|
log_print("Allocatable yes %s",
|
||||||
|
(!pe_free && pv->pe_count) ? "(but full)" : "");
|
||||||
|
else
|
||||||
|
log_print("Allocatable NO");
|
||||||
|
|
||||||
|
/*********FIXME
|
||||||
|
log_print("Cur LV %u", pv->lv_cur);
|
||||||
|
*********/
|
||||||
|
log_print("PE Size (KByte) %llu", pv->pe_size / 2);
|
||||||
|
log_print("Total PE %u", pv->pe_count);
|
||||||
|
log_print("Free PE %llu", pe_free);
|
||||||
|
log_print("Allocated PE %u", pv->pe_allocated);
|
||||||
|
|
||||||
|
#ifdef LVM_FUTURE
|
||||||
|
printf("Stale PE %u", pv->pe_stale);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
log_print("PV UUID %s", *uuid ? uuid : "none");
|
||||||
|
log_print(" ");
|
||||||
|
|
||||||
|
dbg_free(uuid);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pv_display_short(struct physical_volume *pv)
|
||||||
|
{
|
||||||
|
if (!pv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
log_print("PV Name %s ", pv->dev->name);
|
||||||
|
/* FIXME pv->pv_number); */
|
||||||
|
log_print("PV Status %savailable / %sallocatable",
|
||||||
|
(pv->status & ACTIVE) ? "" : "NOT ",
|
||||||
|
(pv->status & ALLOCATED_PV) ? "" : "NOT ");
|
||||||
|
log_print("Total PE / Free PE %u / %u",
|
||||||
|
pv->pe_count, pv->pe_count - pv->pe_allocated);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/******** FIXME
|
||||||
|
void pv_display_pe(pv_t * pv, pe_disk_t * pe)
|
||||||
|
{
|
||||||
|
int p;
|
||||||
|
|
||||||
|
for (p = 0; p < pv->pe_total; p++)
|
||||||
|
printf("pe#: %4d vg: %s lv: %d le: %d\n",
|
||||||
|
p, pv->vg_name, pe[p].lv_num, pe[p].le_num);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*******/
|
||||||
|
|
||||||
|
void pv_display_pe_text(pv_t * pv, pe_disk_t * pe, lv_disk_t * lvs)
|
||||||
|
{
|
||||||
|
int flag = 0;
|
||||||
|
int lv_num_last = 0;
|
||||||
|
int p = 0;
|
||||||
|
int pe_free = 0;
|
||||||
|
int *pe_this_count = NULL;
|
||||||
|
int pt = 0;
|
||||||
|
int pt_count = 0;
|
||||||
|
lv_disk_t *lv;
|
||||||
|
char *lv_name_this = NULL;
|
||||||
|
char *lv_names = NULL;
|
||||||
|
char *lv_names_sav = NULL;
|
||||||
|
pe_disk_t *pe_this = NULL;
|
||||||
|
|
||||||
|
if ((pe_this = dbg_malloc(pv->pe_total * sizeof (pe_disk_t))) == NULL) {
|
||||||
|
log_error("pe_this allocation failed");
|
||||||
|
goto pv_display_pe_text_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pe_this_count = dbg_malloc(pv->pe_total * sizeof (int))) == NULL) {
|
||||||
|
log_error("pe_this_count allocation failed");
|
||||||
|
goto pv_display_pe_text_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(pe_this, 0, pv->pe_total * sizeof (pe_disk_t));
|
||||||
|
memset(pe_this_count, 0, pv->pe_total * sizeof (int));
|
||||||
|
|
||||||
|
/* get PE and LE summaries */
|
||||||
|
pt_count = 0;
|
||||||
|
for (p = pt_count; p < pv->pe_total; p++) {
|
||||||
|
if (pe[p].lv_num != 0) {
|
||||||
|
flag = 0;
|
||||||
|
for (pt = 0; pt < pt_count; pt++) {
|
||||||
|
if (pe_this[pt].lv_num == pe[p].lv_num) {
|
||||||
|
flag = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag == 0) {
|
||||||
|
pe_this[pt_count].lv_num = pe[p].lv_num;
|
||||||
|
for (pt = 0; pt < pv->pe_total; pt++)
|
||||||
|
if (pe_this[pt_count].lv_num ==
|
||||||
|
pe[pt].lv_num)
|
||||||
|
pe_this_count[pt_count]++;
|
||||||
|
pt_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lv = lvs;
|
||||||
|
printf(" --- Distribution of physical volume ---\n"
|
||||||
|
" LV Name LE of LV PE for LV\n");
|
||||||
|
for (pt = 0; pt < pt_count; pt++) {
|
||||||
|
printf(" %-25s ", lv->lv_name);
|
||||||
|
if (strlen(lv->lv_name) > 25)
|
||||||
|
printf("\n ");
|
||||||
|
printf("%-8u %-8d\n",
|
||||||
|
lv->lv_allocated_le,
|
||||||
|
pe_this_count[pt]);
|
||||||
|
if (pe_this[pt].lv_num > lv_num_last) {
|
||||||
|
lv_num_last = pe_this[pt].lv_num;
|
||||||
|
lv_names_sav = lv_names;
|
||||||
|
if ((lv_names = dbg_realloc(lv_names,
|
||||||
|
lv_num_last * NAME_LEN)) ==
|
||||||
|
NULL) {
|
||||||
|
log_error("realloc error in %s [line %d]",
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
goto pv_display_pe_text_out;
|
||||||
|
} else
|
||||||
|
lv_names_sav = NULL;
|
||||||
|
}
|
||||||
|
strcpy(&lv_names[(pe_this[pt].lv_num - 1) * NAME_LEN],
|
||||||
|
lv->lv_name);
|
||||||
|
lv++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n --- Physical extents ---\n"
|
||||||
|
" PE LV LE Disk sector\n");
|
||||||
|
pe_free = -1;
|
||||||
|
for (p = 0; p < pv->pe_total; p++) {
|
||||||
|
if (pe[p].lv_num != 0) {
|
||||||
|
if (pe_free > -1) {
|
||||||
|
pv_display_pe_free(pe_free, p);
|
||||||
|
pe_free = -1;
|
||||||
|
}
|
||||||
|
lv_name_this = &lv_names[(pe[p].lv_num - 1) * NAME_LEN];
|
||||||
|
printf(" %05d %-25s ", p, lv_name_this);
|
||||||
|
if (strlen(lv_name_this) > 25)
|
||||||
|
printf("\n ");
|
||||||
|
printf("%05d %ld\n", pe[p].le_num,
|
||||||
|
get_pe_offset(p, pv));
|
||||||
|
|
||||||
|
} else if (pe_free == -1)
|
||||||
|
pe_free = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pe_free > 0)
|
||||||
|
pv_display_pe_free(pe_free, p);
|
||||||
|
|
||||||
|
pv_display_pe_text_out:
|
||||||
|
if (lv_names != NULL)
|
||||||
|
dbg_free(lv_names);
|
||||||
|
else if (lv_names_sav != NULL)
|
||||||
|
dbg_free(lv_names_sav);
|
||||||
|
if (pe_this != NULL)
|
||||||
|
dbg_free(pe_this);
|
||||||
|
if (pe_this_count != NULL)
|
||||||
|
dbg_free(pe_this_count);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pv_display_pe_free(int pe_free, int p)
|
||||||
|
{
|
||||||
|
printf(" %05d free\n", pe_free);
|
||||||
|
|
||||||
|
if (p - pe_free > 1)
|
||||||
|
printf(" .....\n %05d free\n", p - 1);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -21,11 +21,26 @@
|
|||||||
#ifndef _LVM_DISPLAY_H
|
#ifndef _LVM_DISPLAY_H
|
||||||
#define _LVM_DISPLAY_H
|
#define _LVM_DISPLAY_H
|
||||||
|
|
||||||
|
#include "metadata.h"
|
||||||
|
|
||||||
typedef enum {SIZE_LONG=0, SIZE_SHORT=1} size_len_t;
|
typedef enum {SIZE_LONG=0, SIZE_SHORT=1} size_len_t;
|
||||||
|
|
||||||
/* Specify size in KB */
|
/* Specify size in KB */
|
||||||
char *display_size(unsigned long long size, size_len_t sl);
|
char *display_size(unsigned long long size, size_len_t sl);
|
||||||
|
|
||||||
char *display_uuid(char *uuidstr);
|
char *display_uuid(char *uuidstr);
|
||||||
|
|
||||||
|
void pvdisplay_colons(struct physical_volume *pv);
|
||||||
|
void pvdisplay_full(struct physical_volume *pv);
|
||||||
|
#if 0
|
||||||
|
void pv_show_short(pv_t * pv);
|
||||||
|
void pv_display_pe(pv_t * pv, pe_disk_t * pe);
|
||||||
|
void pv_display_pe_free(int pe_free, int p);
|
||||||
|
void pv_display_pe_text(pv_t * pv, pe_disk_t * pe, lv_disk_t * lvs);
|
||||||
|
|
||||||
|
static inline unsigned long get_pe_offset(ulong p, pv_t *pv)
|
||||||
|
{
|
||||||
|
return pv->pe_start + (p * pv->pe_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,278 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2001 Sistina Software
|
|
||||||
*
|
|
||||||
* This LVM library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This LVM library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this LVM library; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
||||||
* MA 02111-1307, USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "display.h"
|
|
||||||
#include "metadata.h"
|
|
||||||
#include "dbg_malloc.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
void pv_display_colons(pv_t * pv)
|
|
||||||
{
|
|
||||||
char *uuid;
|
|
||||||
|
|
||||||
if (!pv)
|
|
||||||
return;
|
|
||||||
|
|
||||||
uuid = display_uuid(pv->pv_uuid);
|
|
||||||
|
|
||||||
printf("%s:%s:%d:%d:%d:%d:%d:%d:%d:%d:%d:%s\n",
|
|
||||||
pv->pv_name,
|
|
||||||
pv->vg_name,
|
|
||||||
pv->pv_size,
|
|
||||||
pv->pv_number,
|
|
||||||
pv->pv_status,
|
|
||||||
pv->pv_allocatable,
|
|
||||||
pv->lv_cur,
|
|
||||||
pv->pe_size / 2,
|
|
||||||
pv->pe_total,
|
|
||||||
pv->pe_total - pv->pe_allocated,
|
|
||||||
pv->pe_allocated, uuid ? uuid : "none");
|
|
||||||
|
|
||||||
dbg_free(uuid);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pv_display_full(pv_t * pv)
|
|
||||||
{
|
|
||||||
ulong pe_free;
|
|
||||||
char *size = NULL;
|
|
||||||
char *uuid;
|
|
||||||
|
|
||||||
if (!pv)
|
|
||||||
return;
|
|
||||||
|
|
||||||
uuid = display_uuid(pv->pv_uuid);
|
|
||||||
|
|
||||||
printf("--- %sPhysical volume ---\n", pv->pe_size ? "" : "NEW ");
|
|
||||||
printf("PV Name %s\n", pv->pv_name);
|
|
||||||
printf("VG Name %s\n", pv->vg_name);
|
|
||||||
|
|
||||||
size = display_size(pv->pv_size / 2, SIZE_SHORT);
|
|
||||||
printf("PV Size %s", size);
|
|
||||||
dbg_free(size);
|
|
||||||
|
|
||||||
if (pv->pe_size && pv->pe_total) {
|
|
||||||
size =
|
|
||||||
display_size((pv->pv_size - pv->pe_size * pv->pe_total) / 2,
|
|
||||||
SIZE_SHORT);
|
|
||||||
printf(" / NOT usable %s ", size);
|
|
||||||
dbg_free(size);
|
|
||||||
|
|
||||||
size =
|
|
||||||
display_size(
|
|
||||||
(pv->pe_on_disk.base +
|
|
||||||
pv->pe_total * sizeof (pe_disk_t)) / 1024,
|
|
||||||
SIZE_SHORT);
|
|
||||||
printf("[LVM: %s]", size);
|
|
||||||
dbg_free(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("PV# %u\n", pv->pv_number);
|
|
||||||
printf("PV Status %savailable\n",
|
|
||||||
(pv->pv_status & PV_ACTIVE) ? "" : "NOT ");
|
|
||||||
|
|
||||||
printf("Allocatable ");
|
|
||||||
pe_free = pv->pe_total - pv->pe_allocated;
|
|
||||||
if (pv->pe_total > 0 && (pv->pv_allocatable & PV_ALLOCATABLE)) {
|
|
||||||
printf("yes");
|
|
||||||
if (pe_free == 0 && pv->pe_total > 0)
|
|
||||||
printf(" (but full)");
|
|
||||||
printf("\n");
|
|
||||||
} else
|
|
||||||
printf("NO\n");
|
|
||||||
|
|
||||||
printf("Cur LV %u\n", pv->lv_cur);
|
|
||||||
printf("PE Size (KByte) %u\n", pv->pe_size / 2);
|
|
||||||
printf("Total PE %u\n", pv->pe_total);
|
|
||||||
printf("Free PE %lu\n", pe_free);
|
|
||||||
printf("Allocated PE %u\n", pv->pe_allocated);
|
|
||||||
|
|
||||||
#ifdef LVM_FUTURE
|
|
||||||
printf("Stale PE %u\n", pv->pe_stale);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printf("PV UUID %s\n", uuid ? uuid : "none");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
dbg_free(uuid);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******
|
|
||||||
void pv_display_short(pv_t * pv)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (pv != NULL) {
|
|
||||||
printf("PV Name (#) %s (%u)\n", pv->pv_name,
|
|
||||||
pv->pv_number);
|
|
||||||
printf("PV Status ");
|
|
||||||
if (!(pv->pv_status & PV_ACTIVE))
|
|
||||||
printf("NOT ");
|
|
||||||
printf("available / ");
|
|
||||||
if (!(pv->pv_allocatable & PV_ALLOCATABLE))
|
|
||||||
printf("NOT ");
|
|
||||||
printf("allocatable\n");
|
|
||||||
printf("Total PE / Free PE %u / %u\n",
|
|
||||||
pv->pe_total, pv->pe_total - pv->pe_allocated);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pv_display_pe(pv_t * pv, pe_disk_t * pe)
|
|
||||||
{
|
|
||||||
int p;
|
|
||||||
|
|
||||||
for (p = 0; p < pv->pe_total; p++)
|
|
||||||
printf("pe#: %4d vg: %s lv: %d le: %d\n",
|
|
||||||
p, pv->vg_name, pe[p].lv_num, pe[p].le_num);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*******/
|
|
||||||
|
|
||||||
void pv_display_pe_text(pv_t * pv, pe_disk_t * pe, lv_disk_t * lvs)
|
|
||||||
{
|
|
||||||
int flag = 0;
|
|
||||||
int lv_num_last = 0;
|
|
||||||
int p = 0;
|
|
||||||
int pe_free = 0;
|
|
||||||
int *pe_this_count = NULL;
|
|
||||||
int pt = 0;
|
|
||||||
int pt_count = 0;
|
|
||||||
lv_disk_t *lv;
|
|
||||||
char *lv_name_this = NULL;
|
|
||||||
char *lv_names = NULL;
|
|
||||||
char *lv_names_sav = NULL;
|
|
||||||
pe_disk_t *pe_this = NULL;
|
|
||||||
|
|
||||||
if ((pe_this = dbg_malloc(pv->pe_total * sizeof (pe_disk_t))) == NULL) {
|
|
||||||
log_error("pe_this allocation failed");
|
|
||||||
goto pv_display_pe_text_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pe_this_count = dbg_malloc(pv->pe_total * sizeof (int))) == NULL) {
|
|
||||||
log_error("pe_this_count allocation failed");
|
|
||||||
goto pv_display_pe_text_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(pe_this, 0, pv->pe_total * sizeof (pe_disk_t));
|
|
||||||
memset(pe_this_count, 0, pv->pe_total * sizeof (int));
|
|
||||||
|
|
||||||
/* get PE and LE summaries */
|
|
||||||
pt_count = 0;
|
|
||||||
for (p = pt_count; p < pv->pe_total; p++) {
|
|
||||||
if (pe[p].lv_num != 0) {
|
|
||||||
flag = 0;
|
|
||||||
for (pt = 0; pt < pt_count; pt++) {
|
|
||||||
if (pe_this[pt].lv_num == pe[p].lv_num) {
|
|
||||||
flag = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (flag == 0) {
|
|
||||||
pe_this[pt_count].lv_num = pe[p].lv_num;
|
|
||||||
for (pt = 0; pt < pv->pe_total; pt++)
|
|
||||||
if (pe_this[pt_count].lv_num ==
|
|
||||||
pe[pt].lv_num)
|
|
||||||
pe_this_count[pt_count]++;
|
|
||||||
pt_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lv = lvs;
|
|
||||||
printf(" --- Distribution of physical volume ---\n"
|
|
||||||
" LV Name LE of LV PE for LV\n");
|
|
||||||
for (pt = 0; pt < pt_count; pt++) {
|
|
||||||
printf(" %-25s ", lv->lv_name);
|
|
||||||
if (strlen(lv->lv_name) > 25)
|
|
||||||
printf("\n ");
|
|
||||||
printf("%-8u %-8d\n",
|
|
||||||
lv->lv_allocated_le,
|
|
||||||
pe_this_count[pt]);
|
|
||||||
if (pe_this[pt].lv_num > lv_num_last) {
|
|
||||||
lv_num_last = pe_this[pt].lv_num;
|
|
||||||
lv_names_sav = lv_names;
|
|
||||||
if ((lv_names = dbg_realloc(lv_names,
|
|
||||||
lv_num_last * NAME_LEN)) ==
|
|
||||||
NULL) {
|
|
||||||
log_error("realloc error in %s [line %d]",
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
goto pv_display_pe_text_out;
|
|
||||||
} else
|
|
||||||
lv_names_sav = NULL;
|
|
||||||
}
|
|
||||||
strcpy(&lv_names[(pe_this[pt].lv_num - 1) * NAME_LEN],
|
|
||||||
lv->lv_name);
|
|
||||||
lv++;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n --- Physical extents ---\n"
|
|
||||||
" PE LV LE Disk sector\n");
|
|
||||||
pe_free = -1;
|
|
||||||
for (p = 0; p < pv->pe_total; p++) {
|
|
||||||
if (pe[p].lv_num != 0) {
|
|
||||||
if (pe_free > -1) {
|
|
||||||
pv_display_pe_free(pe_free, p);
|
|
||||||
pe_free = -1;
|
|
||||||
}
|
|
||||||
lv_name_this = &lv_names[(pe[p].lv_num - 1) * NAME_LEN];
|
|
||||||
printf(" %05d %-25s ", p, lv_name_this);
|
|
||||||
if (strlen(lv_name_this) > 25)
|
|
||||||
printf("\n ");
|
|
||||||
printf("%05d %ld\n", pe[p].le_num,
|
|
||||||
get_pe_offset(p, pv));
|
|
||||||
|
|
||||||
} else if (pe_free == -1)
|
|
||||||
pe_free = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pe_free > 0)
|
|
||||||
pv_display_pe_free(pe_free, p);
|
|
||||||
|
|
||||||
pv_display_pe_text_out:
|
|
||||||
if (lv_names != NULL)
|
|
||||||
dbg_free(lv_names);
|
|
||||||
else if (lv_names_sav != NULL)
|
|
||||||
dbg_free(lv_names_sav);
|
|
||||||
if (pe_this != NULL)
|
|
||||||
dbg_free(pe_this);
|
|
||||||
if (pe_this_count != NULL)
|
|
||||||
dbg_free(pe_this_count);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pv_display_pe_free(int pe_free, int p)
|
|
||||||
{
|
|
||||||
printf(" %05d free\n", pe_free);
|
|
||||||
|
|
||||||
if (p - pe_free > 1)
|
|
||||||
printf(" .....\n %05d free\n", p - 1);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2001 Sistina Software
|
|
||||||
*
|
|
||||||
* This LVM library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This LVM library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this LVM library; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
||||||
* MA 02111-1307, USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_DISPLAY_METADATA_H
|
|
||||||
#define _LVM_DISPLAY_METADATA_H
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include "metadata/metadata.h"
|
|
||||||
|
|
||||||
void pv_display_colons(pv_t * pv);
|
|
||||||
void pv_display_full(pv_t * pv);
|
|
||||||
void pv_show_short(pv_t * pv);
|
|
||||||
void pv_display_pe(pv_t * pv, pe_disk_t * pe);
|
|
||||||
void pv_display_pe_free(int pe_free, int p);
|
|
||||||
void pv_display_pe_text(pv_t * pv, pe_disk_t * pe, lv_disk_t * lvs);
|
|
||||||
|
|
||||||
static inline unsigned long get_pe_offset(ulong p, pv_t *pv)
|
|
||||||
{
|
|
||||||
return pv->pe_start + (p * pv->pe_size);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
@ -359,12 +359,16 @@ static int _pv_write(struct io_space *is, struct physical_volume *pv)
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&pvs);
|
INIT_LIST_HEAD(&pvs);
|
||||||
|
|
||||||
if (*pv->vg_name) {
|
if (*pv->vg_name || pv->pe_allocated ) {
|
||||||
log_error("Assertion failed: can't _pv_write non-orphan PV "
|
log_error("Assertion failed: can't _pv_write non-orphan PV "
|
||||||
"(in VG %s)", pv->vg_name);
|
"(in VG %s)", pv->vg_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure any residual PE structure is gone */
|
||||||
|
pv->pe_size = pv->pe_count = pv->pe_start = 0;
|
||||||
|
pv->status &= ~ALLOCATED_PV;
|
||||||
|
|
||||||
if (!(mem = pool_create(1024))) {
|
if (!(mem = pool_create(1024))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -25,6 +25,7 @@ SOURCES=\
|
|||||||
lvmchange.c \
|
lvmchange.c \
|
||||||
pvchange.c \
|
pvchange.c \
|
||||||
pvcreate.c \
|
pvcreate.c \
|
||||||
|
pvdisplay.c \
|
||||||
pvscan.c \
|
pvscan.c \
|
||||||
toollib.c \
|
toollib.c \
|
||||||
vgck.c \
|
vgck.c \
|
||||||
|
@ -20,81 +20,77 @@
|
|||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
void pvdisplay_device(const char *pv_name);
|
void pvdisplay_single(struct physical_volume *pv);
|
||||||
|
|
||||||
int pvdisplay(int argc, char **argv)
|
int pvdisplay(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt;
|
int opt=0;
|
||||||
|
|
||||||
if (argc == 0) {
|
struct list_head *pvh, *pvs;
|
||||||
log_error("please enter a physical volume path");
|
struct physical_volume *pv;
|
||||||
return EINVALID_CMD_LINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg_count(colon_ARG) && arg_count(verbose_ARG)) {
|
if (arg_count(colon_ARG) && arg_count(verbose_ARG)) {
|
||||||
log_error("option v not allowed with option c");
|
log_error("Option -v not allowed with option -c");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (opt = 0; opt < argc; opt++)
|
if (argc) {
|
||||||
pvdisplay_device(argv[opt]);
|
log_very_verbose("Using physical volume(s) on command line");
|
||||||
|
|
||||||
|
for (; opt < argc; opt++) {
|
||||||
|
if (!(pv = ios->pv_read(ios, argv[opt]))) {
|
||||||
|
log_error("Failed to read physical volume %s",
|
||||||
|
argv[opt]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pvdisplay_single(pv);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log_verbose("Scanning for physical volume names");
|
||||||
|
if (!(pvs = ios->get_pvs(ios)))
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
|
list_for_each(pvh, pvs)
|
||||||
|
pvdisplay_single(&list_entry(pvh, struct pv_list, list)->pv);
|
||||||
|
}
|
||||||
|
|
||||||
putchar('\n');
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pvdisplay_device(const char *pv_name)
|
void pvdisplay_single(struct physical_volume *pv)
|
||||||
{
|
{
|
||||||
struct dev_mgr *dm;
|
char *sz;
|
||||||
struct device *pv_dev;
|
uint64_t size;
|
||||||
|
|
||||||
pv_t *pv = NULL;
|
char *pv_name = pv->dev->name;
|
||||||
lv_disk_t *lvs = NULL;
|
|
||||||
|
|
||||||
dm = active_dev_mgr();
|
if (!*pv->vg_name)
|
||||||
|
size = pv->size;
|
||||||
if (!(pv_dev = dev_by_name(dm, pv_name))) {
|
else
|
||||||
log_error("device \"%s\" not found", pv_name);
|
size = (pv->pe_count - pv->pe_allocated) * pv->pe_size;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg_count(short_ARG)) {
|
if (arg_count(short_ARG)) {
|
||||||
long size;
|
|
||||||
char *sz;
|
|
||||||
|
|
||||||
/* Returns size in 512-byte units */
|
|
||||||
if ((size = device_get_size(pv_name)) < 0) {
|
|
||||||
log_error("Failed to get size of physical volume %s",
|
|
||||||
pv_name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sz = display_size(size / 2, SIZE_SHORT);
|
sz = display_size(size / 2, SIZE_SHORT);
|
||||||
log_print("Device \"%s\" has a capacity of %s", pv_name, sz);
|
log_print("Device '%s' has a capacity of %s", pv_name, sz);
|
||||||
|
|
||||||
dbg_free(sz);
|
dbg_free(sz);
|
||||||
}
|
|
||||||
|
|
||||||
if (!(pv = pv_read(dm, pv_name))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Check attributes
|
if (pv->status & EXPORTED_VG)
|
||||||
MD_DEVICE,
|
log_print("Physical volume '%s' of volume group '%s' "
|
||||||
log_error("\"%s\" no VALID physical volume \"%s\"", lvm_error ( ret), pv_name);
|
"is exported" , pv_name, pv->vg_name);
|
||||||
|
|
||||||
EXPORTED
|
/********* FIXME
|
||||||
pv->vg_name[strlen(pv->vg_name)-strlen(EXPORTED)] = 0;
|
|
||||||
log_print("physical volume \"%s\" of volume group \"%s\" is exported" , pv_name, pv->vg_name);
|
|
||||||
|
|
||||||
Valid ID
|
|
||||||
log_error("no physical volume identifier on \"%s\"" , pv_name);
|
log_error("no physical volume identifier on \"%s\"" , pv_name);
|
||||||
|
*********/
|
||||||
|
|
||||||
NEW
|
if (!pv->vg_name) {
|
||||||
pv_check_new (pv)
|
log_print ( "'%s' is a new physical volume of %s",
|
||||||
log_print ( "\"%s\" is a new physical volume of %s",
|
pv_name, ( sz = display_size ( size / 2,
|
||||||
pv_name, ( dummy = lvm_show_size ( size / 2, SHORT)));
|
SIZE_SHORT)));
|
||||||
*/
|
dbg_free(sz);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: Check active - no point?
|
/* FIXME: Check active - no point?
|
||||||
log_very_verbose("checking physical volume activity" );
|
log_very_verbose("checking physical volume activity" );
|
||||||
@ -102,22 +98,22 @@ void pvdisplay_device(const char *pv_name)
|
|||||||
pv_status ( pv->vg_name, pv->pv_name, &pv)
|
pv_status ( pv->vg_name, pv->pv_name, &pv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* FIXME: Check consistency - or do this when reading metadata?
|
/* FIXME: Check consistency - do this when reading metadata BUT trigger mesgs
|
||||||
log_very_verbose("checking physical volume consistency" );
|
log_very_verbose("checking physical volume consistency" );
|
||||||
ret = pv_check_consistency (pv)
|
ret = pv_check_consistency (pv)
|
||||||
log_error("\"%s\" checking consistency of physical volume \"%s\"", lvm_error ( ret), pv_name);
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (arg_count(colon_ARG)) {
|
if (arg_count(colon_ARG)) {
|
||||||
pv_display_colons(pv);
|
pvdisplay_colons(pv);
|
||||||
goto pvdisplay_device_out;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pv_display_full(pv);
|
pvdisplay_full(pv);
|
||||||
|
|
||||||
if (!arg_count(verbose_ARG))
|
if (!arg_count(verbose_ARG))
|
||||||
goto pvdisplay_device_out;
|
return;
|
||||||
|
|
||||||
|
/******* FIXME
|
||||||
if (pv->pe_allocated) {
|
if (pv->pe_allocated) {
|
||||||
if (!(pv->pe = pv_read_pe(pv_name, pv)))
|
if (!(pv->pe = pv_read_pe(pv_name, pv)))
|
||||||
goto pvdisplay_device_out;
|
goto pvdisplay_device_out;
|
||||||
@ -128,12 +124,8 @@ void pvdisplay_device(const char *pv_name)
|
|||||||
pv_display_pe_text(pv, pv->pe, lvs);
|
pv_display_pe_text(pv, pv->pe, lvs);
|
||||||
} else
|
} else
|
||||||
log_print("no logical volume on physical volume %s", pv_name);
|
log_print("no logical volume on physical volume %s", pv_name);
|
||||||
|
**********/
|
||||||
pvdisplay_device_out:
|
|
||||||
if (pv)
|
|
||||||
dbg_free(pv->pe);
|
|
||||||
dbg_free(pv);
|
|
||||||
dbg_free(lvs);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ int lvreduce(int argc, char **argv) {return 1;}
|
|||||||
int lvremove(int argc, char **argv) {return 1;}
|
int lvremove(int argc, char **argv) {return 1;}
|
||||||
int lvrename(int argc, char **argv) {return 1;}
|
int lvrename(int argc, char **argv) {return 1;}
|
||||||
int lvscan(int argc, char **argv) {return 1;}
|
int lvscan(int argc, char **argv) {return 1;}
|
||||||
int pvdisplay(int argc, char **argv) {return 1;}
|
|
||||||
int pvdata(int argc, char **argv) {return 1;}
|
int pvdata(int argc, char **argv) {return 1;}
|
||||||
int vgcfgbackup(int argc, char **argv) {return 1;}
|
int vgcfgbackup(int argc, char **argv) {return 1;}
|
||||||
int vgcfgrestore(int argc, char **argv) {return 1;}
|
int vgcfgrestore(int argc, char **argv) {return 1;}
|
||||||
|
Loading…
Reference in New Issue
Block a user