master - pools: prefetch pool_lv and origin_lv
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=25307e4add1e3f...
Commit: 25307e4add1e3f25cf5ae00d942df61afa46fe60
Parent: 618d818c0d31bbfa1ed4af2e8954c8a4b53127af
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 18:17:40 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
pools: prefetch pool_lv and origin_lv
Load pool_lv and origin_lv at a single place and
use it for more types as they need them.
---
lib/metadata/lv_manip.c | 105 ++++++++++++++++++++++++----------------------
1 files changed, 55 insertions(+), 50 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 335a1bd..8523b58 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6602,7 +6602,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
const char *new_lv_name)
{
struct cmd_context *cmd = vg->cmd;
- uint32_t size_rest;
+ uint32_t size_rest, size;
uint64_t status = lp->permission | VISIBLE_LV;
const struct segment_type *create_segtype = lp->segtype;
struct logical_volume *lv, *origin_lv = NULL;
@@ -6702,18 +6702,46 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (seg_is_pool(lp))
status |= LVM_WRITE; /* Pool is always writable */
+ else if (seg_is_cache(lp) || seg_is_thin_volume(lp)) {
+ /* Resolve pool volume */
+ if (!lp->pool_name) {
+ /* Should be already checked */
+ log_error(INTERNAL_ERROR "Cannot create %s volume without %s pool.",
+ lp->segtype->name, lp->segtype->name);
+ return NULL;
+ }
- if (seg_is_cache_pool(lp) && lp->origin_name) {
- /* Converting exiting origin and creating cache pool */
- if (!(origin_lv = find_lv(vg, lp->origin_name))) {
- log_error("Cache origin volume %s not found in Volume group %s.",
- lp->origin_name, vg->name);
+ if (!(pool_lv = find_lv(vg, lp->pool_name))) {
+ log_error("Couldn't find volume %s in Volume group %s.",
+ lp->pool_name, vg->name);
return NULL;
}
+ if (lv_is_locked(pool_lv)) {
+ log_error("Cannot use locked pool volume %s.",
+ display_lvname(pool_lv));
+ return NULL;
+ }
+ }
+
+ /* Resolve origin volume */
+ if (lp->origin_name &&
+ !(origin_lv = find_lv(vg, lp->origin_name))) {
+ log_error("Origin volume %s not found in Volume group %s.",
+ lp->origin_name, vg->name);
+ return NULL;
+ }
+
+ if (origin_lv && seg_is_cache_pool(lp)) {
+ /* Converting exiting origin and creating cache pool */
if (!validate_lv_cache_create_origin(origin_lv))
return_NULL;
+ if (origin_lv->size < lp->chunk_size) {
+ log_error("Caching of origin cache volume smaller then chunk size is unsupported.");
+ return NULL;
+ }
+
/* Validate cache origin is exclusively active */
if (vg_is_clustered(origin_lv->vg) &&
locking_is_clustered() &&
@@ -6724,29 +6752,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
display_lvname(origin_lv));
return NULL;
}
- } else if (seg_is_cache(lp)) {
- if (!lp->pool_name) {
- log_error(INTERNAL_ERROR "Cannot create thin volume without thin pool.");
- return NULL;
- }
- if (!(pool_lv = find_lv(vg, lp->pool_name))) {
- log_error("Couldn't find volume %s in Volume group %s.",
- lp->pool_name, vg->name);
- return NULL;
- }
-
+ } else if (pool_lv && seg_is_cache(lp)) {
if (!lv_is_cache_pool(pool_lv)) {
log_error("Logical volume %s is not a cache pool.",
display_lvname(pool_lv));
return NULL;
}
-
- if (lv_is_locked(pool_lv)) {
- log_error("Cannot use locked cache pool %s.",
- display_lvname(pool_lv));
- return NULL;
- }
-
/* Create cache origin for cache pool */
/* TODO: eventually support raid/mirrors with -m */
if (!(create_segtype = get_segtype_from_string(vg->cmd, "striped")))
@@ -6765,39 +6776,16 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->region_size = adjusted_mirror_region_size(vg->extent_size,
lp->extents,
lp->region_size, 0);
- } else if (seg_is_thin_volume(lp)) {
- if (!lp->pool_name) {
- log_error(INTERNAL_ERROR "Cannot create thin volume without thin pool.");
- return NULL;
- }
-
- if (!(pool_lv = find_lv(vg, lp->pool_name))) {
- log_error("Unable to find existing pool LV %s in VG %s.",
- lp->pool_name, vg->name);
- return NULL;
- }
-
+ } else if (pool_lv && seg_is_thin_volume(lp)) {
if (!lv_is_thin_pool(pool_lv)) {
log_error("Logical volume %s is not a thin pool.",
display_lvname(pool_lv));
return NULL;
}
- if (lv_is_locked(pool_lv)) {
- log_error("Cannot use locked thin pool %s.",
- display_lvname(pool_lv));
- return NULL;
- }
-
thin_name = lp->pool_name;
- if (lp->origin_name) {
- if (!(origin_lv = find_lv(vg, lp->origin_name))) {
- log_error("Couldn't find origin volume '%s'.",
- lp->origin_name);
- return NULL;
- }
-
+ if (origin_lv) {
if (lv_is_locked(origin_lv)) {
log_error("Snapshots of locked devices are not supported.");
return NULL;
@@ -6809,10 +6797,27 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
thin_name = origin_lv->name;
lp->voriginextents = origin_lv->le_count;
+
+ /*
+ * Check if using 'external origin' or the 'normal' snapshot
+ * within the same thin pool
+ */
+ if (first_seg(origin_lv)->pool_lv != pool_lv) {
+ if (!pool_supports_external_origin(first_seg(pool_lv), origin_lv))
+ return_NULL;
+ if (origin_lv->status & LVM_WRITE) {
+ log_error("Cannot use writable LV as the external origin.");
+ return NULL; // TODO conversion for inactive
+ }
+ if (lv_is_active(origin_lv) && !lv_is_external_origin(origin_lv)) {
+ log_error("Cannot use active LV for the external origin.");
+ return NULL; // We can't be sure device is read-only
+ }
+ }
}
} else if (lp->snapshot) {
if (!lp->voriginsize) {
- if (!(origin_lv = find_lv(vg, lp->origin_name))) {
+ if (!origin_lv) {
log_error("Couldn't find origin volume '%s'.",
lp->origin_name);
return NULL;
9 years, 6 months
master - lvm2app: update to new lv_create_single API
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=618d818c0d31bb...
Commit: 618d818c0d31bbfa1ed4af2e8954c8a4b53127af
Parent: 7916cae697aed7e9f8c286e4f9c6de3cb7ed5e88
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 07:25:30 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
lvm2app: update to new lv_create_single API
lv_create_single is more type based.
---
liblvm/lvm_lv.c | 25 +++++++++++--------------
python/liblvm.c | 14 +++++---------
2 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index f7f1596..49737d5 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -221,7 +221,6 @@ static int _lv_set_default_linear_params(struct cmd_context *cmd,
}
lp->stripes = 1;
- lp->stripe_size = DEFAULT_STRIPESIZE * 2;
return 1;
}
@@ -499,9 +498,7 @@ static int _lv_set_pool_params(struct lvcreate_params *lp,
vg_t vg, const char *pool_name,
uint64_t extents, uint64_t meta_size)
{
- _lv_set_default_params(lp, vg, NULL, extents);
-
- lp->pool_name = pool_name;
+ _lv_set_default_params(lp, vg, pool_name, extents);
lp->create_pool = 1;
lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool");
@@ -625,8 +622,8 @@ static int _lv_set_thin_params(struct lvcreate_params *lp,
}
static lv_create_params_t _lvm_lv_params_create_snapshot(const lv_t lv,
- const char *snap_name,
- uint64_t max_snap_size)
+ const char *snap_name,
+ uint64_t max_snap_size)
{
uint64_t size = 0;
uint64_t extents = 0;
@@ -652,24 +649,24 @@ static lv_create_params_t _lvm_lv_params_create_snapshot(const lv_t lv,
if (!size && !lv_is_thin_volume(lv) ) {
log_error("Origin is not thin, specify size of snapshot");
- return NULL;
+ return NULL;
}
lvcp = dm_pool_zalloc(lv->vg->vgmem, sizeof (struct lvm_lv_create_params));
if (lvcp) {
lvcp->vg = lv->vg;
_lv_set_default_params(&lvcp->lvp, lv->vg, snap_name, extents);
- lvcp->lvp.snapshot = 1;
-
if (size) {
- lvcp->lvp.segtype = _get_segtype(lvcp->vg->cmd);
+ if (!(lvcp->lvp.segtype = get_segtype_from_string(lv->vg->cmd, "snapshot"))) {
+ log_error("Segtype snapshot not found.");
+ return NULL;
+ }
lvcp->lvp.chunk_size = 8;
+ lvcp->lvp.snapshot = 1;
} else {
- lvcp->lvp.segtype = get_segtype_from_string(lv->vg->cmd, "thin");
-
- if (!lvcp->lvp.segtype) {
- log_error(INTERNAL_ERROR "Segtype thin not found.");
+ if (!(lvcp->lvp.segtype = get_segtype_from_string(lv->vg->cmd, "thin"))) {
+ log_error("Segtype thin not found.");
return NULL;
}
diff --git a/python/liblvm.c b/python/liblvm.c
index 094aec2..9983135 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -611,7 +611,10 @@ static PyObject *_liblvm_lvm_vg_close(vgobject *self)
{
/* if already closed, don't reclose it */
if (self->vg) {
- lvm_vg_close(self->vg);
+ if (lvm_vg_close(self->vg) == -1) {
+ PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
+ return NULL;
+ }
self->vg = NULL;
self->libh_copy = NULL;
}
@@ -647,14 +650,7 @@ static PyObject *_liblvm_lvm_vg_remove(vgobject *self)
goto error;
/* Not much you can do with a vg that is removed so close it */
- if (lvm_vg_close(self->vg) == -1)
- goto error;
-
- self->vg = NULL;
-
- Py_INCREF(Py_None);
-
- return Py_None;
+ return _liblvm_lvm_vg_close(self);
error:
PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
9 years, 6 months
master - vg_read: Remove unused READ_WITHOUT_LOCK.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7916cae697aed7...
Commit: 7916cae697aed7e9f8c286e4f9c6de3cb7ed5e88
Parent: c3bb9629a8e1cd786fad33def773873008bdc413
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 24 21:54:04 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Oct 24 21:54:04 2014 +0100
vg_read: Remove unused READ_WITHOUT_LOCK.
Unused since 67a7b7a87da65b2350f975272e581be5f41976e0:
report: Iterate over labels instead of PVs for label-only reports.
(included in 2.02.105).
---
lib/metadata/metadata-exported.h | 1 -
lib/metadata/metadata.c | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 7467b64..d05333c 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -145,7 +145,6 @@
/* vg_read and vg_read_for_update flags */
#define READ_ALLOW_INCONSISTENT 0x00010000U
#define READ_ALLOW_EXPORTED 0x00020000U
-#define READ_WITHOUT_LOCK 0x00040000U
#define READ_WARN_INCONSISTENT 0x00080000U
/* A meta-flag, useful with toollib for_each_* functions. */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 9308cb7..3e1b94a 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4256,7 +4256,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
already_locked = lvmcache_vgname_is_locked(vg_name);
- if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
+ if (!already_locked &&
!lock_vol(cmd, vg_name, lock_flags, NULL)) {
log_error("Can't get lock for %s", vg_name);
return _vg_make_handle(cmd, vg, FAILED_LOCKING);
@@ -4330,7 +4330,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
return _vg_make_handle(cmd, vg, failure);
bad:
- if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK))
+ if (!already_locked)
unlock_vg(cmd, vg_name);
bad_no_unlock:
9 years, 6 months
master - tests: syncaction needs kernel fix
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3bb9629a8e1cd...
Commit: c3bb9629a8e1cd786fad33def773873008bdc413
Parent: e1dede6f6b8b2d05e65acfda56ba3ec0d59f7619
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 10:52:57 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
tests: syncaction needs kernel fix
Add 'should' as we currently cannot pass this test.
FIXME:
Add properly wrapper to not use 'should' with fixed kernel.
---
test/shell/lvchange-raid.sh | 8 ++++++--
test/shell/lvchange-syncaction-raid.sh | 4 ++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index a0a0d2a..00b5265 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -167,11 +167,15 @@ run_syncaction_check() {
# 'lvs' should show results
lvchange --syncaction check $vg/$lv
aux wait_for_sync $vg $lv
+ # FIXME: this needs kernel fix in md-raid
+ # currently let just this test to cause 'warning'
if ! get lv_field $vg/$lv lv_attr -a | grep '.*m.$'; then
dmsetup status | grep $vg
- false
+ # false
fi
- not check lv_field $vg/$lv raid_mismatch_count "0"
+ # FIXME: with fixed kernel this should not fail
+ # add 'wrapper' detecting kernel for this
+ should not check lv_field $vg/$lv raid_mismatch_count "0"
# "repair" will fix discrepancies
lvchange --syncaction repair $vg/$lv
diff --git a/test/shell/lvchange-syncaction-raid.sh b/test/shell/lvchange-syncaction-raid.sh
index 18af83f..9a42894 100644
--- a/test/shell/lvchange-syncaction-raid.sh
+++ b/test/shell/lvchange-syncaction-raid.sh
@@ -37,7 +37,7 @@ lvchange -an $vg/$lv1
aux delay_dev "$dev2" 0 100
lvchange -ay $vg/$lv1
# noone has it open and target is read & running
-dmsetup info -c
+dmsetup info -c | grep $vg
#sleep 10 < "$DM_DEV_DIR/$vg/$lv1" &
# "check" should find discrepancies but not change them
@@ -49,7 +49,7 @@ dmsetup info -c
# For now it fails with:
# device-mapper: message ioctl on failed: Device or resource busy
#
-lvchange --syncaction check $vg/$lv1
+should lvchange --syncaction check $vg/$lv1
aux enable_dev "$dev2"
lvs -o+raid_mismatch_count -a $vg
9 years, 6 months
master - tests: new lvcreate functionality
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e1dede6f6b8b2d...
Commit: e1dede6f6b8b2d05e65acfda56ba3ec0d59f7619
Parent: 9642f013a104590b575badc024b887a02c7ad750
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 14:56:55 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
tests: new lvcreate functionality
Fixed syntax parsing means that some commands that used to work are now
failing. Particullary this case:
$ invalid lvcreate -l1 --type thin vg/pool
> Needs to fail becase thin type LV needs --virtualsize
$ invalid lvcreate --type snapshot vg/lv1
> Needs to fail because old-snapshot segment type needs --size
Some reported error messages have been also updated.
---
test/shell/lvcreate-cache.sh | 116 +++++++++++++++++++++++++++++---------
test/shell/lvcreate-thin-snap.sh | 13 +++-
test/shell/lvcreate-thin.sh | 26 +++++----
test/shell/snapshot-usage.sh | 2 +-
4 files changed, 116 insertions(+), 41 deletions(-)
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index 17b8c09..69d0534 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -12,7 +12,7 @@
# Exercise creation of cache and cache pool volumes
# Full CLI uses --type
-# Shorthand CLI uses --cache | -H
+# Shorthand CLI uses -H | --cache
. lib/inittest
@@ -21,58 +21,75 @@ aux have_cache 1 3 0 || skip
# FIXME: parallel cache metadata allocator is crashing when used value 8000!
aux prepare_vg 5 80000
+
#######################
# Cache_Pool creation #
#######################
-
-# FIXME: Unsupported yet creation of cache pool and cached volume at once
-# needs some policy to determine cache pool size
+# TODO: Unsupported yet creation of cache pool and cached volume at once
+# TODO: Introduce --pooldatasize
+# TODO: Policy to determine cache pool size and cache pool name
invalid lvcreate -H -l 1 $vg
-invalid lvcreate --cache -l 1 $vg
-invalid lvcreate --type cache -l 1 $vg
+invalid lvcreate -H -l 1 --name $lv1 $vg
+invalid lvcreate -l 1 --cache $vg
+# Only cached volume could be created
+invalid lvcreate -l 1 --type cache $vg
+# Fails as it needs to see VG content
+fail lvcreate -l 1 --type cache --cachepool $vg/pool1
+fail lvcreate -l 1 --type cache --cachepool pool2 $vg
+fail lvcreate -l 1 --cache $vg/pool3
+fail lvcreate -l 1 -H --cachepool pool4 $vg
+fail lvcreate -l 1 -H --name $lv2 $vg/pool5
+fail lvcreate -l 1 -H --name $lv3 --cachepool $vg/pool6
+fail lvcreate -l 1 -H --name $vg/$lv4 --cachepool pool7
-# Unlike in thin pool case - cache pool and cached volume both need size arg.
+# Unlike in thin pool case - cache pool and cache volume both need size arg.
# So we require cache pool to exist and need to fail when it's missing.
#
-# FIXME: introduce --poolsize to make this command possible to pass
-fail lvcreate -l 1 -H --cachepool $vg/pool3
-fail lvcreate -l 1 -H --cachepool pool4 $vg
-fail lvcreate -l 1 --type cache --cachepool $vg/pool5
-fail lvcreate -l 1 --type cache --cachepool pool6 $vg
-# --cachpool bring implicit --cache
-fail lvcreate -l 1 --cachepool pool7 $vg
+# --cachepool gives implicit --cache
+fail lvcreate -l 1 --cachepool pool8 $vg
+
+# no size specified
+invalid lvcreate --cachepool pool $vg |& tee err
+grep "specify either size or extents" err
# Check nothing has been created yet
check vg_field $vg lv_count 0
-# If the cache pool volume doesn't yet exist -> cache pool creation
-lvcreate -l 1 -H $vg/pool1
-lvcreate -l 1 --type cache $vg/pool2
-
-# With cache-pool we are clear what has to be created
-lvcreate -l 1 --type cache-pool $vg/pool3
-lvcreate -l 1 --type cache-pool --cachepool $vg/pool4
-lvcreate -l 1 --type cache-pool --cachepool pool5 $vg
-lvcreate -l 1 --type cache-pool --name pool6 $vg
-lvcreate -l 1 --type cache-pool --name $vg/pool7
+# With --type cache-pool we are clear which segtype has to be created
+lvcreate -l 1 --type cache-pool $vg/pool1
check lv_field $vg/pool1 segtype "cache-pool"
+lvcreate -l 1 --type cache-pool --name $vg/pool2 $vg
check lv_field $vg/pool2 segtype "cache-pool"
+lvcreate -l 1 --type cache-pool --cachepool $vg/pool3 $vg
check lv_field $vg/pool3 segtype "cache-pool"
+lvcreate -l 1 --type cache-pool --cachepool $vg/pool4
check lv_field $vg/pool4 segtype "cache-pool"
+lvcreate -l 1 --type cache-pool --cachepool pool5 $vg
check lv_field $vg/pool5 segtype "cache-pool"
+lvcreate -l 1 --type cache-pool --name pool6 $vg
check lv_field $vg/pool6 segtype "cache-pool"
+lvcreate -l 1 --type cache-pool --name $vg/pool7
check lv_field $vg/pool7 segtype "cache-pool"
lvremove -f $vg
+
# Validate ambiguous pool name is detected
invalid lvcreate -l 1 --type cache-pool --cachepool pool1 $vg/pool2
invalid lvcreate -l 1 --type cache-pool --name pool3 --cachepool pool4 $vg
invalid lvcreate -l 1 --type cache-pool --name pool6 --cachepool pool6 $vg/pool7
invalid lvcreate -l 1 --type cache-pool --name pool8 $vg/pool9
+
+# Unsupported with cache & cache pool
+invalid lvcreate --type cache-pool --discards passdown -l1 $vg
+invalid lvcreate -H --discards passdown -l1 $vg
+invalid lvcreate --type cache-pool --virtualsize 1T -l1 $vg
+invalid lvcreate -H --virtualsize 1T -l1 $vg
+
check vg_field $vg lv_count 0
+
for mode in "" "--cachemode writethrough"
do
@@ -114,6 +131,7 @@ lvremove -f $vg
done
+
# Conversion through lvcreate case
# Bug 1110026
# Create origin, then cache pool and cache the origin
@@ -141,14 +159,60 @@ grep "WARNING: Maximum" out
lvremove -f $vg
+########################################
+# Cache conversion and r/w permissions #
+########################################
+
+# writeable origin and 'default' => writable cache + origin
+lvcreate -an -l1 -n $vg/$lv1
+lvcreate -H -l1 -n cpool1 $vg/$lv1
+check lv_attr_bit perm $vg/cpool1 "w"
+check lv_attr_bit perm $vg/${lv1}_corig "w"
+check lv_attr_bit perm $vg/$lv1 "w"
+
+# writeable origin and -pr => conversion is not supported
+lvcreate -an -l1 -n $vg/$lv2
+fail lvcreate -H -l1 -pr -n cpool2 $vg/$lv2
+
+# read-only origin and -pr => read-only cache + origin
+lvcreate -an -pr -l1 -n $vg/$lv3
+lvcreate -an -H -l1 -pr -n cpool3 $vg/$lv3
+check lv_attr_bit perm $vg/cpool3 "w"
+check lv_attr_bit perm $vg/${lv3}_corig "r"
+check lv_attr_bit perm $vg/$lv3 "r"
+check inactive $vg $lv3
+check inactive $vg cpool3
+
+# read-only origin and 'default' => read-only cache + origin
+lvcreate -an -pr -l1 -n $vg/$lv4
+lvcreate -H -l1 -n cpool4 $vg/$lv4
+check lv_attr_bit perm $vg/cpool4 "w"
+check lv_attr_bit perm $vg/${lv4}_corig "r"
+check lv_attr_bit perm $vg/$lv4 "r"
+
+# read-only origin and -prw => conversion unsupported
+lvcreate -an -pr -l1 -n $vg/$lv5
+fail lvcreate -H -l1 -prw -n cpool5 $vg/$lv5
+
+# cached volume respects permissions
+lvcreate --type cache-pool -l1 -n $vg/cpool
+lvcreate -H -l1 -pr -n $lv6 $vg/cpool
+check lv_attr_bit perm $vg/cpool "w"
+check lv_attr_bit perm $vg/$lv6 "r"
+
+lvremove -f $vg
+
##############################
# Test things that should fail
##############################
+# Creation of read-only cache pool is not supported
+invalid lvcreate -pr --type cache-pool -l1 -n $vg/cpool
+
# Atempt to use bigger chunk size then cache pool data size
fail lvcreate -l 1 --type cache-pool --chunksize 16M $vg 2>out
-grep "is bigger" out
+grep "chunk size" out
# Option testing
# --chunksize
@@ -158,7 +222,7 @@ grep "is bigger" out
lvremove -f $vg
lvcreate -n corigin -m 1 --type raid1 -l 10 $vg
-lvcreate -n cpool --type cache $vg/corigin -l 10
+lvcreate -n cpool -H $vg/corigin -l 10
check active $vg corigin_corig
dmsetup table | grep ^$PREFIX | grep corigin_corig
diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh
index 6f29a28..784eb5d 100644
--- a/test/shell/lvcreate-thin-snap.sh
+++ b/test/shell/lvcreate-thin-snap.sh
@@ -41,9 +41,16 @@ lvcreate -K -s $vg/$lv1 -pr --name snap
fsck -n "$DM_DEV_DIR/$vg/snap"
lvcreate -K -s $vg/$lv1 --name $lv2
lvcreate -K -s $vg/$lv1 --name $vg/$lv3
-lvcreate --type snapshot $vg/$lv1
-lvcreate --type snapshot $vg/$lv1 --name $lv4
-lvcreate --type snapshot $vg/$lv1 --name $vg/$lv5
+# old-snapshot without known size is invalid
+invalid lvcreate --type snapshot $vg/$lv1
+invalid lvcreate --type snapshot $vg/$lv1 --name $lv4
+invalid lvcreate --type snapshot $vg/$lv1 --name $vg/$lv5
+# some other ways how to take a thin snapshot
+lvcreate -T $vg/$lv1
+lvcreate --thin $vg/$lv1 --name $lv4
+lvcreate --type thin $vg/$lv1 --name $vg/$lv5
+# virtual size needs thin pool
+fail lvcreate --type thin $vg/$lv1 -V20
# create old-style snapshot
lvcreate -s -L10M --name oldsnap1 $vg/$lv2
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index 16eb1e7..619a40c 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -39,14 +39,14 @@ vgcreate $vg -s 64K $(cat DEVICES)
lvcreate -l1 -T $vg/pool1
lvcreate -l1 -T --thinpool $vg/pool2
lvcreate -l1 -T --thinpool pool3 $vg
-lvcreate -l1 --type thin $vg/pool4
-lvcreate -l1 --type thin --thinpool $vg/pool5
-lvcreate -l1 --type thin --thinpool pool6 $vg
+invalid lvcreate -l1 --type thin $vg/pool4
+invalid lvcreate -l1 --type thin --thinpool $vg/pool5
+invalid lvcreate -l1 --type thin --thinpool pool6 $vg
lvcreate -l1 --type thin-pool $vg/pool7
lvcreate -l1 --type thin-pool --thinpool $vg/pool8
lvcreate -l1 --type thin-pool --thinpool pool9 $vg
-lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 $vg/pool7 $vg/pool8 $vg/pool9
+lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool7 $vg/pool8 $vg/pool9
check vg_field $vg lv_count 0
@@ -56,6 +56,10 @@ invalid lvcreate --type thin-pool -l1 --name pool1 $vg/pool2
invalid lvcreate --type thin-pool -l1 --name pool3 --thinpool pool4 $vg
invalid lvcreate --type thin-pool -l1 --name pool5 --thinpool pool6 $vg/pool7
invalid lvcreate --type thin-pool -l1 --name pool8 --thinpool pool8 $vg/pool9
+
+# no size specified and no origin name give for snapshot
+invalid lvcreate --thinpool pool $vg
+
check vg_field $vg lv_count 0
lvcreate --type thin-pool -l1 --name pool1 $vg
@@ -76,7 +80,7 @@ lvremove -ff $vg
# Create default pool name
lvcreate -l1 -T $vg
-lvcreate -l1 --type thin $vg
+invalid lvcreate -l1 --type thin $vg
lvcreate -l1 --type thin-pool $vg
lvremove -ff $vg
@@ -98,7 +102,7 @@ lvcreate -L4M -V2G --name lvo4 --type thin $vg/pool4
lvcreate -L4M -V2G --name lvo5 --type thin --thinpool $vg/pool5
lvcreate -L4M -V2G --name lvo6 --type thin --thinpool pool6 $vg
-check lv_exists $vg lvo1 lvo2 lvo3 lvo4 lvo5 lvo6
+check lv_exists $vg lvo1 lvo2 lvo3
lvremove -ff $vg
@@ -165,13 +169,13 @@ lvcreate -K -s $vg/lv1 --name snap_lv1
fsck -n "$DM_DEV_DIR/$vg/snap_lv1"
lvcreate -s $vg/lv1 --name lv2
lvcreate -s $vg/lv1 --name $vg/lv3
-lvcreate --type snapshot $vg/lv1 --name lv6
-lvcreate --type snapshot $vg/lv1 --name lv4
-lvcreate --type snapshot $vg/lv1 --name $vg/lv5
+invalid lvcreate --type snapshot $vg/lv1 --name lv6
+invalid lvcreate --type snapshot $vg/lv1 --name lv4
+invalid lvcreate --type snapshot $vg/lv1 --name $vg/lv5
lvdisplay --maps $vg
-check_lv_field_modules_ thin,thin-pool lv1 snap_lv1 lv2 lv3 lv4 lv5 lv6
-check vg_field $vg lv_count 8
+check_lv_field_modules_ thin,thin-pool lv1 snap_lv1 lv2 lv3
+check vg_field $vg lv_count 5
lvremove -ff $vg
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index dcf2886..c29d310 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -69,7 +69,7 @@ vgcreate -s 4M $vg $(cat DEVICES)
lvcreate -aey -l1 -n $lv $vg
# 100%LV is not supported for snapshot
fail lvcreate -s -l 100%LV -n snap $vg/$lv |& tee out
-grep 'Please express size as %ORIGIN, %VG, %PVS, or %FREE' out
+grep 'Please express size as %FREE, %ORIGIN, %PVS or %VG' out
# 100%ORIGIN needs to have enough space for all data and needs to round-up
lvcreate -s -l 100%ORIGIN -n $lv1 $vg/$lv
# everything needs to fit
9 years, 6 months
master - tests: lvcreate usage
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9642f013a10459...
Commit: 9642f013a104590b575badc024b887a02c7ad750
Parent: 11ea72cfd872d4a54e7db52e347688039378bc72
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 11 09:12:56 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
tests: lvcreate usage
---
test/shell/lvcreate-usage.sh | 159 ++++++++++++++++++++++++++----------------
1 files changed, 98 insertions(+), 61 deletions(-)
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index 7ae6d25..c2b7112 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -17,62 +17,70 @@ aux prepare_pvs 4
aux pvcreate --metadatacopies 0 "$dev1"
vgcreate $vg $(cat DEVICES)
-# "lvcreate rejects repeated invocation (run 2 times) (bz178216)"
-lvcreate -n $lv -l 4 $vg
+invalid lvcreate --type free -l1 -n $lv1 $vg 2>err
+grep "Invalid argument for --type" err
+invalid lvcreate --type $RANDOM -l1 -n $lv1 $vg
+invalid lvcreate --type unknown -l1 -n $lv1 $vg
+
+lvcreate --type linear -aey -l1 -n $lv1 $vg
+lvcreate --type snapshot -l1 -n $lv2 $vg/$lv1
+
+# Reject repeated invocation (run 2 times) (bz178216)
+lvcreate -n $lv -l 4 $vg
not lvcreate -n $lv -l 4 $vg
lvremove -ff $vg/$lv
-# try to remove it again - should fail (but not segfault)
+# Try to remove it again - should fail (but not segfault)
not lvremove -ff $vg/$lv
-# "lvcreate rejects a negative stripe_size"
-not lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err;
-grep "Negative stripesize is invalid" err
+# Reject a negative stripe_size
+invalid lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err;
+grep "may not be negative" err
-# 'lvcreate rejects a too-large stripesize'
-not lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err
+# Reject a too-large stripesize
+invalid lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err
grep "Stripe size cannot be larger than" err
-# 'lvcreate w/single stripe succeeds with diagnostics to stdout'
+# w/single stripe succeeds with diagnostics to stdout
lvcreate -L 64m -n $lv -i1 --stripesize 4 $vg 2> err | tee out
grep "Ignoring stripesize argument with single stripe" out
-lvdisplay $vg
+lvdisplay $vg
lvremove -ff $vg
-# 'lvcreate w/default (64KB) stripe size succeeds with diagnostics to stdout'
+# w/default (64KB) stripe size succeeds with diagnostics to stdout
lvcreate -L 64m -n $lv -i2 $vg > out
grep "Using default stripesize" out
-lvdisplay $vg
+lvdisplay $vg
check lv_field $vg/$lv stripesize "64.00k"
lvremove -ff $vg
-# 'lvcreate rejects an invalid number of stripes'
-not lvcreate -L 64m -n $lv -i129 $vg 2>err
+# Reject an invalid number of stripes
+invalid lvcreate -L 64m -n $lv -i129 $vg 2>err
grep "Number of stripes (129) must be between 1 and 128" err
-# The case on lvdisplay output is to verify that the LV was not created.
-# 'lvcreate rejects an invalid stripe size'
-not lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err
+# Reject an invalid stripe size
+invalid lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err
grep "Invalid stripe size" err
+# Verify that the LV was not created via lvdisplay empty output
test -z "$(lvdisplay $vg)"
# Setting max_lv works. (bz490298)
-lvremove -ff $vg
+check vg_field $vg max_lv "0"
vgchange -l 3 $vg
+check vg_field $vg max_lv "3"
lvcreate -aey -l1 -n $lv1 $vg
lvcreate -l1 -s -n $lv2 $vg/$lv1
lvcreate -l1 -n $lv3 $vg
-not lvcreate -l1 -n $lv4 $vg
-
+fail lvcreate -l1 -n $lv4 $vg
lvremove -ff $vg/$lv3
-# check snapshot of inactive origin
+
+# Check snapshot of inactive origin
lvchange -an $vg/$lv1
lvcreate -l1 -s -n $lv3 $vg/$lv1
-not lvcreate -l1 -n $lv4 $vg
-not lvcreate -l1 --type mirror -m1 -n $lv4 $vg
+fail lvcreate -l1 -n $lv4 $vg
+fail lvcreate -l1 --type mirror -m1 -n $lv4 $vg
lvremove -ff $vg/$lv3
lvcreate -aey -l1 --type mirror -m1 -n $lv3 $vg
-vgs -o +max_lv $vg
not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 --type mirror -m1 -n $lv4 $vg
@@ -80,17 +88,17 @@ lvconvert -m0 $vg/$lv3
lvconvert -m2 --type mirror -i 1 $vg/$lv3
lvconvert -m1 $vg/$lv3
-not vgchange -l 2
+fail vgchange -l 2
+check vg_field $vg max_lv "3"
vgchange -l 4
-vgs $vg
+check vg_field $vg max_lv "4"
lvremove -ff $vg
vgchange -l 0 $vg
+check vg_field $vg max_lv "0"
-# lvcreate rejects invalid chunksize, accepts between 4K and 512K
-# validate origin_size
-vgremove -ff $vg
-vgcreate $vg $(cat DEVICES)
+# Rejects invalid chunksize, accepts between 4K and 512K
+# and validate origin_size
lvcreate -aey -L 32m -n $lv1 $vg
not lvcreate -L 8m -n $lv2 -s --chunksize 3k $vg/$lv1
not lvcreate -L 8m -n $lv2 -s --chunksize 1024k $vg/$lv1
@@ -100,25 +108,29 @@ check lv_field $vg/$lv2 origin_size "32.00m"
lvcreate -L 8m -n $lv3 -s --chunksize 512k $vg/$lv1
check lv_field $vg/$lv3 chunk_size "512.00k"
check lv_field $vg/$lv3 origin_size "32.00m"
-lvremove -ff $vg
-vgchange -l 0 $vg
+lvremove -f $vg
-# regionsize must be
+# Mirror regionsize must be
# - nonzero (bz186013)
# - a power of 2 and a multiple of page size
# - <= size of LV
-not lvcreate -L 32m -n $lv -R0 $vg 2>err
-grep "Non-zero region size must be supplied." err
-not lvcreate -L 32m -n $lv -R 11k $vg
-not lvcreate -L 32m -n $lv -R 1k $vg
+invalid lvcreate -m 1 -L 32m -n $lv -R 0 $vg 2>err
+grep "may not be zero" err
+invalid lvcreate -m 1 -L 32m -n $lv -R 11k $vg
+invalid lvcreate -m 1 -L 32m -n $lv -R 1k $vg
lvcreate -aey -L 32m -n $lv --regionsize 128m --type mirror -m 1 $vg
check lv_field $vg/$lv regionsize "32.00m"
-lvremove -ff $vg
+lvremove -f $vg
lvcreate -aey -L 32m -n $lv --regionsize 4m --type mirror -m 1 $vg
check lv_field $vg/$lv regionsize "4.00m"
+
+# -m0 is creating non-mirrored segment and give info about redundant option
+lvcreate -m 0 -l1 -n $lv1 $vg |& tee err
+grep "Redundant" err
+check lv_field $vg/$lv1 segtype "linear"
lvremove -ff $vg
-# snapshot with virtual origin works
+# Snapshot with virtual origin works
lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
lvrename $vg/$lv1 $vg/$lv2
lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
@@ -127,30 +139,50 @@ lvremove -ff $vg/$lv1
lvremove -ff $vg
# readahead default (auto), none, #, auto
-lvcreate -L 32m -n $lv $vg
-check lv_field $vg/$lv lv_read_ahead "auto"
-lvremove -ff $vg
-lvcreate -L 32m -n $lv --readahead none $vg
-check lv_field $vg/$lv lv_read_ahead "0"
-check lv_field $vg/$lv lv_kernel_read_ahead "0"
-lvremove -ff $vg
-lvcreate -L 32m -n $lv --readahead 8k $vg
-check lv_field $vg/$lv lv_read_ahead "8.00k"
-check lv_field $vg/$lv lv_kernel_read_ahead "8.00k"
-lvremove -ff $vg
-lvcreate -L 32m -n $lv --readahead auto $vg
-check lv_field $vg/$lv lv_read_ahead "auto"
-check lv_field $vg/$lv lv_kernel_read_ahead "128.00k"
-lvremove -ff $vg
-lvcreate -L 32m -n $lv -i2 --stripesize 16k --readahead auto $vg
-check lv_field $vg/$lv lv_read_ahead "auto"
-check lv_field $vg/$lv lv_kernel_read_ahead "128.00k"
-lvremove -ff $vg
-lvcreate -L 32m -n $lv -i2 --stripesize 128k --readahead auto $vg
-check lv_field $vg/$lv lv_read_ahead "auto"
-check lv_field $vg/$lv lv_kernel_read_ahead "512.00k"
+lvcreate -L 8 -n $lv1 $vg
+check lv_field $vg/$lv1 lv_read_ahead "auto"
+lvcreate -L 8 -n $lv2 --readahead none $vg
+check lv_field $vg/$lv2 lv_read_ahead "0"
+check lv_field $vg/$lv2 lv_kernel_read_ahead "0"
+lvcreate -L 8 -n $lv3 --readahead 8k $vg
+check lv_field $vg/$lv3 lv_read_ahead "8.00k"
+check lv_field $vg/$lv3 lv_kernel_read_ahead "8.00k"
+lvcreate -L 8 -n $lv4 --readahead auto $vg
+check lv_field $vg/$lv4 lv_read_ahead "auto"
+check lv_field $vg/$lv4 lv_kernel_read_ahead "128.00k"
+lvcreate -L 8 -n $lv5 -i2 --stripesize 16k --readahead auto $vg
+check lv_field $vg/$lv5 lv_read_ahead "auto"
+check lv_field $vg/$lv5 lv_kernel_read_ahead "128.00k"
+lvcreate -L 8 -n $lv6 -i2 --stripesize 128k --readahead auto $vg
+check lv_field $vg/$lv6 lv_read_ahead "auto"
+check lv_field $vg/$lv6 lv_kernel_read_ahead "512.00k"
lvremove -ff $vg
+#
+# Validate --major --minor, we need to know VG, thus failing
+#
+fail lvcreate -My --major 234 -l1 $vg
+# cannot specify --major or --minor with -Mn
+fail lvcreate -Mn --major 234 -l1 $vg
+fail lvcreate --persistent n --minor 234 -l1 $vg
+# out-of-range minor value
+fail lvcreate --minor 9999999 -l1 $vg
+if kernel_at_least 2 4 0; then
+# On >2.4 we ignore --major
+lvcreate --major 234 -l1 $vg |& tee err;
+grep "Ignoring" err
+# Try some bigger possibly unused minor
+if test ! -d /sys/block/dm-2345; then
+ lvcreate --minor 2345 -l1 -n $lv1 $vg
+ check lv_field $vg/$lv1 lv_kernel_minor "2345"
+fi
+if test ! -d /sys/block/dm-23456; then
+ lvcreate -My --minor 23456 -j 122 -l1 -n $lv2 $vg
+ check lv_field $vg/$lv2 lv_kernel_minor "23456"
+fi
+fi # 2.4
+lvremove -f $vg
+
# prohibited names
for i in pvmove snapshot ; do
invalid lvcreate -l1 -n ${i}1 $vg
@@ -158,3 +190,8 @@ done
for i in _cdata _cmeta _mimage _mlog _pmspare _tdata _tmeta _vorigin ; do
invalid lvcreate -l1 -n s_${i}_1 $vg
done
+
+# Check invalid error for pool-only options
+invalid lvcreate --poolmetadataspare y -l1 $vg
+invalid lvcreate --poolmetadatasize 10 -l1 $vg
+invalid lvcreate --discards passdown -l1 $vg
9 years, 6 months
master - mirror: extra parsing for mirrorlog arg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11ea72cfd872d4...
Commit: 11ea72cfd872d4a54e7db52e347688039378bc72
Parent: 29c14a11943d52e47424140ffa3b91dc9b095bc5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 21:02:29 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
mirror: extra parsing for mirrorlog arg
Put validation of mirrorlog arg into a separate function.
---
lib/config/defaults.h | 2 +-
lib/metadata/metadata-exported.h | 8 ++++++++
lib/metadata/mirror.c | 27 +++++++++++++++++++++++++++
tools/args.h | 2 +-
tools/lvconvert.c | 23 ++++-------------------
tools/lvcreate.c | 19 ++++---------------
tools/lvmcmdline.c | 13 +++++++++++++
tools/tools.h | 1 +
8 files changed, 59 insertions(+), 36 deletions(-)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 2cb1e5a..2724cd1 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -53,7 +53,7 @@
#define DEFAULT_LVDISPLAY_SHOWS_FULL_DEVICE_PATH 0
#define DEFAULT_MIRROR_SEGTYPE "raid1"
-#define DEFAULT_MIRRORLOG "disk"
+#define DEFAULT_MIRRORLOG MIRROR_LOG_DISK
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
#define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
#define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 19508ab..7467b64 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -225,6 +225,12 @@ typedef enum {
DONT_PROMPT_OVERRIDE = 2 /* Add even more dangerous prompts */
} force_t;
+enum {
+ MIRROR_LOG_CORE,
+ MIRROR_LOG_DISK,
+ MIRROR_LOG_MIRRORED,
+};
+
typedef enum {
THIN_DISCARDS_IGNORE,
THIN_DISCARDS_NO_PASSDOWN,
@@ -1003,6 +1009,8 @@ int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
uint32_t mirrors, uint32_t log_count,
int (*is_removable)(struct logical_volume *, void *),
void *removable_baton, uint64_t status_mask);
+int get_mirror_log_count(const char *mirrorlog, int *log_count);
+const char *get_mirror_log_name(int log_count);
int is_temporary_mirror_layer(const struct logical_volume *lv);
struct logical_volume * find_temporary_mirror(const struct logical_volume *lv);
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index d89e5cd..a943ac4 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -2273,3 +2273,30 @@ int lv_remove_mirrors(struct cmd_context *cmd __attribute__((unused)),
return remove_mirrors_from_segments(lv, new_mirrors, status_mask);
}
+int get_mirror_log_count(const char *mirrorlog, int *log_count)
+{
+ if (!strcmp("core", mirrorlog))
+ *log_count = MIRROR_LOG_CORE;
+ else if (!strcmp("disk", mirrorlog))
+ *log_count = MIRROR_LOG_DISK;
+ else if (!strcmp("mirrored", mirrorlog))
+ *log_count = MIRROR_LOG_MIRRORED;
+ else {
+ log_error("Mirror log type \"%s\" is unknown.", mirrorlog);
+ return 0;
+ }
+
+ return 1;
+}
+
+const char *get_mirror_log_name(int log_count)
+{
+ switch (log_count) {
+ case MIRROR_LOG_CORE: return "core";
+ case MIRROR_LOG_DISK: return "disk";
+ case MIRROR_LOG_MIRRORED: return "mirrored";
+ default:
+ log_error(INTERNAL_ERROR "Unknown mirror log count %d.", log_count);
+ return "unknown";
+ }
+}
diff --git a/tools/args.h b/tools/args.h
index 4a4845f..000af01 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -55,7 +55,7 @@ arg(metadataprofile_ARG, '\0', "metadataprofile", string_arg, 0)
arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
arg(minor_ARG, '\0', "minor", int_arg, ARG_GROUPABLE)
arg(minrecoveryrate_ARG, '\0', "minrecoveryrate", size_kb_arg, 0)
-arg(mirrorlog_ARG, '\0', "mirrorlog", string_arg, 0)
+arg(mirrorlog_ARG, '\0', "mirrorlog", mirrorlog_arg, 0)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL, 0)
arg(mknodes_ARG, '\0', "mknodes", NULL, 0)
arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c792986..6d6d305 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1265,7 +1265,6 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
uint32_t *new_log_count)
{
int repair = arg_count(cmd, repair_ARG);
- const char *mirrorlog;
*old_mimage_count = lv_mirror_count(lv);
*old_log_count = _get_log_count(lv);
@@ -1334,33 +1333,19 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
if (!arg_count(cmd, corelog_ARG) && !arg_count(cmd, mirrorlog_ARG))
return 1;
- if (arg_count(cmd, corelog_ARG))
- *new_log_count = 0;
-
- mirrorlog = arg_str_value(cmd, mirrorlog_ARG,
- !*new_log_count ? "core" : DEFAULT_MIRRORLOG);
-
- if (!strcmp("mirrored", mirrorlog))
- *new_log_count = 2;
- else if (!strcmp("disk", mirrorlog))
- *new_log_count = 1;
- else if (!strcmp("core", mirrorlog))
- *new_log_count = 0;
- else {
- log_error("Unknown mirrorlog type: %s", mirrorlog);
- return 0;
- }
+ *new_log_count = arg_int_value(cmd, mirrorlog_ARG,
+ arg_is_set(cmd, corelog_ARG) ? MIRROR_LOG_CORE : DEFAULT_MIRRORLOG);
/*
* No mirrored logs for cluster mirrors until
* log daemon is multi-threaded.
*/
- if ((*new_log_count == 2) && vg_is_clustered(lv->vg)) {
+ if ((*new_log_count == MIRROR_LOG_MIRRORED) && vg_is_clustered(lv->vg)) {
log_error("Log type, \"mirrored\", is unavailable to cluster mirrors");
return 0;
}
- log_verbose("Setting logging type to %s", mirrorlog);
+ log_verbose("Setting logging type to %s", get_mirror_log_name(*new_log_count));
/*
* Region size must not change on existing mirrors
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 45f432e..199636c 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -428,27 +428,16 @@ static int _read_size_params(struct cmd_context *cmd,
static int _read_mirror_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
- int corelog = arg_count(cmd, corelog_ARG);
- const char *mirrorlog = arg_str_value(cmd, mirrorlog_ARG, corelog
- ? "core" : DEFAULT_MIRRORLOG);
-
- if (!strcmp("mirrored", mirrorlog))
- lp->log_count = 2;
- else if (!strcmp("disk", mirrorlog))
- lp->log_count = 1;
- else if (!strcmp("core", mirrorlog)) {
- lp->log_count = 0;
- } else {
- log_error("Unknown mirrorlog type: %s", mirrorlog);
- return 0;
- }
+ int corelog = arg_is_set(cmd, corelog_ARG);
+
+ lp->log_count = arg_int_value(cmd, mirrorlog_ARG, corelog ? 0 : DEFAULT_MIRRORLOG);
if (corelog && (lp->log_count != 0)) {
log_error("Please use only one of --corelog or --mirrorlog.");
return 0;
}
- log_verbose("Setting logging type to %s", mirrorlog);
+ log_verbose("Setting logging type to %s", get_mirror_log_name(lp->log_count));
return 1;
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index bbf0145..c426873 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -327,6 +327,19 @@ int discards_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_val
return 1;
}
+int mirrorlog_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av)
+{
+ int log_count;
+
+ if (!get_mirror_log_count(av->value, &log_count))
+ return_0;
+
+ av->i_value = log_count;
+ av->ui_value = log_count;
+
+ return 1;
+}
+
int metadatatype_arg(struct cmd_context *cmd, struct arg_values *av)
{
return get_format_by_name(cmd, av->value) ? 1 : 0;
diff --git a/tools/tools.h b/tools/tools.h
index 75c3eaa..5a5d729 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -126,6 +126,7 @@ void usage(const char *name);
int yes_no_arg(struct cmd_context *cmd, struct arg_values *av);
int activation_arg(struct cmd_context *cmd, struct arg_values *av);
int discards_arg(struct cmd_context *cmd, struct arg_values *av);
+int mirrorlog_arg(struct cmd_context *cmd, struct arg_values *av);
int size_kb_arg(struct cmd_context *cmd, struct arg_values *av);
int size_mb_arg(struct cmd_context *cmd, struct arg_values *av);
int int_arg(struct cmd_context *cmd, struct arg_values *av);
9 years, 6 months
master - man: lvconvert/create updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=29c14a11943d52...
Commit: 29c14a11943d52e47424140ffa3b91dc9b095bc5
Parent: fd00d2c6eceb6536208558561a02d464d1808469
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 7 14:48:38 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
man: lvconvert/create updates
More description for cache support.
Introduce --pooldatasize option.
---
WHATS_NEW | 1 +
man/lvconvert.8.in | 32 +++-
man/lvcreate.8.in | 486 +++++++++++++++++++++++++++++++---------------------
3 files changed, 314 insertions(+), 205 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1bdb884..5ad246c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Update and correct lvcreate and lvcovert man pages.
Mark pools and snapshots as unzeroable volumes.
Check for zeroing of volume after segment type is fully detected.
Better support for persistent major and minor options with lvcreate.
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index b08e420..bf699ee 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -153,8 +153,11 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.B lvconvert
.RB [ \-\-type
.BR \fIcache [ \fI\-pool ]| \-H | \-\-cache ]
-.RB [ \-\-cachepool
+.RB [{ \-\-cachepool
.IR CachePoolLogicalVolume { Name | Path }]
+|
+.B \-\-pooldatasize
+.IR CachePoolMetadataSize [ bBsSkKmMgGtTpPeE ]}]
.RB [ \-c | \-\-chunksize
.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-cachemode
@@ -304,13 +307,13 @@ Separates \fISplitableLogicalVolume\fP.
Option is agregating various split commands and tries to detect necessary split
operation from its arguments.
.TP
-.BR \-\-splitcache ", " \-\-uncache
+.BR \-\-splitcache
Separates \fICacheLogicalVolume\fP from cache pool.
-Before volume becomes uncached, cache is flushed.
-With \-\-split the cache pool volume is then left unused and
-could be i.e. used for caching other volumes.
-The inverse of \-\-cache is \-\-uncache where the cache pool
-component volumes are automatically removed.
+Before the logical volume becomes uncached, cache is flushed.
+The cache pool volume is then left unused and
+could be used e.g. to caching another volume.
+See also the option \fB\-\-uncache\fP for uncaching and removing
+cache pool with one command.
.TP
.B \-\-splitsnapshot
Separates \fISnapshotLogicalVolume\fP from its origin.
@@ -347,6 +350,7 @@ until thin target version 1.5.)
.BR \-\-discards " {" \fIignore | \fInopassdown | \fIpassdown }
Specifies whether or not discards will be processed by the thin layer in the
kernel and passed down to the Physical Volume.
+Options is currently supported only with thin pools.
Default is \fIpassdown\fP.
.TP
.BR \-Z ", " \-\-zero " {" \fIy | \fIn }
@@ -382,6 +386,10 @@ Without this option a default name of "lvol<n>" will be generated where
This volume will be read-only and cannot be further modified as long,
as it is being used as the external origin.
.TP
+.IR \fB\-\-pooldatasize " " PoolDataVolumeSize [ bBsSkKmMgGtTpPeE ]
+Sets the size of pool's data logical volume.
+The option \fB\-\-size\fP could be still used with thin pools.
+.TP
.BR \-\-poolmetadata " " \fIPoolMetadataLogicalVolume { \fIName | \fIPath }
Specifies cache or thin pool metadata logical volume.
The size should be in between 2MiB and 16GiB.
@@ -450,7 +458,7 @@ available in "<pool>_meta<n>" LV.
Remove the specified device (\fIPhysicalVolume\fP) and replace it with one
that is available in the volume group or from the specific list provided.
This option is only available to RAID segment types
-(e.g.
+(e.g.
.IR raid1 ,
.IR raid5 ,
etc).
@@ -483,6 +491,12 @@ Content of converted volume is lost.
Thin pool's metadata logical volume can be specified with the option
\fB\-\-poolmetadata\fP or allocated with \fB\-\-poolmetadatasize\fP.
See \fBlvmthin\fP(7) for more info about thin provisioning support.
+.TP
+.BR \-\-uncache
+Uncaches \fICacheLogicalVolume\fP.
+Before the volume becomes uncached, cache is flushed.
+Unlike with \fB\-\-splitcache\fP the cache pool volume is removed.
+This option could seen as an inverse of \fB\-\-cache\fP.
.SH Examples
Converts the linear logical volume "vg00/lvol1" to a two-way mirror
@@ -593,7 +607,7 @@ given cache metadata LV.
Convert an existing logical volume to a cache LV using the given
cache pool LV and chunk size 128KiB.
.sp
-.B lvconvert \-\-cache \-\-cachepool vg00/lvx_cachepool -c 128 vg00/lvx
+.B lvconvert \-\-cache \-\-cachepool vg00/lvx_cachepool -c 128 vg00/lvx
.sp
Detach cache pool from an existing cached logical volume "vg00/lvol1" and
leave cache pool unused.
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index ed0ed65..c843949 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -3,101 +3,107 @@
lvcreate \- create a logical volume in an existing volume group
.SH SYNOPSIS
.B lvcreate
+.RB [ \-a | \-\-activate
+.RI [ a | e | l ]{ y | n }]
.RB [ \-\-addtag
.IR Tag ]
.RB [ \-\-alloc
.IR AllocationPolicy ]
-.RB [ \-a | \-\-activate
-.RI [ a | e | l ]{ y | n }]
-.RB [ \-k | \-\-setactivationskip
-.RI { y | n }]
-.RB [ \-K | \-\-ignoreactivationskip ]
.RB [ \-A | \-\-autobackup
.RI { y | n }]
+.RB [ \-H | \-\-cache ]
+.RB [ \-\-cachemode
+.RI { writeback | writethrough }]
+.RB [ \-\-cachepool
+.IR CachePoolLogicalVolume { Name | Path }
+.RB [ \-c | \-\-chunksize
+.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-C | \-\-contiguous
.RI { y | n }]
.RB [ \-d | \-\-debug ]
-.RB [ \-h | \-? | \-\-help ]
-.RB [ \-\-noudevsync ]
-.RB [ \-\-ignoremonitoring ]
-.RB [ \-\-metadataprofile
-.IR ProfileName ]
-.RB [ \-\-monitor
-.RI { y | n }]
-.RB [ \-\-[raid]maxrecoveryrate
-.IR Rate ]
-.RB [ \-\-[raid]minrecoveryrate
-.IR Rate ]
+.RB [ \-\-discards
+.RI { ignore | nopassdown | passdown }]
+.RB [{ \-l | \-\-extents
+.IR LogicalExtentsNumber [ % { FREE | PVS | VG }]
+|
+.BR \-L | \-\-size
+.IR LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]}
.RB [ \-i | \-\-stripes
.IR Stripes
.RB [ \-I | \-\-stripesize
-.IR StripeSize ]]
-.RB {[ \-l | \-\-extents
-.IR LogicalExtentsNumber [ % { VG | PVS | FREE }]
-|
-.BR \-L | \-\-size
-.IR LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]]
-|
-.BR \-V | \-\-virtualsize
-.IR VirtualSize [ bBsSkKmMgGtTpPeE ]}
-.RB [ \-M | \-\-persistent
-.RI { y | n }
+.IR StripeSize ]]]
+.RB [ \-h | \-? | \-\-help ]
+.RB [ \-K | \-\-ignoreactivationskip ]
+.RB [ \-\-ignoremonitoring ]
.RB [ \-\-minor
-.IR minor ]
-.RB [ \-\-major
+.IR minor
+.RB [ \-j | \-\-major
.IR major ]]
+.RB [ \-\-metadataprofile
+.IR ProfileName ]
.RB [ \-m | \-\-mirrors
.IR Mirrors
-.RB [ \-\-nosync ]
-.RB [ \-\-mirrorlog
-.RI { disk | core | mirrored }
+.RB [{ \-\-corelog
|
-.BR \-\-corelog ]
+.B \-\-mirrorlog
+.RI { disk | core | mirrored }}]
+.RB [ \-\-nosync ]
.RB [ \-R | \-\-regionsize
-.IR MirrorLogRegionSize ]]
+.IR MirrorLogRegionSize [ bBsSkKmMgG ]]]
+.RB [ \-\-monitor
+.RI { y | n }]
.RB [ \-n | \-\-name
.IR LogicalVolume { Name | Path }]
+.RB [ \-\-noudevsync ]
.RB [ \-p | \-\-permission
.RI { r | rw }]
-.RB [ \-r | \-\-readahead
-.RI { ReadAheadSectors | auto | none }]
-.RB [ \-t | \-\-test ]
-.RB [ \-T | \-\-thin
-.RB [ \-\-cachemode
-.RI { writeback | writethrough }
-.RB [ \-c | \-\-chunksize
-.IR ChunkSize [ bBsSkKmMgG ]]
-.RB [ \-\-discards
-.RI { ignore | nopassdown | passdown }]
+.RB [ \-M | \-\-persistent
+.RI { y | n }
+.RB [ \-\-pooldatasize
+.IR DataVolumeSize [ bBsSkKmMgGtTpPeE ]]
.RB [ \-\-poolmetadatasize
.IR MetadataVolumeSize [ bBsSkKmMgG ]]
.RB [ \-\-poolmetadataspare
-.RI { y | n }]]
-.RB [ \-\-thinpool
-.IR ThinPoolLogicalVolume { Name | Path }
+.RI { y | n }]
+.RB [ \-\- [ raid ] maxrecoveryrate
+.IR Rate ]
+.RB [ \-\- [ raid ] minrecoveryrate
+.IR Rate ]
+.RB [ \-r | \-\-readahead
+.RI { ReadAheadSectors | auto | none }]
+.RB [ \-k | \-\-setactivationskip
+.RI { y | n }]
.RB [ \-s | \-\-snapshot
-.RI [ VolumeGroup { Name | Path }/]
-.IR ExternalOriginLogicalVolumeName ]]
+.RB [ \-V | \-\-virtualsize
+.IR VirtualSize [ bBsSkKmMgGtTpPeE ]]
+.RB [ \-t | \-\-test ]
+.RB [ \-T | \-\-thin ]
+.RB [ \-\-thinpool
+.IR ThinPoolLogicalVolume { Name | Path }]
.RB [ \-\-type
.IR SegmentType ]
.RB [ \-v | \-\-verbose ]
.RB [ \-W | \-\-wipesignatures ]
.RB [ \-Z | \-\-zero
.RI { y | n }]
-.IR VolumeGroup { Name | Path }[/ ThinPoolLogicalVolumeName ]
+.RI [ VolumeGroup { Name | Path }
+.RI [/\{ ExternalOrigin
+|
+.I Origin
+|
+.IR Pool } LogicalVolumeName ]
.RI [ PhysicalVolumePath [ :PE [ \-PE ]]...]
-.br
.B lvcreate
.RB [ \-l | \-\-extents
-.IR LogicalExtentsNumber [ % { ORIGIN | VG | PVS | FREE }]
+.IR LogicalExtentsNumber [ % { FREE | ORIGIN | PVS | VG }]
|
-.BR \-L | \-\-size
+.BR \-L | \-\-size | \-\-pooldatasize
.IR LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]]
.RB [ \-c | \-\-chunksize
-.IR ChunkSize [ bBsSkK ]]
+.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-commandprofile
.IR Profilename ]
.RB [ \-\-noudevsync ]
@@ -108,7 +114,7 @@ lvcreate \- create a logical volume in an existing volume group
.RI { y | n }]
.RB [ \-n | \-\-name
.IR SnapshotLogicalVolume { Name | Path }]
-.BR \-s | \-\-snapshot
+.BR \-s | \-\-snapshot | \-H | \-\-cache
.RI {[ VolumeGroup { Name | Path }/] OriginalLogicalVolumeName
.BR \-V | \-\-virtualsize
.IR VirtualSize [ bBsSkKmMgGtTpPeE ]}
@@ -140,13 +146,16 @@ Controls the availability of the Logical Volumes for immediate use after
the command finishes running.
By default, new Logical Volumes are activated (\fB\-a\fIy\fR).
If it is possible technically, \fB\-a\fIn\fR will leave the new Logical
-Volume inactive. But for example, snapshots can only be created
-in the active state so \fB\-a\fIn\fR cannot be used with \fB\-\-snapshot\fP.
+Volume inactive. But for example, snapshots of active origin can only be
+created in the active state so \fB\-a\fIn\fR cannot be used with
+\fB-\-type\fP \fIsnapshot\fP. This does not apply to thin volume snapshots,
+which are by default created with flag to skip their activation
+(\fB-k\fP\fIy\fP).
Normally the \fB\-\-zero\fP \fIn\fP argument has to be supplied too because
zeroing (the default behaviour) also requires activation.
If autoactivation option is used (\fB\-a\fIay\fR), the logical volume is
activated only if it matches an item in the
-.B activation/auto_activation_volume_list
+.BR activation / auto_activation_volume_list
set in \fBlvm.conf\fP(5).
For autoactivated logical volumes, \fB\-\-zero\fP \fIn\fP and
\fB\-\-wipesignatures\fP \fIn\fP is always assumed and it can't
@@ -155,19 +164,21 @@ be overridden. If the clustered locking is enabled,
.IR \fB\-a { a | l } y
will activate only on the local node.
.TP
-.IR \fB\-k ", " \fB\-\-setactivationskip " {" y | n }
-Controls whether Logical Volumes are persistently flagged to be skipped during
-activation. By default, thin snapshot volumes are flagged for activation skip.
-To activate such volumes, an extra \fB\-K/\-\-ignoreactivationskip\fP option must
-be used. The flag is not applied during deactivation.
-Use \fBlvchange \-k/\-\-setactivationskip {y|n}\fP command to attach or
-detach the flag for existing volumes. To see whether the flag is attached,
-use \fBlvs\fP command where the state of the flag is reported within
-\fBlv_attr\fP bits.
-.TP
-.BR \-K ", " \-\-ignoreactivationskip
-Ignore the flag to skip Logical Volumes during activation.
-
+.IR \fB\-H ", " \fB\-\-cache
+Creates cache or cache pool logical volume or both.
+Specifying the optional argument \fB\-\-size\fP will cause the creation of
+the cache logical volume.
+Specifying the optional argument \fB\-\-pooldatasize\fP will cause
+the creation of the cache pool logical volume.
+Specifying both arguments will cause the creation of cache with its
+cache pool volume.
+When the Volume group name is specified together with existing logical volume
+name which is NOT a cache pool name, such volume is treaded
+as cache origin volume and cache pool is created. In this case
+the \fB\-\-size\fP is used to specify size of cache pool volume.
+See \fBlvmcache\fP(7) for more info about caching support.
+Note that the cache segment type requires a dm-cache kernel module version
+1.3.0 or greater.
.TP
.IR \fB\-\-cachemode " {" writeback | writethrough }
Specifying a cache mode determines when the writes to a cache LV
@@ -178,24 +189,32 @@ when it has been stored in the cache pool LV and on the origin LV.
While \fIwritethrough\fP may be slower for writes, it is more
resilient if something should happen to a device associated with the
cache pool LV.
-
+.TP
+.IR \fB\-\-cachepool " " CachePoolLogicalVolume { Name | Path }
+Specifies the name of cache pool volume name. The other way to specify pool name
+is to append name to Volume group name argument.
.TP
.BR \-c ", " \-\-chunksize " " \fIChunkSize [ \fIbBsSkKmMgG ]
Gives the size of chunk for snapshot, cache pool and thin pool logical volumes.
Default unit is in kilobytes.
.br
-For snapshots the value must be power of 2 between 4KiB and 512KiB
-and the default value is 4.
+For \fIsnapshots\fP the value must be power of 2 between 4KiB and 512KiB
+and the default value is 4KiB.
.br
-For cache pool LVs the value must be between 32KiB and 1GiB. The default
-is 64KiB. Values must be a multiple of 32KiB.
+For \fIcache pools\fP the value must a multiple of 32KiB
+between 32KiB and 1GiB. The default is 64KiB.
.br
-For thin pools the value must be between 64KiB and
-1GiB and the default value starts with 64 and scales
-up to fit the pool metadata size within 128MiB,
+For \fIthin pools\fP the value must be a multiple of 64KiB
+between 64KiB and 1GiB.
+Default value starts with 64KiB and grows up to
+fit the pool metadata size within 128MiB,
if the pool metadata size is not specified.
-Thin pool target version <1.4 requires the value to be a power of 2.
-The newer target version relaxes limitation to be a multiple of 64KiB.
+See
+.BR lvm.conf (5)
+setting
+.IR allocation / thin_pool_chunk_size_policy
+to select different calculation policy.
+Thin pool target version <1.4 requires this value to be a power of 2.
For target version <1.5 discard is not supported for non power of 2 values.
.TP
.BR \-C ", " \-\-contiguous " {" \fIy | \fIn }
@@ -203,30 +222,17 @@ Sets or resets the contiguous allocation policy for
logical volumes. Default is no contiguous allocation based
on a next free principle.
.TP
+.BR \-\-corelog
+This is shortcut for option \fB\-\-mirrorlog\fP \fIcore\fP.
+.TP
.BR \-\-discards " {" \fIignore | \fInopassdown | \fIpassdown }
Sets discards behavior for thin pool.
Default is \fIpassdown\fP.
.TP
-.BR \-i ", " \-\-stripes " " \fIStripes
-Gives the number of stripes.
-This is equal to the number of physical volumes to scatter
-the logical volume. When creating a RAID 4/5/6 logical volume,
-the extra devices which are necessary for parity are
-internally accounted for. Specifying
-.BI \-i 3
-would use 3 devices for striped logical volumes,
-4 devices for RAID 4/5, and 5 devices for RAID 6. Alternatively,
-RAID 4/5/6 will stripe across all PVs in the volume group or
-all of the PVs specified if the
-.B \-i
-argument is omitted.
-.TP
-.BR \-I ", " \-\-stripesize " " \fIStripeSize
-Gives the number of kilobytes for the granularity of the stripes.
-.br
-StripeSize must be 2^n (n = 2 to 9) for metadata in LVM1 format.
-For metadata in LVM2 format, the stripe size may be a larger
-power of 2 but must not exceed the physical extent size.
+.BR \-K ", " \-\-ignoreactivationskip
+Ignore the flag to skip Logical Volumes during activation.
+Use \fB\-\-setactivationskip\fP option to set or reset
+activation skipping flag persistently for logical volume.
.TP
.B \-\-ignoremonitoring
Make no attempt to interact with dmeventd unless \fB\-\-monitor\fP
@@ -247,19 +253,28 @@ When expressed as a percentage, the number is treated
as an approximate upper limit for the total number of physical extents
to be allocated (including extents used by any mirrors, for example).
.TP
-.IR \fB\-L ", " \fB\-\-size " " LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]
-Gives the size to allocate for the new logical volume.
-A size suffix of \fIB\fR for bytes, \fIS\fR for sectors as 512 bytes,
-\fIK\fR for kilobytes, \fIM\fR for megabytes,
-\fIG\fR for gigabytes, \fIT\fR for terabytes, \fIP\fR for petabytes
-or \fIE\fR for exabytes is optional.
-.br
-Default unit is megabytes.
+.BR \-j ", " \-\-major " " \fImajor
+Sets the major number.
+Major numbers are not supported with pool volumes.
+This option is supported only on older systems
+(kernel version 2.4) and is ignored on modern Linux systems where major
+numbers are dynamically assigned.
+.TP
+.BR \-\-metadataprofile " " \fIProfileName
+Uses and attaches the ProfileName configuration profile to the logical
+volume metadata. Whenever the logical volume is processed next time,
+the profile is automatically applied. If the volume group has another
+profile attached, the logical volume profile is preferred.
+See \fBlvm.conf\fP(5) for more information about \fBmetadata profiles\fP.
+.TP
+.B \-\-minor \fIminor
+Sets the minor number.
+Minor numbers are not supported with pool volumes.
.TP
.BR \-m ", " \-\-mirrors " " \fIMirrors
Creates a mirrored logical volume with \fIMirrors\fP copies.
For example, specifying
-.BI \-m 1
+.BI \-m\ 1
would result in a mirror with two-sides; that is,
a linear volume plus one copy.
@@ -270,49 +285,40 @@ copied. This is useful for skipping a potentially long and resource
intensive initial sync of an empty device.
There are two implementations of mirroring which can be used and correspond
-to the "raid1" and "mirror" segment types. The default is "raid1". See the
+to the "\fIraid1\fP" and "\fImirror\fP" segment types.
+The default is "\fIraid1\fP". See the
\fB\-\-type\fP option for more information if you would like to use the
-legacy "mirror" segment type. The \fB\-\-mirrorlog\fP and \fB\-\-corelog\fP
-options apply to the "mirror" segment type only.
-
-The optional argument \fB\-\-mirrorlog\fP specifies the type of log to be
-used for logical volumes utilizing the legacy "mirror" segment type.
+legacy "\fImirror\fP" segment type. See
+.BR lvm.conf (5)
+settings
+.BR global / mirror_segtype_default
+to configure default mirror segment type.
+The options
+\fB\-\-mirrorlog\fP and \fB\-\-corelog\fP apply
+to the legacy "\fImirror\fP" segment type only.
+.TP
+.BR \-\-mirrorlog " {" \fIdisk | \fIcore | \fImirrored }
+Specifies the type of log to be used for logical volumes utilizing
+the legacy "\fImirror\fP" segment type.
+.br
The default is \fIdisk\fP, which is persistent and requires
a small amount of storage space, usually on a separate device from the
-data being mirrored. Using \fIcore\fP means the mirror is regenerated
-by copying the data from the first device each time the logical
-volume is activated, like after every reboot. Using \fImirrored\fP
-will create a persistent log that is itself mirrored.
-
-When the legacy "mirror" segment type is used, the optional argument
-\fB\-\-corelog\fP is equivalent to \fB\-\-mirrorlog\fP \fIcore\fP.
-.TP
-.BR \-\-metadataprofile " " \fIProfileName
-Uses and attaches the ProfileName configuration profile to the logical
-volume metadata. Whenever the logical volume is processed next time,
-the profile is automatically applied. If the volume group has another
-profile attached, the logical volume profile is preferred.
-See \fBlvm.conf\fP(5) for more information about \fBmetadata profiles\fP.
-.TP
-.IR \fB\-M ", " \fB\-\-persistent " {" y | n }
-Set to \fIy\fP to make the minor number specified persistent.
-.TP
-.B \-\-minor \fIminor
-Sets the minor number.
-.TP
-.B \-\-major \fImajor
-Sets the major number. This option is supported only on older systems
-(kernel version 2.4) and is ignored on modern Linux systems where major
-numbers are dynamically assigned.
+data being mirrored.
+.br
+Using \fIcore\fP means the mirror is regenerated by copying the data
+from the first device each time the logical volume is activated,
+like after every reboot.
+.br
+Using \fImirrored\fP will create a persistent log that is itself mirrored.
.TP
.BR \-\-monitor " {" \fIy | \fIn }
Starts or avoids monitoring a mirrored, snapshot or thin pool logical volume with
dmeventd, if it is installed.
If a device used by a monitored mirror reports an I/O error,
the failure is handled according to
-.B activation/mirror_image_fault_policy
+.BR activation / mirror_image_fault_policy
and
-.B activation/mirror_log_fault_policy
+.BR activation / mirror_log_fault_policy
set in \fBlvm.conf\fP(5).
.TP
.IR \fB\-n ", " \fB\-\-name " " LogicalVolume { Name | Path }
@@ -321,17 +327,8 @@ Sets the name for the new logical volume.
Without this option a default name of "lvol#" will be generated where
# is the LVM internal number of the logical volume.
.TP
-.IR \fB\-\-[raid]maxrecoveryrate " " \fIRate [ bBsSkKmMgG ]
-Sets the maximum recovery rate for a RAID logical volume. \fIRate\fP
-is specified as an amount per second for each device in the array.
-If no suffix is given, then KiB/sec/device is assumed. Setting the
-recovery rate to 0 means it will be unbounded.
-.TP
-.IR \fB\-\-[raid]minrecoveryrate " " \fIRate [ bBsSkKmMgG ]
-Sets the minimum recovery rate for a RAID logical volume. \fIRate\fP
-is specified as an amount per second for each device in the array.
-If no suffix is given, then KiB/sec/device is assumed. Setting the
-recovery rate to 0 means it will be unbounded.
+.B \-\-nosync
+Causes the creation of the mirror to skip the initial resynchronization.
.TP
.B \-\-noudevsync
Disables udev synchronisation. The
@@ -345,10 +342,23 @@ Sets access permissions to read only (\fIr\fP) or read and write (\fIrw\fP).
.br
Default is read and write.
.TP
+.BR \-M ", " \-\-persistent " {" \fIy | \fIn }
+Set to \fIy\fP to make the minor number specified persistent.
+Pool volumes cannot have persistent major and minor numbers.
+Defaults to \fIy\fPes only when major or minor number is specified.
+Otherwise it is \fIn\fPo.
+.TP
+.IR \fB\-\-pooldatasize " " PoolDataVolumeSize [ bBsSkKmMgGtTpPeE ]
+Sets the size of pool's data logical volume.
+For thin pools you may also specify the size
+with the option \fB\-\-size\fP.
+.TP
.IR \fB\-\-poolmetadatasize " " MetadataVolumeSize [ bBsSkKmMgG ]
-Sets the size of thin pool's metadata logical volume.
-Supported values are in range between 2MiB and 16GiB.
-Default value is (Pool_LV_size / Pool_LV_chunk_size * 64b).
+Sets the size of pool's metadata logical volume.
+Supported values are in range between 2MiB and 16GiB for thin pool,
+and upto 16GiB for cache pool. The minimum value is computed from pool's
+data size.
+Default value for thin pool is (Pool_LV_size / Pool_LV_chunk_size * 64b).
Default unit is megabytes.
.TP
.IR \fB\-\-poolmetadataspare " {" y | n }
@@ -358,6 +368,18 @@ Only one such volume is maintained within a volume group
with the size of the biggest pool metadata volume.
Default is \fIy\fPes.
.TP
+.BR \-\- [ raid ] maxrecoveryrate " " \fIRate [ \fIbBsSkKmMgG ]
+Sets the maximum recovery rate for a RAID logical volume. \fIRate\fP
+is specified as an amount per second for each device in the array.
+If no suffix is given, then KiB/sec/device is assumed. Setting the
+recovery rate to 0 means it will be unbounded.
+.TP
+.BR \-\- [ raid ] minrecoveryrate " " \fIRate [ \fIbBsSkKmMgG ]
+Sets the minimum recovery rate for a RAID logical volume. \fIRate\fP
+is specified as an amount per second for each device in the array.
+If no suffix is given, then KiB/sec/device is assumed. Setting the
+recovery rate to 0 means it will be unbounded.
+.TP
.IR \fB\-r ", " \fB\-\-readahead " {" ReadAheadSectors | auto | none }
Sets read ahead sector count of this logical volume.
For volume groups with metadata in lvm1 format, this must
@@ -366,16 +388,41 @@ The default value is \fIauto\fP which allows the kernel to choose
a suitable value automatically.
\fINone\fP is equivalent to specifying zero.
.TP
-.BR \-R ", " \-\-regionsize " " \fIMirrorLogRegionSize
+.BR \-R ", " \-\-regionsize " " \fIMirrorLogRegionSize [ \fIbBsSkKmMgG ]
A mirror is divided into regions of this size (in MiB), and the mirror log
uses this granularity to track which regions are in sync.
.TP
+.IR \fB\-k ", " \fB\-\-setactivationskip " {" y | n }
+Controls whether Logical Volumes are persistently flagged to be skipped during
+activation. By default, thin snapshot volumes are flagged for activation skip.
+See
+.BR lvm.conf (5)
+.IR activation / auto_set_activation_skip
+how to change its default behaviour.
+To activate such volumes, an extra
+.BR \-K | \-\-ignoreactivationskip
+option must be used. The flag is not applied during deactivation. Use
+.B lvchange \-\-setactivationskip {y|n}
+command to change the skip flag for existing volumes.
+To see whether the flag is attached, use \fBlvs\fP command
+where the state of the flag is reported within \fBlv_attr\fP bits.
+.TP
+.IR \fB\-L ", " \fB\-\-size " " LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]
+Gives the size to allocate for the new logical volume.
+A size suffix of \fIB\fR for bytes, \fIS\fR for sectors as 512 bytes,
+\fIK\fR for kilobytes, \fIM\fR for megabytes,
+\fIG\fR for gigabytes, \fIT\fR for terabytes, \fIP\fR for petabytes
+or \fIE\fR for exabytes is optional.
+.br
+Default unit is megabytes.
+.TP
.IR \fB\-s ", " \fB\-\-snapshot " " OriginalLogicalVolume { Name | Path }
Creates a snapshot logical volume (or snapshot) for an existing, so called
original logical volume (or origin).
Snapshots provide a 'frozen image' of the contents of the origin
while the origin can still be updated. They enable consistent
backups and online recovery of removed/overwritten data/files.
+.br
Thin snapshot is created when the origin is a thin volume and
the size IS NOT specified. Thin snapshot shares same blocks within
the thin pool volume.
@@ -403,51 +450,91 @@ even from different thin pools. See
.BR lvconvert (8)
for online conversion to thin volumes with external origin.
.TP
-.IR \fB\-T ", " \fB\-\-thin ", " \fB\-\-thinpool " " ThinPoolLogicalVolume { Name | Path }
+.BR \-i ", " \-\-stripes " " \fIStripes
+Gives the number of stripes.
+This is equal to the number of physical volumes to scatter
+the logical volume. When creating a RAID 4/5/6 logical volume,
+the extra devices which are necessary for parity are
+internally accounted for. Specifying
+.BI \-i 3
+would use 3 devices for striped logical volumes,
+4 devices for RAID 4/5, and 5 devices for RAID 6. Alternatively,
+RAID 4/5/6 will stripe across all PVs in the volume group or
+all of the PVs specified if the
+.B \-i
+argument is omitted.
+.TP
+.BR \-I ", " \-\-stripesize " " \fIStripeSize
+Gives the number of kilobytes for the granularity of the stripes.
+.br
+StripeSize must be 2^n (n = 2 to 9) for metadata in LVM1 format.
+For metadata in LVM2 format, the stripe size may be a larger
+power of 2 but must not exceed the physical extent size.
+.TP
+.IR \fB\-T ", " \fB\-\-thin
Creates thin pool or thin logical volume or both.
-Specifying the optional argument \fB\-\-size\fP will cause the creation of
-the thin pool logical volume.
+Specifying the optional argument \fB\-\-size\fP or \fB\-\-extents\fP
+will cause the creation of the thin pool logical volume.
Specifying the optional argument \fB\-\-virtualsize\fP will cause
the creation of the thin logical volume from given thin pool volume.
Specifying both arguments will cause the creation of both
thin pool and thin volume using this pool.
See \fBlvmthin\fP(7) for more info about thin provisioning support.
-Requires device mapper kernel driver for thin provisioning
-from kernel 3.2 or newer.
+Thin provisioning requires device mapper kernel driver
+from kernel 3.2 or greater.
+.TP
+.IR \fB\-\-thinpool " " ThinPoolLogicalVolume { Name | Path }
+Specifies the name of thin pool volume name. The other way to specify pool name
+is to append name to Volume group name argument.
.TP
.B \-\-type \fISegmentType
-Create a logical volume that uses the specified segment type
-(e.g.
-.IR mirror ( \fB\-m ),
-.IR raid5 ,
-.IR snapshot ( \fB\-s ),
-.IR thin ( \fB\-T ),
-.IR thin-pool ,\ ...).
-Many segment types have a
-commandline switch alias that will enable their use
-(\fB\-s\fP is an alias for
-.B \-\-type \fIsnapshot\fP).
-However, this argument must be used when no existing
-commandline switch alias is available for the desired type,
-as is the case with
+Creates a logical volume with the specified segment type.
+Supported types are:
.IR cache ,
+.IR cache-pool ,
.IR error ,
+.IR linear ,
+.IR mirror,
.IR raid1 ,
.IR raid4 ,
-.IR raid5 ,
-.IR raid6 ,
-.IR raid10
+.IR raid5_la ,
+.IR raid5_ls " (= " raid5 ),
+.IR raid5_ra ,
+.IR raid5_rs ,
+.IR raid6_nc ,
+.IR raid6_nr ,
+.IR raid6_zr " (= " raid6 ) ,
+.IR raid10 ,
+.IR snapshot ,
+.IR striped,
+.IR thin ,
+.IR thin-pool
or
.IR zero .
-See \fBlvmcache\fP(7) for more info about caching support.
-Note that the cache segment type requires a dm-cache kernel module version
-1.3.0 or greater.
-
+Segment type may have a commandline switch alias that will
+enable its use.
+When the type is not explicitly specified an implicit type
+is selected from combination of options:
+.BR \-H | \-\-cache | \-\-cachepool " (" \fIcache
+or
+.IR cachepool ),
+.BR \-T | \-\-thin | \-\-thinpool " (" \fIthin
+or
+.IR thinpool ),
+.BR \-m | \-\-mirrors " (" \fIraid1
+or
+.IR mirror ),
+.BR \-s | \-\-snapshot | \-V | \-\-virtualsize " (" \fIsnapshot
+or
+.IR thin ),
+.BR \-i | \-\-stripes " (" \fIstriped ).
+Default type is \fIlinear\fP.
.TP
.BR \-V ", " \-\-virtualsize " " \fIVirtualSize [ \fIbBsSkKmMgGtTpPeE ]
Creates a sparse device of the given size (in MiB by default) using a snapshot
or thinly provisioned device when thin pool is specified.
-Anything written to the device will be returned when reading from it.
+See \fBlvmthin\fP(7) for more info about thin provisioning support.
+Anything written to a sparse snapshot will be returned when reading from it.
Reading from other areas of the device will return blocks of zeros.
Virtual snapshot is implemented by creating a hidden virtual device of the
requested size using the zero target. A suffix of _vorigin is used for
@@ -458,25 +545,27 @@ device sizes (GiB), thin provisioning should be used for this case.
Controls wiping of detected signatures on newly created Logical Volume.
If this option is not specified, then by default signature wiping is done
each time the zeroing (\fB\-Z\fP/\fB\-\-zero\fP) is done. This default behaviour
-can be controlled by \fBallocation/wipe_signatures_when_zeroing_new_lvs\fP
-setting found in \fBlvm.conf\fP(5).
+can be controlled by
+.BR allocation / wipe_signatures_when_zeroing_new_lvs
+setting found in
+.BR lvm.conf (5).
.br
-If blkid wiping is used (\fBallocation/use_blkid_wiping setting\fP in \fBlvm.conf\fP(5))
+If blkid wiping is used
+.BR allocation / use_blkid_wiping
+setting in
+.BR lvm.conf (5))
and LVM2 is compiled with blkid wiping support, then \fBblkid\fP(8) library is used
to detect the signatures (use \fBblkid -k\fP command to list the signatures that are recognized).
Otherwise, native LVM2 code is used to detect signatures (MD RAID, swap and LUKS
signatures are detected only in this case).
.br
-Logical Volume is not wiped if the read only flag is set.
+Logical volume is not wiped if the read only flag is set.
.TP
.BR \-Z ", " \-\-zero " {" \fIy | \fIn }
Controls zeroing of the first 4KiB of data in the new logical volume.
-.br
Default is \fIy\fPes.
-.br
-Volume will not be zeroed if the read only flag is set.
-.br
-Snapshot volumes are zeroed always.
+Snapshot COW volumes are always zeroed.
+Logical volume is not zeroed if the read only flag is set.
.br
Warning: trying to mount an unzeroed logical volume can cause the system to
@@ -572,7 +661,7 @@ If there is an existing cache pool LV, create the large slow
device (i.e. the origin LV) and link it to the supplied cache pool LV,
creating a cache LV.
.sp
-.B lvcreate \-\-type cache \-L 100G \-n my_lv vg/my_lv_cachepool /dev/slow1
+.B lvcreate \-\-cache \-L 100G \-n my_lv vg/my_lv_cachepool /dev/slow1
If there is an existing logical volume, create the small and fast
cache pool LV and link it to the supplied existing logical
@@ -580,6 +669,10 @@ volume (i.e. the origin LV), creating a cache LV.
.sp
.B lvcreate \-\-type cache \-L 1G \-n my_lv_cachepool vg/my_lv /dev/fast1
+Create a 1G cached LV "lvol1" with 10M cache pool "vg00/pool".
+.sp
+.B lvcreate \-\-cache \-L 1G \-n lv --pooldatasize 10M vg00/pool
+
.SH SEE ALSO
.BR lvm (8),
.BR lvm.conf (5),
@@ -593,4 +686,5 @@ volume (i.e. the origin LV), creating a cache LV.
.BR lvrename (8)
.BR lvs (8),
.BR lvscan (8),
-.BR vgcreate (8)
+.BR vgcreate (8),
+.BR blkid (8)
9 years, 6 months
master - cache: separate func for pool/origin validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd00d2c6eceb65...
Commit: fd00d2c6eceb6536208558561a02d464d1808469
Parent: 298de1f5c3c2a84eb4c12f4697c110016a98237e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 21:01:03 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
cache: separate func for pool/origin validation
Split validate_lv_cache_create() into 2 function
once is called for pool validation other for origin.
It's less misleading the accepting NULLs.
---
lib/metadata/cache_manip.c | 55 ++++++++++++++++++--------------------
lib/metadata/lv_manip.c | 2 +-
lib/metadata/metadata-exported.h | 4 +-
tools/lvconvert.c | 5 ++-
tools/lvcreate.c | 2 +
5 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 6aad50d..44d1bd8 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -92,39 +92,35 @@ int update_cache_pool_params(const struct segment_type *segtype,
*
* Always validates origin_lv, and when it is known also cache pool_lv
*/
-int validate_lv_cache_create(const struct logical_volume *pool_lv,
- const struct logical_volume *origin_lv)
+int validate_lv_cache_create_pool(const struct logical_volume *pool_lv)
{
struct lv_segment *seg;
- if (pool_lv) {
- if (!lv_is_cache_pool(pool_lv)) {
- log_error("Logical volume %s is not a cache pool.",
- display_lvname(pool_lv));
- return 0;
- }
-
- if (lv_is_locked(pool_lv)) {
- log_error("Cannot use locked cache pool %s.",
- display_lvname(pool_lv));
- return 0;
- }
+ if (!lv_is_cache_pool(pool_lv)) {
+ log_error("Logical volume %s is not a cache pool.",
+ display_lvname(pool_lv));
+ return 0;
+ }
- if (origin_lv == pool_lv) {
- log_error("Can't use same LV %s for cache pool and cache volume.",
- display_lvname(pool_lv));
- return 0;
- }
+ if (lv_is_locked(pool_lv)) {
+ log_error("Cannot use locked cache pool %s.",
+ display_lvname(pool_lv));
+ return 0;
+ }
- if (!dm_list_empty(&pool_lv->segs_using_this_lv)) {
- seg = get_only_segment_using_this_lv(pool_lv);
- log_error("Logical volume %s is already in use by %s",
- display_lvname(pool_lv),
- seg ? display_lvname(seg->lv) : "another LV");
- return 0;
- }
+ if (!dm_list_empty(&pool_lv->segs_using_this_lv)) {
+ seg = get_only_segment_using_this_lv(pool_lv);
+ log_error("Logical volume %s is already in use by %s",
+ display_lvname(pool_lv),
+ seg ? display_lvname(seg->lv) : "another LV");
+ return 0;
}
+ return 1;
+}
+
+int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
+{
if (lv_is_locked(origin_lv)) {
log_error("Cannot use locked origin volume %s.",
display_lvname(origin_lv));
@@ -174,7 +170,8 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
struct logical_volume *cache_lv = origin_lv;
struct lv_segment *seg;
- if (!validate_lv_cache_create(pool_lv, origin_lv))
+ if (!validate_lv_cache_create_pool(pool_lv) ||
+ !validate_lv_cache_create_origin(origin_lv))
return_NULL;
if (!(segtype = get_segtype_from_string(cmd, "cache")))
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f2cf404..335a1bd 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6711,7 +6711,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (!validate_lv_cache_create(NULL, origin_lv))
+ if (!validate_lv_cache_create_origin(origin_lv))
return_NULL;
/* Validate cache origin is exclusively active */
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 1100849..19508ab 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1083,8 +1083,8 @@ int update_cache_pool_params(const struct segment_type *segtype,
int passed_args, uint32_t data_extents,
uint64_t *pool_metadata_size,
int *chunk_size_calc_method, uint32_t *chunk_size);
-int validate_lv_cache_create(const struct logical_volume *pool_lv,
- const struct logical_volume *origin_lv);
+int validate_lv_cache_create_pool(const struct logical_volume *pool_lv);
+int validate_lv_cache_create_origin(const struct logical_volume *origin_lv);
struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct logical_volume *origin);
int lv_cache_remove(struct logical_volume *cache_lv);
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index eb8a83b..c792986 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3202,7 +3202,8 @@ static int _lvconvert_cache(struct cmd_context *cmd,
struct logical_volume *pool_lv = lp->pool_data_lv;
struct logical_volume *cache_lv;
- if (!validate_lv_cache_create(pool_lv, origin_lv))
+ if (!validate_lv_cache_create_pool(pool_lv) ||
+ !validate_lv_cache_create_origin(origin_lv))
return_0;
if (!archive(origin_lv->vg))
@@ -3270,7 +3271,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (lp->cache) {
if (lv_is_thin_pool(lv))
lv = seg_lv(first_seg(lv), 0); /* cache _tdata */
- if (!validate_lv_cache_create(NULL, lv))
+ if (!validate_lv_cache_create_origin(lv))
return_ECMD_FAILED;
}
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 767405b..45f432e 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1051,6 +1051,8 @@ static int _determine_cache_argument(struct volume_group *vg,
if (!lp->pool_name) {
lp->pool_name = lp->lv_name;
} else if ((lv = find_lv(vg, lp->pool_name)) && lv_is_cache_pool(lv)) {
+ if (!validate_lv_cache_create_pool(lv))
+ return_0;
/* Pool exists, create cache volume */
lp->create_pool = 0;
lp->origin_name = NULL;
9 years, 6 months
master - segments: mark more of them unzeroable
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=298de1f5c3c2a8...
Commit: 298de1f5c3c2a84eb4c12f4697c110016a98237e
Parent: 784c216d2beb21bf793d33d1ebf600ab30454bb7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 14:57:24 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
segments: mark more of them unzeroable
Use segment flags to avoid zeroing of cache, cache pool
snapshot and thin pool segments.
We never want to zero these segment types.
Note:
Snapshot COW and Cache origin are created as stripes
thus are then properly zeroed.
---
WHATS_NEW | 1 +
lib/cache_segtype/cache.c | 2 +-
lib/snapshot/snapshot.c | 2 +-
lib/thin/thin.c | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b1f8410..1bdb884 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Mark pools and snapshots as unzeroable volumes.
Check for zeroing of volume after segment type is fully detected.
Better support for persistent major and minor options with lvcreate.
Refactor lvcreate towards more complete validation of all supported options.
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 9927688..8c2ff78 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -391,7 +391,7 @@ int init_cache_segtypes(struct cmd_context *cmd,
segtype->cmd = cmd;
segtype->name = "cache-pool";
- segtype->flags = SEG_CACHE_POOL;
+ segtype->flags = SEG_CACHE_POOL | SEG_CANNOT_BE_ZEROED;
segtype->ops = &_cache_pool_ops;
segtype->private = NULL;
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 18e8111..aefab3a 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -262,7 +262,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
segtype->ops = &_snapshot_ops;
segtype->name = "snapshot";
segtype->private = NULL;
- segtype->flags = SEG_SNAPSHOT;
+ segtype->flags = SEG_SNAPSHOT | SEG_CANNOT_BE_ZEROED;
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 9ae237e..bb13b2b 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -753,7 +753,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
const char name[16];
uint32_t flags;
} reg_segtypes[] = {
- { &_thin_pool_ops, "thin-pool", SEG_THIN_POOL },
+ { &_thin_pool_ops, "thin-pool", SEG_THIN_POOL | SEG_CANNOT_BE_ZEROED },
/* FIXME Maybe use SEG_THIN_VOLUME instead of SEG_VIRTUAL */
{ &_thin_ops, "thin", SEG_THIN_VOLUME | SEG_VIRTUAL }
};
9 years, 6 months