mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-24 06:04:19 +03:00
Fix rounding of large displayed sizes.
This commit is contained in:
parent
5bf92ced1a
commit
359fffa5f1
@ -1,5 +1,6 @@
|
||||
Version 2.00.17 -
|
||||
=============================
|
||||
Fix rounding of large diplayed sizes.
|
||||
Suppress decimal point when using units of sectors/bytes.
|
||||
Additional kernel target checks before pvmove & snapshot creation.
|
||||
Add i2o_block.
|
||||
|
@ -131,6 +131,7 @@ alloc_policy_t get_alloc_from_string(const char *str)
|
||||
return ALLOC_INVALID;
|
||||
}
|
||||
|
||||
/* Size supplied in sectors */
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
{
|
||||
int s;
|
||||
@ -169,8 +170,9 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
|
||||
if (s < 8) {
|
||||
byte = cmd->current_settings.unit_factor;
|
||||
size *= UINT64_C(1024);
|
||||
size *= UINT64_C(512);
|
||||
} else {
|
||||
size /= 2;
|
||||
suffix = 1;
|
||||
if (cmd->current_settings.unit_type == 'H')
|
||||
units = UINT64_C(1000);
|
||||
@ -193,7 +195,7 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
}
|
||||
|
||||
snprintf(size_buf, SIZE_BUF - 1, "%.*f%s", precision,
|
||||
(float) size / byte, suffix ? size_str[s][sl] : "");
|
||||
(double) size / byte, suffix ? size_str[s][sl] : "");
|
||||
|
||||
return size_buf;
|
||||
}
|
||||
@ -246,18 +248,18 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
log_print("VG Name %s%s", pv->vg_name,
|
||||
pv->status & EXPORTED_VG ? " (exported)" : "");
|
||||
|
||||
size = display_size(cmd, (uint64_t) pv->size / 2, SIZE_SHORT);
|
||||
size = display_size(cmd, (uint64_t) pv->size, SIZE_SHORT);
|
||||
if (pv->pe_size && pv->pe_count) {
|
||||
|
||||
/******** FIXME display LVM on-disk data size
|
||||
size2 = display_size(pv->size / 2, SIZE_SHORT);
|
||||
size2 = display_size(pv->size, SIZE_SHORT);
|
||||
********/
|
||||
|
||||
log_print("PV Size %s" " / not usable %s", /* [LVM: %s]", */
|
||||
size, display_size(cmd,
|
||||
(pv->size -
|
||||
pv->pe_count * pv->pe_size) / 2,
|
||||
SIZE_SHORT));
|
||||
size,
|
||||
display_size(cmd, (pv->size -
|
||||
pv->pe_count * pv->pe_size),
|
||||
SIZE_SHORT));
|
||||
|
||||
} else
|
||||
log_print("PV Size %s", size);
|
||||
@ -400,7 +402,7 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
log_print("LV Size %s",
|
||||
display_size(cmd,
|
||||
snap ? snap->origin->size / 2 : lv->size / 2,
|
||||
snap ? snap->origin->size : lv->size,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("Current LE %u",
|
||||
@ -421,11 +423,11 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
snap_percent = 100;
|
||||
|
||||
log_print("Snapshot chunk size %s",
|
||||
display_size(cmd, (uint64_t) snap->chunk_size / 2,
|
||||
display_size(cmd, (uint64_t) snap->chunk_size,
|
||||
SIZE_SHORT));
|
||||
|
||||
/*
|
||||
size = display_size(lv->size / 2, SIZE_SHORT);
|
||||
size = display_size(lv->size, SIZE_SHORT);
|
||||
sscanf(size, "%f", &fsize);
|
||||
fused = fsize * snap_percent / 100;
|
||||
*/
|
||||
@ -552,7 +554,7 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print("Open LV %u", lvs_in_vg_opened(vg));
|
||||
/****** FIXME Max LV Size
|
||||
log_print ( "MAX LV Size %s",
|
||||
( s1 = display_size ( LVM_LV_SIZE_MAX(vg) / 2, SIZE_SHORT)));
|
||||
( s1 = display_size ( LVM_LV_SIZE_MAX(vg), SIZE_SHORT)));
|
||||
free ( s1);
|
||||
*********/
|
||||
log_print("Max PV %u", vg->max_pv);
|
||||
@ -561,30 +563,25 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
|
||||
log_print("VG Size %s",
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->extent_count * (vg->extent_size /
|
||||
2), SIZE_SHORT));
|
||||
(uint64_t) vg->extent_count * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("PE Size %s",
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_size / 2,
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("Total PE %u", vg->extent_count);
|
||||
|
||||
log_print("Alloc PE / Size %u / %s",
|
||||
vg->extent_count - vg->free_count, display_size(vg->cmd,
|
||||
((uint64_t)
|
||||
vg->extent_count
|
||||
-
|
||||
vg->free_count)
|
||||
*
|
||||
(vg->extent_size
|
||||
/ 2),
|
||||
SIZE_SHORT));
|
||||
vg->extent_count - vg->free_count,
|
||||
display_size(vg->cmd,
|
||||
((uint64_t) vg->extent_count - vg->free_count) *
|
||||
vg->extent_size, SIZE_SHORT));
|
||||
|
||||
log_print("Free PE / Size %u / %s", vg->free_count,
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->free_count * (vg->extent_size /
|
||||
2), SIZE_SHORT));
|
||||
(uint64_t) vg->free_count * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
|
||||
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
@ -653,15 +650,15 @@ void vgdisplay_short(struct volume_group *vg)
|
||||
{
|
||||
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
|
||||
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_count *
|
||||
vg->extent_size / 2, SIZE_SHORT),
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->extent_count * vg->extent_size,
|
||||
SIZE_SHORT),
|
||||
display_size(vg->cmd,
|
||||
((uint64_t) vg->extent_count -
|
||||
vg->free_count) * vg->extent_size / 2,
|
||||
SIZE_SHORT), display_size(vg->cmd,
|
||||
(uint64_t)
|
||||
vg->free_count *
|
||||
vg->extent_size / 2,
|
||||
SIZE_SHORT));
|
||||
vg->free_count) * vg->extent_size,
|
||||
SIZE_SHORT),
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->free_count * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ static int _pv_setup(const struct format_type *fmt,
|
||||
pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE) {
|
||||
log_error("Physical volumes cannot be bigger than %s",
|
||||
display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE / 2,
|
||||
display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
@ -386,7 +386,7 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
}
|
||||
if (lv->size > max_size) {
|
||||
log_error("logical volumes cannot be larger than %s",
|
||||
display_size(fid->fmt->cmd, max_size / 2,
|
||||
display_size(fid->fmt->cmd, max_size,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
@ -468,21 +468,18 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
|
||||
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
|
||||
log_error("Extent size must be between %s and %s",
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE
|
||||
/ 2,
|
||||
SIZE_SHORT), display_size(fid->fmt->cmd,
|
||||
(uint64_t)
|
||||
MAX_PE_SIZE
|
||||
/ 2,
|
||||
SIZE_SHORT));
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE,
|
||||
SIZE_SHORT),
|
||||
display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE,
|
||||
SIZE_SHORT));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->extent_size % MIN_PE_SIZE) {
|
||||
log_error("Extent size must be multiple of %s",
|
||||
display_size(fid->fmt->cmd,
|
||||
(uint64_t) MIN_PE_SIZE / 2, SIZE_SHORT));
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
uint64_t max_size = UINT_MAX;
|
||||
|
||||
if (lv->size > max_size) {
|
||||
char *dummy = display_size(max_size / 2, SIZE_SHORT);
|
||||
char *dummy = display_size(max_size, SIZE_SHORT);
|
||||
log_error("logical volumes cannot be larger than %s", dummy);
|
||||
dbg_free(dummy);
|
||||
return 0;
|
||||
|
@ -459,7 +459,7 @@ static int _size32_disp(struct report_handle *rh, struct field *field,
|
||||
const char *disp;
|
||||
uint64_t *sortval;
|
||||
|
||||
if (!*(disp = display_size(rh->cmd, (uint64_t) size / 2, SIZE_UNIT))) {
|
||||
if (!*(disp = display_size(rh->cmd, (uint64_t) size, SIZE_UNIT))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -487,7 +487,7 @@ static int _size64_disp(struct report_handle *rh, struct field *field,
|
||||
const char *disp;
|
||||
uint64_t *sortval;
|
||||
|
||||
if (!*(disp = display_size(rh->cmd, size / 2, SIZE_UNIT))) {
|
||||
if (!*(disp = display_size(rh->cmd, size, SIZE_UNIT))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
tmp_size += vg->extent_size - tmp_size %
|
||||
vg->extent_size;
|
||||
log_print("Rounding up size to full physical extent %s",
|
||||
display_size(cmd, tmp_size / 2, SIZE_SHORT));
|
||||
display_size(cmd, tmp_size, SIZE_SHORT));
|
||||
}
|
||||
|
||||
lp->extents = tmp_size / vg->extent_size;
|
||||
|
@ -64,7 +64,7 @@ static void _print(struct cmd_context *cmd, const struct device *dev,
|
||||
uint64_t size, const char *what)
|
||||
{
|
||||
log_print("%-*s [%15s] %s", max_len, dev_name(dev),
|
||||
display_size(cmd, size / 2, SIZE_SHORT), what ? : "");
|
||||
display_size(cmd, size, SIZE_SHORT), what ? : "");
|
||||
}
|
||||
|
||||
static int _check_device(struct cmd_context *cmd, struct device *dev)
|
||||
|
@ -181,7 +181,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
(lp->size % vg->extent_size);
|
||||
|
||||
log_print("Rounding up size to full physical extent %s",
|
||||
display_size(cmd, (uint64_t) lp->size / 2,
|
||||
display_size(cmd, (uint64_t) lp->size,
|
||||
SIZE_SHORT));
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
log_print("WARNING: Reducing active%s logical volume "
|
||||
"to %s", info.open_count ? " and open" : "",
|
||||
display_size(cmd, (uint64_t) lp->extents *
|
||||
(vg->extent_size / 2),
|
||||
vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("THIS MAY DESTROY YOUR DATA "
|
||||
@ -391,7 +391,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
|
||||
log_print("Extending logical volume %s to %s", lp->lv_name,
|
||||
display_size(cmd, (uint64_t)
|
||||
lp->extents * (vg->extent_size / 2),
|
||||
lp->extents * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
|
||||
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes,
|
||||
|
@ -39,7 +39,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
log_print("%s%s '%s%s/%s' [%s] %s", active_str, snapshot_str,
|
||||
cmd->dev_dir, lv->vg->name, lv->name,
|
||||
display_size(cmd, lv->size / 2, SIZE_SHORT),
|
||||
display_size(cmd, lv->size, SIZE_SHORT),
|
||||
get_alloc_string(lv->alloc));
|
||||
|
||||
lv_total++;
|
||||
|
@ -29,7 +29,7 @@ static int _pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
if (arg_count(cmd, short_ARG)) {
|
||||
log_print("Device \"%s\" has a capacity of %s", pv_name,
|
||||
display_size(cmd, size / 2, SIZE_SHORT));
|
||||
display_size(cmd, size, SIZE_SHORT));
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ static int _pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
if (!pv->vg_name)
|
||||
log_print("\"%s\" is a new physical volume of \"%s\"",
|
||||
pv_name, display_size(cmd, size / 2, SIZE_SHORT));
|
||||
pv_name, display_size(cmd, size, SIZE_SHORT));
|
||||
|
||||
if (arg_count(cmd, colon_ARG)) {
|
||||
pvdisplay_colons(pv);
|
||||
|
@ -66,7 +66,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_max_name_len, " ",
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
display_size(cmd, pv->size / 2, SIZE_SHORT));
|
||||
display_size(cmd, pv->size, SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,24 +77,23 @@ static void _pvscan_display_single(struct cmd_context *cmd,
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_name_this,
|
||||
display_size(cmd, (uint64_t) pv->pe_count *
|
||||
pv->pe_size / 2, SIZE_SHORT),
|
||||
pv->pe_size, SIZE_SHORT),
|
||||
display_size(cmd, (uint64_t) (pv->pe_count -
|
||||
pv->pe_alloc_count)
|
||||
* pv->pe_size / 2, SIZE_SHORT));
|
||||
* pv->pe_size, SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(vg_tmp_name, "%s", pv->vg_name);
|
||||
log_print
|
||||
("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
|
||||
pv_tmp_name, vg_max_name_len, vg_tmp_name,
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
display_size(cmd, (uint64_t) pv->pe_count * pv->pe_size / 2,
|
||||
SIZE_SHORT), display_size(cmd, (uint64_t)
|
||||
(pv->pe_count -
|
||||
pv->pe_alloc_count) *
|
||||
pv->pe_size / 2,
|
||||
SIZE_SHORT));
|
||||
log_print("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
|
||||
pv_tmp_name, vg_max_name_len, vg_tmp_name,
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
display_size(cmd, (uint64_t) pv->pe_count * pv->pe_size,
|
||||
SIZE_SHORT),
|
||||
display_size(cmd,
|
||||
(uint64_t) (pv->pe_count - pv->pe_alloc_count) *
|
||||
pv->pe_size,
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -189,10 +188,10 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
log_print("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]",
|
||||
pvs_found,
|
||||
display_size(cmd, size_total / 2, SIZE_SHORT),
|
||||
display_size(cmd, size_total, SIZE_SHORT),
|
||||
pvs_found - new_pvs_found,
|
||||
display_size(cmd, (size_total - size_new) / 2, SIZE_SHORT),
|
||||
new_pvs_found, display_size(cmd, size_new / 2, SIZE_SHORT));
|
||||
display_size(cmd, (size_total - size_new), SIZE_SHORT),
|
||||
new_pvs_found, display_size(cmd, size_new, SIZE_SHORT));
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user