summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/commands.h55
-rw-r--r--tools/lvcreate.c20
-rw-r--r--tools/lvm.c1
3 files changed, 38 insertions, 38 deletions
diff --git a/tools/commands.h b/tools/commands.h
index 6668e578..dfc219c1 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -68,41 +68,28 @@ xx(lvchange,
xx(lvcreate,
"Create a logical volume",
"lvcreate " "\n"
- "\t[-A|--autobackup {y|n}] " "\n"
- "\t[-C|--contiguous {y|n}] " "\n"
- "\t[-d|--debug]" "\n"
- "\t[-h|--help] " "\n"
- "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]" "\n"
- "\t{-l|--extents LogicalExtentsNumber |" "\n"
- "\t -L|--size LogicalVolumeSize[kKmMgGtT]} " "\n"
+ "\t[-A|--autobackup {y|n}]\n"
+ "\t[-c|--chunksize]\n"
+ "\t[-C|--contiguous {y|n}]\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
+ "\t{-l|--extents LogicalExtentsNumber |\n"
+ "\t -L|--size LogicalVolumeSize[kKmMgGtT]}\n"
"\t[-M|--persistent {y|n}] [--minor minor]\n"
- "\t[-n|--name LogicalVolumeName]" "\n"
- "\t[-p|--permission {r|rw}] " "\n"
- "\t[-r|--readahead ReadAheadSectors]" "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[-Z|--zero {y|n}] " "\n"
- "\t[--version]" "\n"
- "\tVolumeGroupName [PhysicalVolumePath...]" "\n\n"
-
- ,
-/*
- "lvcreate "
- "\t-s|--snapshot "
- "\t[-c|--chunksize ChunkSize]" "\n"
- "\t{-l|--extents LogicalExtentsNumber |" "\n"
- "\t -L|--size LogicalVolumeSize[kKmMgGtT]}" "\n"
- "\t-n|--name SnapshotLogicalVolumeName" "\n"
- "\t[-t|--test]" "\n"
- "\tLogicalVolume[Path] [PhysicalVolumePath...]" "\n",
-chunksize_ARG,
-snapshot_ARG,
-*/
-
- autobackup_ARG, contiguous_ARG, stripes_ARG, stripesize_ARG,
- extents_ARG, size_ARG, name_ARG, permission_ARG, readahead_ARG,
- minor_ARG, persistent_ARG,
- test_ARG, zero_ARG)
+ "\t[-n|--name LogicalVolumeName]\n"
+ "\t[-p|--permission {r|rw}]\n"
+ "\t[-r|--readahead ReadAheadSectors]\n"
+ "\t[-s|--snapshot]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[-Z|--zero {y|n}]\n"
+ "\t[--version]\n"
+ "\tVolumeGroupName [PhysicalVolumePath...]\n\n",
+
+ autobackup_ARG, contiguous_ARG, extents_ARG, minor_ARG, name_ARG,
+ permission_ARG, persistent_ARG, readahead_ARG, size_ARG,
+ snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, zero_ARG)
xx(lvdisplay,
"Display information about a logical volume",
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 27a58a37..5fa8e8b6 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -62,6 +62,10 @@ static int _read_name_params(struct lvcreate_params *lp,
return 0;
}
+ /* Strip the volume group from the origin */
+ if ((ptr = strrchr(lp->origin, (int) '/')))
+ lp->origin = ptr + 1;
+
} else {
/*
* If VG not on command line, try -n arg and then
@@ -130,7 +134,7 @@ static int _read_size_params(struct lvcreate_params *lp,
/* Size returned in kilobyte units; held in sectors */
if (arg_count(cmd, size_ARG))
- lp->size = arg_int_value(cmd, size_ARG, 0);
+ lp->size = arg_int64_value(cmd, size_ARG, 0) * 2ull;
return 1;
}
@@ -251,7 +255,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp,
uint32_t size_rest;
uint32_t status;
struct volume_group *vg;
- struct logical_volume *lv;
+ struct logical_volume *lv, *org;
struct list *pvh;
@@ -312,7 +316,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp,
if (lp->size) {
/* No of 512-byte sectors */
- lp->extents = lp->size * 2;
+ lp->extents = lp->size;
if (lp->extents % vg->extent_size) {
char *s1;
@@ -336,6 +340,11 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp,
lp->extents = lp->extents - size_rest + lp->stripes;
}
+ if (lp->snapshot && !(org = find_lv(vg, lp->origin))) {
+ log_err("Couldn't find origin volume '%s'.", lp->origin);
+ return 0;
+ }
+
if (!archive(vg))
return 0;
@@ -344,6 +353,11 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp,
vg, pvh)))
return 0;
+ if (lp->snapshot && !vg_add_snapshot(vg, org, lv, 1, lp->chunk_size)) {
+ log_err("Couldn't create snapshot.");
+ return 0;
+ }
+
if (lp->read_ahead) {
log_verbose("Setting read ahead sectors");
lv->read_ahead = lp->read_ahead;
diff --git a/tools/lvm.c b/tools/lvm.c
index 182d9e13..b648e284 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -262,7 +262,6 @@ int size_arg(struct arg *a)
a->i64_value = (uint64_t) v;
return 1;
-
}
int int_arg(struct arg *a)