1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Make --snapshot optional with lvcreate --virtualsize.

Generalise --virtualoriginsize to --virtualsize.
This commit is contained in:
Alasdair Kergon 2009-05-27 16:30:29 +00:00
parent 36a1d9e9b4
commit 154753db8b
6 changed files with 27 additions and 23 deletions

View File

@ -1,5 +1,7 @@
Version 2.02.48 -
===============================
Make --snapshot optional with lvcreate --virtualsize.
Generalise --virtualoriginsize to --virtualsize.
Skip virtual origins in process_each_lv_in_vg().
Fix counting of virtual origin LVs in vg_validate.
Attempt to load dm-zero module if zero target needed but not present.

View File

@ -26,8 +26,10 @@ VolumeGroupName [PhysicalVolumePath...]
\-L|\-\-size LogicalVolumeSize[kKmMgGtT]}
[\-c|\-\-chunksize ChunkSize]
\-n|\-\-name SnapshotLogicalVolumeName
\-s|\-\-snapshot
[OriginalLogicalVolumePath | VolumeGroupName \-\-virtualoriginsize VirtualOriginSize]
{{\-s|\-\-snapshot}
OriginalLogicalVolumePath |
[\-s|\-\-snapshot]
VolumeGroupName \-\-virtualsize VirtualSize}
.SH DESCRIPTION
lvcreate creates a new logical volume in a volume group ( see
.B vgcreate(8), vgchange(8)
@ -152,11 +154,11 @@ allocate slightly more space than you actually need and monitor the
rate at which the snapshot data is growing so you can avoid running out
of space.
.TP
.I \-\-virtualoriginsize VirtualOriginSize
In conjunction with \-\-snapshot, create a sparse device of the given size
(in MB by default). Anything written to the device will be returned when
reading from it. Reading from other areas of the device will return
blocks of zeros. It is implemented by creating a hidden virtual device of the
.I \-\-virtualsize VirtualSize
Create a sparse device of the given size (in MB by default) using a snapshot.
Anything written to the device will be returned when reading from it.
Reading from other areas of the device will return blocks of zeros.
It is implemented by creating a hidden virtual device of the
requested size using the zero target. A suffix of _vorigin is used for
this device.
.TP

View File

@ -59,6 +59,7 @@ arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
arg(rows_ARG, '\0', "rows", NULL, 0)
arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0)
arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
arg(virtualsize_ARG, '\0', "virtualsize", size_mb_arg, 0)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)

View File

@ -145,7 +145,9 @@ xx(lvcreate,
"\t[--version]\n"
"\tVolumeGroupName [PhysicalVolumePath...]\n\n"
"lvcreate -s|--snapshot\n"
"lvcreate \n"
"\t{ {-s|--snapshot} OriginalLogicalVolume[Path] |\n"
"\t [-s|--snapshot] VolumeGroupName[Path] --virtualsize VirtualSize}\n"
"\t[-c|--chunksize]\n"
"\t[-A|--autobackup {y|n}]\n"
"\t[--addtag Tag]\n"
@ -163,15 +165,14 @@ xx(lvcreate,
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
"\t[--version]\n"
"\t[OriginalLogicalVolume[Path] |\n"
"\t VolumeGroupName[Path] --virtualoriginsize VirtualOriginSize]]\n"
"\t[PhysicalVolumePath...]\n\n",
addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
name_ARG, nosync_ARG, permission_ARG, persistent_ARG, readahead_ARG,
regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG,
test_ARG, type_ARG, virtualoriginsize_ARG, zero_ARG)
test_ARG, type_ARG, virtualoriginsize_ARG, virtualsize_ARG, zero_ARG)
xx(lvdisplay,
"Display information about a logical volume",

View File

@ -66,7 +66,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (arg_count(cmd, name_ARG))
lp->lv_name = arg_value(cmd, name_ARG);
if (lp->snapshot && !arg_count(cmd, virtualoriginsize_ARG)) {
if (lp->snapshot && !arg_count(cmd, virtualsize_ARG)) {
if (!argc) {
log_err("Please specify a logical volume to act as "
"the snapshot origin.");
@ -178,12 +178,12 @@ static int _read_size_params(struct lvcreate_params *lp,
}
/* Size returned in kilobyte units; held in sectors */
if (arg_count(cmd, virtualoriginsize_ARG)) {
if (arg_sign_value(cmd, virtualoriginsize_ARG, 0) == SIGN_MINUS) {
if (arg_count(cmd, virtualsize_ARG)) {
if (arg_sign_value(cmd, virtualsize_ARG, 0) == SIGN_MINUS) {
log_error("Negative virtual origin size is invalid");
return 0;
}
lp->voriginsize = arg_uint64_value(cmd, virtualoriginsize_ARG,
lp->voriginsize = arg_uint64_value(cmd, virtualsize_ARG,
UINT64_C(0));
if (!lp->voriginsize) {
log_error("Virtual origin size may not be zero");
@ -362,7 +362,8 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
if (arg_count(cmd, stripes_ARG) && lp->stripes == 1)
log_print("Redundant stripes argument: default is 1");
if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp))
if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp) ||
arg_count(cmd, virtualsize_ARG))
lp->snapshot = 1;
lp->mirrors = 1;
@ -406,10 +407,6 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
log_error("-c is only available with snapshots");
return 0;
}
if (arg_count(cmd, virtualoriginsize_ARG)) {
log_error("--virtualoriginsize is only available with snapshots");
return 0;
}
}
if (lp->mirrors > 1) {
@ -722,7 +719,7 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
/* Must zero cow */
status |= LVM_WRITE;
if (arg_count(cmd, virtualoriginsize_ARG))
if (arg_count(cmd, virtualsize_ARG))
origin_active = 1;
else {
@ -733,7 +730,7 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
}
if (lv_is_virtual_origin(org)) {
log_error("Can't share virtual origins. "
"Use --virtualoriginsize.");
"Use --virtualsize.");
return 0;
}
if (lv_is_cow(org)) {

View File

@ -816,7 +816,8 @@ static int _get_settings(struct cmd_context *cmd)
/* Handle synonyms */
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, resizeable_ARG))
!_merge_synonym(cmd, allocation_ARG, resizeable_ARG) ||
!_merge_synonym(cmd, virtualoriginsize_ARG, virtualsize_ARG))
return EINVALID_CMD_LINE;
/* Zero indicates success */