mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-23 21:35:29 +03:00
o Use 'pvcreate --setphysicalvolumesize' with no short form (instead of -s)
and add severe warning if it's used to make a device seem bigger than it really is. This is not an option people should be using as it breaks metadata integrity. o Use uint64_t throughout (rather than unsigned long long) o Convert a few messages that contain pathnames into the more common form: pathname: message
This commit is contained in:
parent
6544fb43d9
commit
f6485616cd
@ -31,7 +31,7 @@
|
||||
|
||||
#define SIZE_BUF 128
|
||||
|
||||
char *display_size(unsigned long long size, size_len_t sl)
|
||||
char *display_size(uint64_t size, size_len_t sl)
|
||||
{
|
||||
int s;
|
||||
ulong byte = 1024 * 1024 * 1024;
|
||||
@ -109,7 +109,7 @@ void pvdisplay_full(struct physical_volume *pv)
|
||||
log_print("VG Name %s%s", pv->vg_name,
|
||||
pv->status & EXPORTED_VG ? " (exported)" : "");
|
||||
|
||||
size = display_size((unsigned long long) pv->size / 2, SIZE_SHORT);
|
||||
size = display_size((uint64_t) 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);
|
||||
@ -470,7 +470,7 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print ( "Act PV %u", vg->pv_act);
|
||||
*********/
|
||||
|
||||
s1 = display_size((unsigned long long) vg->extent_count * (vg->extent_size / 2), SIZE_SHORT);
|
||||
s1 = display_size((uint64_t) vg->extent_count * (vg->extent_size / 2), SIZE_SHORT);
|
||||
log_print("VG Size %s", s1);
|
||||
dbg_free(s1);
|
||||
|
||||
@ -481,14 +481,14 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print("Total PE %u", vg->extent_count);
|
||||
|
||||
s1 =
|
||||
display_size(((unsigned long long)
|
||||
display_size(((uint64_t)
|
||||
vg->extent_count - vg->free_count) *
|
||||
(vg->extent_size / 2), SIZE_SHORT);
|
||||
log_print("Alloc PE / Size %u / %s",
|
||||
vg->extent_count - vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
|
||||
s1 = display_size((unsigned long long) vg->free_count * (vg->extent_size / 2), SIZE_SHORT);
|
||||
s1 = display_size((uint64_t) vg->free_count * (vg->extent_size / 2), SIZE_SHORT);
|
||||
log_print("Free PE / Size %u / %s", vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
typedef enum {SIZE_LONG=0, SIZE_SHORT=1} size_len_t;
|
||||
|
||||
/* Specify size in KB */
|
||||
char *display_size(unsigned long long size, size_len_t sl);
|
||||
char *display_size(uint64_t size, size_len_t sl);
|
||||
char *display_uuid(char *uuidstr);
|
||||
|
||||
void pvdisplay_colons(struct physical_volume *pv);
|
||||
|
@ -395,15 +395,17 @@ static int _pv_setup(struct format_instance *fi, struct physical_volume *pv,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
/* setup operations for the PV structure */
|
||||
|
||||
if (pv->size > MAX_PV_SIZE) pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE)
|
||||
pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE) {
|
||||
log_error("physical volumes cannot be bigger than 2TB");
|
||||
/* FIXME Limit hardcoded */
|
||||
log_error("Physical volumes cannot be bigger than 2TB");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* setup operations which need members derived from the VG */
|
||||
if (!vg) return 1;
|
||||
/* Nothing more to do if pe_size isn't known */
|
||||
if (!vg)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* This works out pe_start and pe_count.
|
||||
|
@ -203,7 +203,7 @@ struct physical_volume *pv_create(struct format_instance *fi,
|
||||
memcpy(&pv->id, id, sizeof(*id));
|
||||
|
||||
if (!(pv->dev = dev_cache_get(name, fi->cmd->filter))) {
|
||||
log_err("Couldn't find device '%s'", name);
|
||||
log_error("%s: Couldn't find device.", name);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@ -215,14 +215,23 @@ struct physical_volume *pv_create(struct format_instance *fi,
|
||||
*pv->vg_name = 0;
|
||||
pv->status = ALLOCATABLE_PV;
|
||||
|
||||
if (size) {
|
||||
if (size < PV_MIN_SIZE) {
|
||||
log_err("Given size for '%s' is too small", name);
|
||||
if (!dev_get_size(pv->dev, &pv->size)) {
|
||||
log_error("%s: Couldn't get size.", name);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (size) {
|
||||
if (size > pv->size)
|
||||
log_print("WARNING: %s: Overriding real size. "
|
||||
"You could lose data.", name);
|
||||
log_verbose("%s: Pretending size is %" PRIu64 " sectors.",
|
||||
name, size);
|
||||
pv->size = size;
|
||||
} else if (!dev_get_size(pv->dev, &pv->size)) {
|
||||
log_err("Couldn't get size of device '%s'", name);
|
||||
}
|
||||
|
||||
if (pv->size < PV_MIN_SIZE) {
|
||||
log_error("%s: Size must exceed minimum of %lu sectors.",
|
||||
name, PV_MIN_SIZE);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@ -232,7 +241,7 @@ struct physical_volume *pv_create(struct format_instance *fi,
|
||||
pv->pe_allocated = 0;
|
||||
|
||||
if (!fi->ops->pv_setup(fi, pv, NULL)) {
|
||||
log_error("Format-specific setup of physical volume '%s' "
|
||||
log_error("%s: Format-specific setup of physical volume "
|
||||
"failed.", name);
|
||||
goto bad;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
arg(version_ARG, '\0', "version", NULL)
|
||||
arg(quiet_ARG, '\0', "quiet", NULL)
|
||||
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_arg)
|
||||
|
||||
/* Allow some variations */
|
||||
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
|
||||
@ -58,7 +59,6 @@ arg(physicalvolume_ARG, 'P', "physicalvolume", NULL)
|
||||
arg(readahead_ARG, 'r', "readahead", int_arg)
|
||||
arg(reset_ARG, 'R', "reset", NULL)
|
||||
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_arg)
|
||||
arg(physicalvolumesize_ARG, 's', "size", size_arg)
|
||||
arg(stdin_ARG, 's', "stdin", NULL)
|
||||
arg(snapshot_ARG, 's', "snapshot", NULL)
|
||||
arg(short_ARG, 's', "short", NULL)
|
||||
|
@ -279,7 +279,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
if (lv_active(lv) > 0) {
|
||||
dummy =
|
||||
display_size((unsigned long long)
|
||||
display_size((uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("WARNING: Reducing active%s logical volume "
|
||||
@ -321,7 +321,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
/* Use full list from VG */
|
||||
pvh = &vg->pvs;
|
||||
}
|
||||
dummy = display_size((unsigned long long)
|
||||
dummy = display_size((uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("Extending logical volume %s to %s", lv_name, dummy);
|
||||
|
@ -32,8 +32,11 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
struct physical_volume *pv;
|
||||
|
||||
/* is the partition type set correctly ? */
|
||||
if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name))
|
||||
if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) {
|
||||
log_error("%s: Not LVM partition type: use -f to override",
|
||||
name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* is there a pv here already */
|
||||
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, name)))
|
||||
@ -54,7 +57,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
/* prompt */
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
yes_no_prompt(_really_init, name, pv->vg_name) == 'n') {
|
||||
log_print("Physical volume \"%s\" not initialized", name);
|
||||
log_print("%s: physical volume not initialized", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -94,14 +97,15 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name)
|
||||
|
||||
size = arg_int64_value(cmd, physicalvolumesize_ARG, 0) * 2;
|
||||
if (!(pv = pv_create(cmd->fid, pv_name, idp, size))) {
|
||||
log_err("Failed to setup physical volume \"%s\"", pv_name);
|
||||
log_error("Failed to setup physical volume \"%s\"", pv_name);
|
||||
return;
|
||||
}
|
||||
|
||||
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
||||
" sectors", pv_name, pv->size);
|
||||
|
||||
log_verbose("Writing physical volume data to disk \"%s\"", pv_name);
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
pv_name);
|
||||
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
||||
log_error("Failed to write physical volume \"%s\"", pv_name);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user