summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2009-05-27 16:30:29 +0000
committerAlasdair Kergon <agk@redhat.com>2009-05-27 16:30:29 +0000
commit154753db8b7595525f7b9b33b517eab946e0ec51 (patch)
treee0c86676f2e78de21cc59ad5d819bc7c284806ef
parent36a1d9e9b4c26416986b9aa675731cf9dbf4099f (diff)
downloadlvm2-154753db8b7595525f7b9b33b517eab946e0ec51.tar.gz
lvm2-154753db8b7595525f7b9b33b517eab946e0ec51.tar.xz
lvm2-154753db8b7595525f7b9b33b517eab946e0ec51.zip
Make --snapshot optional with lvcreate --virtualsize.
Generalise --virtualoriginsize to --virtualsize.
-rw-r--r--WHATS_NEW2
-rw-r--r--man/lvcreate.8.in16
-rw-r--r--tools/args.h1
-rw-r--r--tools/commands.h9
-rw-r--r--tools/lvcreate.c19
-rw-r--r--tools/lvmcmdline.c3
6 files changed, 27 insertions, 23 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 23fce5f9..b5ba17d4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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.
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 1e5322b0..af3dc283 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -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
diff --git a/tools/args.h b/tools/args.h
index c3f23320..f8dc02c6 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -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)
diff --git a/tools/commands.h b/tools/commands.h
index 18495288..eec62e3b 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -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",
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 65dc39a4..b7dce37b 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -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)) {
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index bedf9e2d..0d4e230a 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -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 */