Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e09ee21fd46287ed…
Commit: e09ee21fd46287ed245ea086ddcf06140a83431a
Parent: 47d50a8f2735a8c4496082eab5b312a596e2c2d4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 31 00:37:35 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 31 00:37:35 2014 +0100
tests: update raid sync
---
test/shell/lvconvert-cache-raid.sh | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh
index 174b0ec..1fcd0fe 100644
--- a/test/shell/lvconvert-cache-raid.sh
+++ b/test/shell/lvconvert-cache-raid.sh
@@ -46,11 +46,11 @@ lvremove -f $vg
lvcreate -n cpool_meta -m 1 --type raid1 -l 10 $vg
lvcreate -n cpool -m 1 --type raid1 -l 10 $vg
+aux wait_for_sync $vg cpool
lvs -a -o+seg_pe_ranges $vg
lvconvert --yes --type cache-pool --poolmetadata $vg/cpool_meta $vg/cpool
lvcreate -n corigin --type cache --cachepool $vg/cpool -l 10
-aux wait_for_sync $vg cpool
lvchange --syncaction repair $vg/cpool_cmeta
lvchange --syncaction repair $vg/cpool_cdata
@@ -62,7 +62,6 @@ not lvconvert --splitmirrors 1 --name split_cmeta $vg/cpool_cmeta "$dev1"
not lvconvert --splitmirrors 1 --name split_cdata $vg/cpool_cdata "$dev1"
# but allow manipulating existing LVs with reserved names
-aux wait_for_sync $vg cpool
lvconvert --splitmirrors 1 --name split_meta $vg/cpool_cmeta "$dev1"
lvconvert --splitmirrors 1 --name split_data $vg/cpool_cdata "$dev1"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=47d50a8f2735a8c4…
Commit: 47d50a8f2735a8c4496082eab5b312a596e2c2d4
Parent: e7c130430a2b232bdf062f8fb3064899b176986b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 31 00:31:54 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 31 00:31:54 2014 +0100
tests: wait for raid sync
---
test/shell/lvconvert-cache-raid.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh
index 16dd38e..174b0ec 100644
--- a/test/shell/lvconvert-cache-raid.sh
+++ b/test/shell/lvconvert-cache-raid.sh
@@ -50,6 +50,7 @@ lvs -a -o+seg_pe_ranges $vg
lvconvert --yes --type cache-pool --poolmetadata $vg/cpool_meta $vg/cpool
lvcreate -n corigin --type cache --cachepool $vg/cpool -l 10
+aux wait_for_sync $vg cpool
lvchange --syncaction repair $vg/cpool_cmeta
lvchange --syncaction repair $vg/cpool_cdata
@@ -61,6 +62,7 @@ not lvconvert --splitmirrors 1 --name split_cmeta $vg/cpool_cmeta "$dev1"
not lvconvert --splitmirrors 1 --name split_cdata $vg/cpool_cdata "$dev1"
# but allow manipulating existing LVs with reserved names
+aux wait_for_sync $vg cpool
lvconvert --splitmirrors 1 --name split_meta $vg/cpool_cmeta "$dev1"
lvconvert --splitmirrors 1 --name split_data $vg/cpool_cdata "$dev1"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e7c130430a2b232b…
Commit: e7c130430a2b232bdf062f8fb3064899b176986b
Parent: 8926230f6e7ac46c5bbed70d3e8efbc43e5b444d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 31 00:28:25 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 31 00:28:25 2014 +0100
tests: explicitely use old snapshots
---
test/shell/snapshot-usage.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index c29d310..a3dd7a6 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -111,7 +111,7 @@ lvs -a $vg1
lvremove -f $vg1
# Test virtual snapshot over /dev/zero
-lvcreate -V50 -L10 -n $lv1 -s $vg1
+lvcreate --type snapshot -V50 -L10 -n $lv1 -s $vg1
CHECK_ACTIVE="active"
test ! -e LOCAL_CLVMD || CHECK_ACTIVE="local exclusive"
check lv_field $vg1/$lv1 lv_active "$CHECK_ACTIVE"
@@ -228,7 +228,7 @@ lvcreate -s -l100%FREE -n $lv2 $vg1/$lv1
check lv_field $vg1/$lv2 size "7.50p"
lvremove -ff $vg1
-lvcreate -V15E -l1 -n $lv1 -s $vg1
+lvcreate --type snapshot -V15E -l1 -n $lv1 -s $vg1
check lv_field $vg1/$lv1 origin_size "15.00e"
vgremove -ff $vg1
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8926230f6e7ac46c…
Commit: 8926230f6e7ac46c5bbed70d3e8efbc43e5b444d
Parent: b58a0f5cd31669e789d6944ced5b42ce7c6f4f74
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 23:16:03 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
tests: lvcreate snapshot usage update
---
test/shell/lvcreate-usage.sh | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index 05f2515..5d37d9c 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -130,8 +130,16 @@ grep "Redundant" err
check lv_field $vg/$lv1 segtype "linear"
lvremove -ff $vg
-# Snapshot with virtual origin works
+# Old --type snapshot works with -s
+lvcreate --type snapshot -s -V64 -L32 -n $lv1 $vg
+check lv_field $vg/$lv1 segtype "linear"
+lvcreate --type snapshot -V64 -L32 -n $lv2 $vg
+check lv_field $vg/$lv2 segtype "linear"
+lvremove -ff $vg
+
+# --virtualoriginsize always makes old snapshot
lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
+check lv_field $vg/$lv1 segtype "linear"
lvrename $vg/$lv1 $vg/$lv2
lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
lvchange -a n $vg/$lv1
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b58a0f5cd31669e7…
Commit: b58a0f5cd31669e789d6944ced5b42ce7c6f4f74
Parent: da61e6355e35ba7961b2073812c6a5639d9d541d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 20:41:49 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
tests: use aux func to disable device
---
test/shell/lvcreate-missing.sh | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvcreate-missing.sh b/test/shell/lvcreate-missing.sh
index 2b74052..4553e98 100644
--- a/test/shell/lvcreate-missing.sh
+++ b/test/shell/lvcreate-missing.sh
@@ -12,10 +12,11 @@
. lib/inittest
aux prepare_vg 2
-init_udev_transaction
-dmsetup remove -f "$dev1" || true
-finish_udev_transaction
+
+aux disable_dev "$dev1"
not lvcreate -n "foo" $vg -l 1
+aux enable_dev "$dev1"
+
vgremove -ff $vg
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da61e6355e35ba79…
Commit: da61e6355e35ba7961b2073812c6a5639d9d541d
Parent: fe245d78ff603dd798b719854ee8d900f858779d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 25 16:03:44 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
tests: raid syncaction test
Add sync wait for syncaction of raid1 test.
--syncaction requires raid to be in sync first.
---
test/shell/lvchange-syncaction-raid.sh | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvchange-syncaction-raid.sh b/test/shell/lvchange-syncaction-raid.sh
index 9a42894..7ef4e01 100644
--- a/test/shell/lvchange-syncaction-raid.sh
+++ b/test/shell/lvchange-syncaction-raid.sh
@@ -21,12 +21,15 @@ aux prepare_vg 3
lvcreate -n $lv1 $vg -l1 --type raid1
+aux wait_for_sync $vg $lv1
+
START=$(get pv_field "$dev2" pe_start --units 1k)
METASIZE=$(get lv_field $vg/${lv1}_rmeta_1 size -a --units 1k)
SEEK=$((${START%\.00k} + ${METASIZE%\.00k}))
# Overwrite some portion of _rimage_1
dd if=/dev/urandom of="$dev2" bs=1K count=1 seek=$SEEK oflag=direct
+aux wait_for_sync $vg $lv1
lvchange --syncaction check $vg/$lv1
check lv_field $vg/$lv1 raid_mismatch_count "128"
@@ -34,7 +37,7 @@ check lv_field $vg/$lv1 raid_mismatch_count "128"
lvchange -an $vg/$lv1
# Slow down write by 100ms
-aux delay_dev "$dev2" 0 100
+aux delay_dev "$dev2" 0 50
lvchange -ay $vg/$lv1
# noone has it open and target is read & running
dmsetup info -c | grep $vg
@@ -49,9 +52,12 @@ dmsetup info -c | grep $vg
# For now it fails with:
# device-mapper: message ioctl on failed: Device or resource busy
#
+# As solution for now - user needs to run --synaction on synchronous raid array
+#
+aux wait_for_sync $vg $lv1
should lvchange --syncaction check $vg/$lv1
aux enable_dev "$dev2"
-lvs -o+raid_mismatch_count -a $vg
+check lv_field $vg/$lv1 raid_mismatch_count "0"
vgremove -ff $vg
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fe245d78ff603dd7…
Commit: fe245d78ff603dd798b719854ee8d900f858779d
Parent: 888b21e9bd10d70154fb361359a2342aa56af27a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 13:04:41 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
cleanup: shorter code
---
lib/metadata/pool_manip.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index d1b4497..c7c07e5 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -533,12 +533,11 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
.read_ahead = read_ahead,
.stripe_size = stripe_size,
.stripes = stripes,
- .zero = 1,
+ .tags = DM_LIST_HEAD_INIT(lvc.tags),
.temporary = 1,
+ .zero = 1,
};
- dm_list_init(&lvc.tags);
-
if (!(lvc.extents = extents_from_size(pool_lv->vg->cmd, size,
pool_lv->vg->extent_size)))
return_0;
@@ -574,12 +573,11 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
.pvh = pvh ? : &vg->pvs,
.read_ahead = DM_READ_AHEAD_AUTO,
.stripes = 1,
- .zero = 1,
+ .tags = DM_LIST_HEAD_INIT(lp.tags),
.temporary = 1,
+ .zero = 1,
};
- dm_list_init(&lp.tags);
-
if (!(lp.segtype = get_segtype_from_string(vg->cmd, "striped")))
return_0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=888b21e9bd10d701…
Commit: 888b21e9bd10d70154fb361359a2342aa56af27a
Parent: 9a6cf3d9f4b43e0d47ac686d8acc5f280d4bfd70
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 11:38:49 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
cleanup: extents_from_size is 32bit value
Current lvm2 does support only 32bit extents count.
---
lib/metadata/metadata-exported.h | 2 +-
lib/metadata/metadata.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 890e808..013da16 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -731,7 +731,7 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
int lv_update_and_reload(struct logical_volume *lv);
int lv_update_and_reload_origin(struct logical_volume *lv);
-uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
+uint32_t extents_from_size(struct cmd_context *cmd, uint64_t size,
uint32_t extent_size);
uint32_t extents_from_percent_size(struct volume_group *vg, const struct dm_list *pvh,
uint32_t extents, int roundup,
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 2038f06..df2d6a3 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1075,7 +1075,8 @@ bad:
return NULL;
}
-uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
+/* Rounds up by default */
+uint32_t extents_from_size(struct cmd_context *cmd, uint64_t size,
uint32_t extent_size)
{
if (size % extent_size) {
@@ -1094,7 +1095,7 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
return 0;
}
- return size / extent_size;
+ return (uint32_t) (size / extent_size);
}
/*
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a6cf3d9f4b43e0d…
Commit: 9a6cf3d9f4b43e0d47ac686d8acc5f280d4bfd70
Parent: 0da749c9a4c488bd336b2c6b3df7d781a812cb47
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 11:38:03 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
cleanup: prints and stacks
---
lib/metadata/lv_manip.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 49d2300..e5b36df 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4600,21 +4600,21 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
/* If reducing, find stripes, stripesize & size of last segment */
if (reducing) {
if (lp->stripes || lp->stripe_size || lp->mirrors)
- log_error("Ignoring stripes, stripesize and mirrors "
- "arguments when reducing");
+ log_print_unless_silent("Ignoring stripes, stripesize and mirrors "
+ "arguments when reducing.");
if (lp->sign == SIGN_MINUS)
if (lp->extents_are_pes) {
if (lp->extents >= existing_physical_extents) {
log_error("Unable to reduce %s below 1 extent.", lp->lv_name);
- return_0;
+ return 0;
}
new_extents = existing_physical_extents - lp->extents;
} else {
new_extents = existing_logical_extents - lp->extents;
if (lp->extents >= existing_logical_extents) {
log_error("Unable to reduce %s below 1 extent.", lp->lv_name);
- return_0;
+ return 0;
}
}
else
@@ -4843,7 +4843,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
if (lv_is_thin_pool(lv)) {
if (lp->resizefs) {
- log_warn("Thin pool volumes do not have filesystem.");
+ log_print_unless_silent("Ignoring --resizefs as thin pool volumes do not have filesystem.");
lp->resizefs = 0;
}
lock_lv = lv;
@@ -4854,7 +4854,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
alloc = lp->ac_alloc ?: lv->alloc;
if ((lp->resize == LV_REDUCE) && lp->argc)
- log_warn("Ignoring PVs on command line when reducing");
+ log_print_unless_silent("Ignoring PVs on command line when reducing.");
/* Request confirmation before operations that are often mistakes. */
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0da749c9a4c488bd…
Commit: 0da749c9a4c488bd336b2c6b3df7d781a812cb47
Parent: 8bf4cd464f499403aacde52b1c1867ebb31714da
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 28 20:09:08 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
cleanup: remove unneeded assign
---
lib/metadata/lv_manip.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 36bc2d8..49d2300 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5081,7 +5081,6 @@ struct logical_volume *alloc_lv(struct dm_pool *mem)
return NULL;
}
- lv->snapshot = NULL;
dm_list_init(&lv->snapshot_segs);
dm_list_init(&lv->segments);
dm_list_init(&lv->tags);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8bf4cd464f499403…
Commit: 8bf4cd464f499403aacde52b1c1867ebb31714da
Parent: 375d7f1c2d4ebe86cb54fce454f503758e02bb7a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 23:43:12 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
metadata: add extents_from_percent_size
Add API call to calculate extents from percentage value.
Size is based in DM_PERCENT_1 units.
(Supporting decimal point number).
This commit is preparing functionality for more global
usage of % with i.e. --size option.
---
lib/metadata/metadata-exported.h | 3 ++
lib/metadata/metadata.c | 61 ++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 5ac68bf..890e808 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -733,6 +733,9 @@ int lv_update_and_reload_origin(struct logical_volume *lv);
uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
uint32_t extent_size);
+uint32_t extents_from_percent_size(struct volume_group *vg, const struct dm_list *pvh,
+ uint32_t extents, int roundup,
+ percent_type_t percent, uint64_t size);
struct logical_volume *find_pool_lv(const struct logical_volume *lv);
int pool_is_active(const struct logical_volume *pool_lv);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 3e1b94a..2038f06 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1097,6 +1097,67 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
return size / extent_size;
}
+/*
+ * Converts size according to percentage with specified rounding to extents
+ *
+ * For PERCENT_NONE size is in standard sector units.
+ * For all other percent type is in DM_PERCENT_1 base unit (supports decimal point)
+ *
+ * Return value of 0 extents is an error.
+ */
+uint32_t extents_from_percent_size(struct volume_group *vg, const struct dm_list *pvh,
+ uint32_t extents, int roundup,
+ percent_type_t percent, uint64_t size)
+{
+ uint32_t count;
+
+ switch (percent) {
+ case PERCENT_NONE:
+ if (!roundup && (size % vg->extent_size)) {
+ if (!(size -= size % vg->extent_size)) {
+ log_error("Specified size is smaller then physical extent boundary.");
+ return 0;
+ }
+ log_print_unless_silent("Rounding size to boundary between physical extents: %s.",
+ display_size(vg->cmd, size));
+ }
+ return extents_from_size(vg->cmd, size, vg->extent_size);
+ case PERCENT_LV:
+ break; /* Base extents already passed in. */
+ case PERCENT_VG:
+ extents = vg->extent_count;
+ break;
+ case PERCENT_PVS:
+ if (pvh != &vg->pvs) {
+ /* Physical volumes are specified on cmdline */
+ if (!(extents = pv_list_extents_free(pvh))) {
+ log_error("No free extents in the list of physical volumes.");
+ return 0;
+ }
+ break;
+ }
+ /* Fall back to use all PVs in VG like %FREE */
+ case PERCENT_FREE:
+ if (!(extents = vg->free_count)) {
+ log_error("No free extents in Volume group %s.", vg->name);
+ return 0;
+ }
+ break;
+ default:
+ log_error(INTERNAL_ERROR "Unsupported percent type %u.", percent);
+ return 0;
+ }
+
+ if (!(count = percent_of_extents(size, extents, roundup)))
+ log_error("Converted %.2f%%%s into 0 extents.",
+ (double) size / DM_PERCENT_1, get_percent_string(percent));
+ else
+ log_verbose("Converted %.2f%%%s into %" PRIu32 " extents.",
+ (double) size / DM_PERCENT_1, get_percent_string(percent), count);
+
+ return count;
+}
+
static dm_bitset_t _bitset_with_random_bits(struct dm_pool *mem, uint32_t num_bits,
uint32_t num_set_bits, unsigned *seed)
{
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=375d7f1c2d4ebe86…
Commit: 375d7f1c2d4ebe86cb54fce454f503758e02bb7a
Parent: 464f3b8abd03633ff5dd2c5fe5585d921af8931f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 28 11:02:58 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
pv_manip: check for pe_ranges
---
lib/metadata/pv_manip.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 9a0f287..00a7fd5 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -374,6 +374,10 @@ uint32_t pv_list_extents_free(const struct dm_list *pvh)
struct pv_segment *pvseg;
dm_list_iterate_items(pvl, pvh) {
+ if (!pvl->pe_ranges) {
+ log_warn(INTERNAL_ERROR "WARNING: PV %s is without initialized PE ranges.", dev_name(pvl->pv->dev));
+ continue;
+ }
dm_list_iterate_items(per, pvl->pe_ranges) {
dm_list_iterate_items(pvseg, &pvl->pv->segments) {
if (!pvseg_is_allocated(pvseg))
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=464f3b8abd03633f…
Commit: 464f3b8abd03633ff5dd2c5fe5585d921af8931f
Parent: 519fbe71e46c747a254bc200ea93396591e1a1a3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 14:52:37 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
lvmcmdline: support size_mb_arg_with_percent
New size_mb_arg_with_percent is able to read size_mb_arg
but also it's able to read % values.
Percent parsing is share with int_arg_with_sign_and_percent.
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 66 +++++++++++++++++++++++++++++++++++++---------------
tools/tools.h | 1 +
3 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a8ea15f..bb8cd8d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Introduce size_mb_arg_with_percent() for advanced size arg reading.
Add extra support for '.' as decimal point in size args.
Configurable support for creation of sparse volumes with thin-pools.
Update and correct lvcreate and lvcovert man pages.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 33c0045..1d3e993 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -384,8 +384,32 @@ static int _get_int_arg(struct arg_values *av, char **ptr)
return 1;
}
+static int _get_percent_arg(struct arg_values *av, const char *ptr)
+{
+ if (!strcasecmp(ptr, "V") || !strcasecmp(ptr, "VG"))
+ av->percent = PERCENT_VG;
+ else if (!strcasecmp(ptr, "L") || !strcasecmp(ptr, "LV"))
+ av->percent = PERCENT_LV;
+ else if (!strcasecmp(ptr, "P") || !strcasecmp(ptr, "PV") ||
+ !strcasecmp(ptr, "PVS"))
+ av->percent = PERCENT_PVS;
+ else if (!strcasecmp(ptr, "F") || !strcasecmp(ptr, "FR") ||
+ !strcasecmp(ptr, "FREE"))
+ av->percent = PERCENT_FREE;
+ else if (!strcasecmp(ptr, "O") || !strcasecmp(ptr, "OR") ||
+ !strcasecmp(ptr, "ORIGIN"))
+ av->percent = PERCENT_ORIGIN;
+ else {
+ log_error("Specified %%%s is unknown.", ptr);
+ return 0;
+ }
+
+ return 1;
+}
+
/* Size stored in sectors */
-static int _size_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av, int factor)
+static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
+ struct arg_values *av, int factor, int percent)
{
char *ptr;
int i;
@@ -429,7 +453,14 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)), struct arg
if (ptr == val)
return 0;
- if (*ptr) {
+ if (percent && *ptr == '%') {
+ if (!_get_percent_arg(av, ++ptr))
+ return_0;
+ if ((uint64_t) v >= UINT32_MAX) {
+ log_error("Percentage is too big (>=%d%%).", UINT32_MAX);
+ return 0;
+ }
+ } else if (*ptr) {
for (i = strlen(suffixes) - 1; i >= 0; i--)
if (suffixes[i] == tolower((int) *ptr))
break;
@@ -474,12 +505,17 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)), struct arg
int size_kb_arg(struct cmd_context *cmd, struct arg_values *av)
{
- return _size_arg(cmd, av, 2);
+ return _size_arg(cmd, av, 2, 0);
}
int size_mb_arg(struct cmd_context *cmd, struct arg_values *av)
{
- return _size_arg(cmd, av, 2048);
+ return _size_arg(cmd, av, 2048, 0);
+}
+
+int size_mb_arg_with_percent(struct cmd_context *cmd, struct arg_values *av)
+{
+ return _size_arg(cmd, av, 2048, 1);
}
int int_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av)
@@ -516,21 +552,13 @@ int int_arg_with_sign_and_percent(struct cmd_context *cmd __attribute__((unused)
if (*ptr++ != '%')
return 0;
- if (!strcasecmp(ptr, "V") || !strcasecmp(ptr, "VG"))
- av->percent = PERCENT_VG;
- else if (!strcasecmp(ptr, "L") || !strcasecmp(ptr, "LV"))
- av->percent = PERCENT_LV;
- else if (!strcasecmp(ptr, "P") || !strcasecmp(ptr, "PV") ||
- !strcasecmp(ptr, "PVS"))
- av->percent = PERCENT_PVS;
- else if (!strcasecmp(ptr, "F") || !strcasecmp(ptr, "FR") ||
- !strcasecmp(ptr, "FREE"))
- av->percent = PERCENT_FREE;
- else if (!strcasecmp(ptr, "O") || !strcasecmp(ptr, "OR") ||
- !strcasecmp(ptr, "ORIGIN"))
- av->percent = PERCENT_ORIGIN;
- else
+ if (!_get_percent_arg(av, ptr))
+ return_0;
+
+ if (av->ui64_value >= UINT32_MAX) {
+ log_error("Percentage is too big (>=%d%%).", UINT32_MAX);
return 0;
+ }
return 1;
}
@@ -613,7 +641,7 @@ int readahead_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_va
return 1;
}
- if (!_size_arg(cmd, av, 1))
+ if (!_size_arg(cmd, av, 1, 0))
return 0;
if (av->sign == SIGN_MINUS)
diff --git a/tools/tools.h b/tools/tools.h
index 5a5d729..2196dba 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -129,6 +129,7 @@ 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 size_mb_arg_with_percent(struct cmd_context *cmd, struct arg_values *av);
int int_arg(struct cmd_context *cmd, struct arg_values *av);
int int_arg_with_sign(struct cmd_context *cmd, struct arg_values *av);
int int_arg_with_sign_and_percent(struct cmd_context *cmd, struct arg_values *av);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=519fbe71e46c747a…
Commit: 519fbe71e46c747a254bc200ea93396591e1a1a3
Parent: 97cccfbf1c000e597cf751e26284614a15f77cb5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 28 11:20:33 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
lvmcmdline: extra support for decimal point
If root has locales with different decimal point then '.'
(i.e. Czech with ',') lets be tolerant and retry with
"C" locales in the case '.' is found during parse of number.
Locales are then restored back.
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e59e0f4..a8ea15f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Add extra support for '.' as decimal point in size args.
Configurable support for creation of sparse volumes with thin-pools.
Update and correct lvcreate and lvcovert man pages.
Mark pools and snapshots as unzeroable volumes.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index c426873..33c0045 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -27,6 +27,7 @@
#include <sys/resource.h>
#include <dirent.h>
#include <paths.h>
+#include <locale.h>
#ifdef HAVE_GETOPTLONG
# include <getopt.h>
@@ -414,6 +415,17 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)), struct arg
v = strtod(val, &ptr);
+ if (*ptr == '.') {
+ /*
+ * Maybe user has non-C locale with different decimal point ?
+ * Lets be toleran and retry with standard C locales
+ */
+ if (setlocale(LC_ALL, "C")) {
+ v = strtod(val, &ptr);
+ setlocale(LC_ALL, "");
+ }
+ }
+
if (ptr == val)
return 0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=97cccfbf1c000e59…
Commit: 97cccfbf1c000e597cf751e26284614a15f77cb5
Parent: 87fc3b710c3b8fc656dcf48ec453e1da280ec696
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 27 10:50:52 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:49 2014 +0100
segtype: drop cmdcontex pointer
Users of context provide their cmd pointer,
so don't keep it inside segtype.
---
lib/cache_segtype/cache.c | 4 ----
lib/commands/toolcontext.c | 1 -
lib/error/errseg.c | 2 --
lib/freeseg/freeseg.c | 2 --
lib/metadata/segtype.h | 1 -
lib/mirror/mirrored.c | 2 --
lib/raid/raid.c | 2 +-
lib/snapshot/snapshot.c | 2 --
lib/striped/striped.c | 2 --
lib/unknown/unknown.c | 2 --
lib/zero/zero.c | 2 --
tools/reporter.c | 1 -
12 files changed, 1 insertions(+), 22 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 8c2ff78..93027d7 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -388,12 +388,10 @@ int init_cache_segtypes(struct cmd_context *cmd,
log_error("Failed to allocate memory for cache_pool segtype");
return 0;
}
- segtype->cmd = cmd;
segtype->name = "cache-pool";
segtype->flags = SEG_CACHE_POOL | SEG_CANNOT_BE_ZEROED;
segtype->ops = &_cache_pool_ops;
- segtype->private = NULL;
if (!lvm_register_segtype(seglib, segtype))
return_0;
@@ -404,12 +402,10 @@ int init_cache_segtypes(struct cmd_context *cmd,
log_error("Failed to allocate memory for cache segtype");
return 0;
}
- segtype->cmd = cmd;
segtype->name = "cache";
segtype->flags = SEG_CACHE;
segtype->ops = &_cache_ops;
- segtype->private = NULL;
if (!lvm_register_segtype(seglib, segtype))
return_0;
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 72525f5..3900179 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1174,7 +1174,6 @@ int lvm_register_segtype(struct segtype_library *seglib,
struct segment_type *segtype2;
segtype->library = seglib->lib;
- segtype->cmd = seglib->cmd;
dm_list_iterate_items(segtype2, &seglib->cmd->segtypes) {
if (strcmp(segtype2->name, segtype->name))
diff --git a/lib/error/errseg.c b/lib/error/errseg.c
index af19e7d..fa0b9c0 100644
--- a/lib/error/errseg.c
+++ b/lib/error/errseg.c
@@ -94,10 +94,8 @@ struct segment_type *init_error_segtype(struct cmd_context *cmd)
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_error_ops;
segtype->name = "error";
- segtype->private = NULL;
segtype->flags = SEG_CAN_SPLIT | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
log_very_verbose("Initialised segtype: %s", segtype->name);
diff --git a/lib/freeseg/freeseg.c b/lib/freeseg/freeseg.c
index b4eba94..71d7f8c 100644
--- a/lib/freeseg/freeseg.c
+++ b/lib/freeseg/freeseg.c
@@ -32,10 +32,8 @@ struct segment_type *init_free_segtype(struct cmd_context *cmd)
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_freeseg_ops;
segtype->name = "free";
- segtype->private = NULL;
segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
log_very_verbose("Initialised segtype: %s", segtype->name);
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 749b188..4635681 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -81,7 +81,6 @@ struct dev_manager;
struct segment_type {
struct dm_list list; /* Internal */
- struct cmd_context *cmd; /* lvm_register_segtype() sets this. */
uint32_t flags;
uint32_t parity_devs; /* Parity drives required by segtype */
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 46dfe02..7ab11c2 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -618,10 +618,8 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_mirrored_ops;
segtype->name = "mirror";
- segtype->private = NULL;
segtype->flags = SEG_MIRROR | SEG_AREAS_MIRRORED;
#ifdef DEVMAPPER_SUPPORT
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 7cc4301..6f4fe27 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -462,7 +462,7 @@ static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
rt->name);
return NULL;
}
- segtype->cmd = cmd;
+
segtype->ops = &_raid_ops;
segtype->name = rt->name;
segtype->flags = SEG_RAID | rt->extra_flags | monitored;
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index aefab3a..b64e533 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -258,10 +258,8 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_snapshot_ops;
segtype->name = "snapshot";
- segtype->private = NULL;
segtype->flags = SEG_SNAPSHOT | SEG_CANNOT_BE_ZEROED;
#ifdef DEVMAPPER_SUPPORT
diff --git a/lib/striped/striped.c b/lib/striped/striped.c
index dfd4518..1803077 100644
--- a/lib/striped/striped.c
+++ b/lib/striped/striped.c
@@ -228,10 +228,8 @@ struct segment_type *init_striped_segtype(struct cmd_context *cmd)
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_striped_ops;
segtype->name = "striped";
- segtype->private = NULL;
segtype->flags =
SEG_CAN_SPLIT | SEG_AREAS_STRIPED | SEG_FORMAT1_SUPPORT;
diff --git a/lib/unknown/unknown.c b/lib/unknown/unknown.c
index 760f1c2..3712c66 100644
--- a/lib/unknown/unknown.c
+++ b/lib/unknown/unknown.c
@@ -67,10 +67,8 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd, const char *n
return NULL;
}
- segtype->cmd = cmd;
segtype->ops = &_unknown_ops;
segtype->name = dm_pool_strdup(cmd->libmem, name);
- segtype->private = NULL;
segtype->flags = SEG_UNKNOWN | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
log_very_verbose("Initialised segtype: %s", segtype->name);
diff --git a/lib/zero/zero.c b/lib/zero/zero.c
index 9f9d06c..f07f288 100644
--- a/lib/zero/zero.c
+++ b/lib/zero/zero.c
@@ -90,10 +90,8 @@ struct segment_type *init_zero_segtype(struct cmd_context *cmd)
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_zero_ops;
segtype->name = "zero";
- segtype->private = NULL;
segtype->flags = SEG_CAN_SPLIT | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
log_very_verbose("Initialised segtype: %s", segtype->name);
diff --git a/tools/reporter.c b/tools/reporter.c
index 9688151..02f6064 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -100,7 +100,6 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
struct lvinfo lvinfo = { .exists = 0 };
struct segment_type _freeseg_type = {
- .cmd = cmd,
.name = "free",
.flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED,
};
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=87fc3b710c3b8fc6…
Commit: 87fc3b710c3b8fc656dcf48ec453e1da280ec696
Parent: 651613e9a40c9cc0aaf4a1c7c262ad394ac93ffb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 23:36:07 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:48 2014 +0100
lvcreate: improving recent lvcreate updates
We need to be able to parse:
lvcreate --type snapshot -s
lvcreate --type thin -s
lvcreate --type cache-pool -H
---
tools/lvcreate.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index e507858..6b8c4b5 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -153,6 +153,8 @@ static int _lvcreate_name_params(struct cmd_context *cmd,
vg_name = skip_dev_dir(cmd, argv[0], NULL);
if (!strchr(vg_name, '/')) {
+ if (lp->snapshot && arg_is_set(cmd, virtualsize_ARG))
+ lp->snapshot = 0 ; /* Sparse volume via thin-pool */
if (!_set_vg_name(lp, vg_name))
return_0;
} else {
@@ -639,10 +641,6 @@ static int _lvcreate_params(struct cmd_context *cmd,
segtype_str = "striped";
only_linear = 1; /* User requested linear only target */
}
- if (arg_from_list_is_set(cmd, "is conflicting with option --type",
- cache_ARG, thin_ARG, snapshot_ARG,
- -1))
- return_0;
/* More estimations from options after shortcuts */
} else if (arg_is_set(cmd, snapshot_ARG) &&
(arg_is_set(cmd, virtualoriginsize_ARG) ||
@@ -754,6 +752,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
LVCREATE_ARGS,
POOL_ARGS,
SIZE_ARGS,
+ cache_ARG,
chunksize_ARG,
-1))
return_0;
@@ -853,6 +852,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
SIZE_ARGS,
THIN_POOL_ARGS,
chunksize_ARG,
+ snapshot_ARG,
thin_ARG,
virtualsize_ARG,
wipesignatures_ARG, zero_ARG,
@@ -888,7 +888,8 @@ static int _lvcreate_params(struct cmd_context *cmd,
return_0;
} else /* Parse free arg as snapshot origin */
lp->snapshot = 1;
- }
+ } else if (arg_is_set(cmd, snapshot_ARG))
+ lp->snapshot = 1;
} else if (seg_is_thin_pool(lp)) {
if (arg_outside_list_is_set(cmd, "is unsupported with thin pools",
LVCREATE_ARGS,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=651613e9a40c9cc0…
Commit: 651613e9a40c9cc0aaf4a1c7c262ad394ac93ffb
Parent: e6e647489d49e02dbe9795371df7b154d30baf74
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 19:44:42 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:48 2014 +0100
man: update lvcreate with sparse
Document sparse device creation and its default segtype selection.
---
man/lvcreate.8.in | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index c843949..e2b6d91 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -155,7 +155,7 @@ 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
-.BR activation / auto_activation_volume_list
+.IR 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
@@ -291,7 +291,9 @@ The default is "\fIraid1\fP". See the
legacy "\fImirror\fP" segment type. See
.BR lvm.conf (5)
settings
-.BR global / mirror_segtype_default
+.IR global / mirror_segtype_default
+and
+.IR global / raid10_segtype_default
to configure default mirror segment type.
The options
\fB\-\-mirrorlog\fP and \fB\-\-corelog\fP apply
@@ -316,9 +318,9 @@ Starts or avoids monitoring a mirrored, snapshot or thin pool logical volume wit
dmeventd, if it is installed.
If a device used by a monitored mirror reports an I/O error,
the failure is handled according to
-.BR activation / mirror_image_fault_policy
+.IR activation / mirror_image_fault_policy
and
-.BR activation / mirror_log_fault_policy
+.IR activation / mirror_log_fault_policy
set in \fBlvm.conf\fP(5).
.TP
.IR \fB\-n ", " \fB\-\-name " " LogicalVolume { Name | Path }
@@ -531,8 +533,12 @@ or
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.
+Creates a thinly provisioned device or a sparse device of the given size (in MiB by default).
+See
+.BR lvm.conf (5)
+settings
+.IR global / sparse_segtype_default
+to configure default sparse segment type.
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.
@@ -546,12 +552,12 @@ 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
-.BR allocation / wipe_signatures_when_zeroing_new_lvs
+.IR allocation / wipe_signatures_when_zeroing_new_lvs
setting found in
.BR lvm.conf (5).
.br
If blkid wiping is used
-.BR allocation / use_blkid_wiping
+.IR 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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e6e647489d49e02d…
Commit: e6e647489d49e02dbe9795371df7b154d30baf74
Parent: e0164f21886a5b4964110bcac65535a670fdf6f3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 17:07:58 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:48 2014 +0100
configure: autoreconf
Just rebuild after configure.in update.
---
aclocal.m4 | 2 +-
configure | 194 +++++++++++++++++++++++++++++++++++++++---------------------
2 files changed, 127 insertions(+), 69 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 6f752f2..2325191 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
+# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
diff --git a/configure b/configure
index 6a15ed8..28651ac 100755
--- a/configure
+++ b/configure
@@ -697,16 +697,19 @@ DMEVENTD_PATH
DMEVENTD
DL_LIBS
DEVMAPPER
+DEFAULT_SYS_DIR
+DEFAULT_SPARSE_SEGTYPE
DEFAULT_RUN_DIR
+DEFAULT_RAID10_SEGTYPE
+DEFAULT_PROFILE_SUBDIR
DEFAULT_PID_DIR
-DEFAULT_DM_RUN_DIR
+DEFAULT_MIRROR_SEGTYPE
DEFAULT_LOCK_DIR
+DEFAULT_DM_RUN_DIR
DEFAULT_DATA_ALIGNMENT
-DEFAULT_PROFILE_SUBDIR
DEFAULT_CACHE_SUBDIR
DEFAULT_BACKUP_SUBDIR
DEFAULT_ARCHIVE_SUBDIR
-DEFAULT_SYS_DIR
DEBUG
COPTIMISE_FLAG
CONFDIR
@@ -870,7 +873,10 @@ with_cluster
with_snapshots
with_mirrors
with_raid
+with_default_mirror_segtype
+with_default_raid10r_segtype
with_replicators
+with_default_sparse_segtype
with_thin
with_thin_check
with_thin_dump
@@ -1638,52 +1644,53 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-user=USER set the owner of installed files [[USER=]]
- --with-group=GROUP set the group owner of installed files [[GROUP=]]
- --with-device-uid=UID set the owner used for new device nodes [[UID=0]]
- --with-device-gid=GID set the group used for new device nodes [[GID=0]]
- --with-device-mode=MODE set the mode used for new device nodes [[MODE=0600]]
+ --with-user=USER set the owner of installed files [USER=]
+ --with-group=GROUP set the group owner of installed files [GROUP=]
+ --with-device-uid=UID set the owner used for new device nodes [UID=0]
+ --with-device-gid=GID set the group used for new device nodes [GID=0]
+ --with-device-mode=MODE set the mode used for new device nodes [MODE=0600]
--with-device-nodes-on=ON
- create nodes on resume or create [[ON=resume]]
+ create nodes on resume or create [ON=resume]
--with-default-name-mangling=MANGLING
- default name mangling: auto/none/hex
- [[MANGLING=auto]]
+ default name mangling: auto/none/hex [auto]
--with-lvm1=TYPE LVM1 metadata support: internal/shared/none
- [[TYPE=internal]]
+ [internal]
--with-pool=TYPE GFS pool read-only support: internal/shared/none
- [[TYPE=internal]]
+ [internal]
--with-cluster=TYPE cluster LVM locking support: internal/shared/none
- [[TYPE=internal]]
- --with-snapshots=TYPE snapshot support: internal/shared/none
- [[TYPE=internal]]
- --with-mirrors=TYPE mirror support: internal/shared/none
- [[TYPE=internal]]
- --with-raid=TYPE raid support: internal/shared/none [[TYPE=internal]]
- --with-replicators=TYPE replicator support: internal/shared/none
- [[TYPE=none]]
+ [internal]
+ --with-snapshots=TYPE snapshot support: internal/shared/none [internal]
+ --with-mirrors=TYPE mirror support: internal/shared/none [internal]
+ --with-raid=TYPE raid support: internal/shared/none [internal]
+ --with-default-mirror-segtype=TYPE
+ default mirror segtype: raid1/mirror [raid1]
+ --with-default-raid10-segtype=TYPE
+ default mirror segtype: raid10/mirror [raid10]
+ --with-replicators=TYPE replicator support: internal/shared/none [none]
+ --with-default-sparse-segtype=TYPE
+ default sparse segtype: thin/snapshot [thin]
--with-thin=TYPE thin provisioning support: internal/shared/none
- [[TYPE=internal]]
- --with-thin-check=PATH thin_check tool: [[autodetect]]
- --with-thin-dump=PATH thin_dump tool: [[autodetect]]
- --with-thin-repair=PATH thin_repair tool: [[autodetect]]
+ [internal]
+ --with-thin-check=PATH thin_check tool: [autodetect]
+ --with-thin-dump=PATH thin_dump tool: [autodetect]
+ --with-thin-repair=PATH thin_repair tool: [autodetect]
--with-thin-restore=PATH
- thin_restore tool: [[autodetect]]
- --with-cache=TYPE cache support: internal/shared/none
- [[TYPE=internal]]
- --with-cache-check=PATH cache_check tool: [[autodetect]]
- --with-cache-dump=PATH cache_dump tool: [[autodetect]]
+ thin_restore tool: [autodetect]
+ --with-cache=TYPE cache support: internal/shared/none [internal]
+ --with-cache-check=PATH cache_check tool: [autodetect]
+ --with-cache-dump=PATH cache_dump tool: [autodetect]
--with-cache-repair=PATH
- cache_repair tool: [[autodetect]]
+ cache_repair tool: [autodetect]
--with-cache-restore=PATH
- cache_restore tool: [[autodetect]]
- --with-ocfdir=DIR install OCF files in DIR
- [[PREFIX/lib/ocf/resource.d/lvm2]]
+ cache_restore tool: [autodetect]
+ --with-ocfdir=DIR install OCF files in
+ [PREFIX/lib/ocf/resource.d/lvm2]
--with-default-pid-dir=PID_DIR
- Default directory to keep PID files in. [[/var/run]]
+ Default directory to keep PID files in. [/var/run]
--with-default-dm-run-dir=DM_RUN_DIR
- Default DM run directory. [[/var/run]]
+ Default DM run directory. [/var/run]
--with-default-run-dir=RUN_DIR
- Default LVM run directory. [[/var/run/lvm]]
+ Default LVM run directory. [/var/run/lvm]
--with-clvmd=TYPE build cluster LVM Daemon
The following cluster manager combinations are valid:
* cman (RHEL5 or equivalent)
@@ -1691,46 +1698,46 @@ Optional Packages:
* singlenode (localhost only)
* all (autodetect)
* none (disable build)
- [TYPE=none]
+ [none]
--with-clvmd-pidfile=PATH
- clvmd pidfile [[PID_DIR/clvmd.pid]]
+ clvmd pidfile [PID_DIR/clvmd.pid]
--with-cmirrord-pidfile=PATH
- cmirrord pidfile [[PID_DIR/cmirrord.pid]]
- --with-optimisation=OPT C optimisation flag [[OPT=-O2]]
+ cmirrord pidfile [PID_DIR/cmirrord.pid]
+ --with-optimisation=OPT C optimisation flag [OPT=-O2]
--with-lvmetad-pidfile=PATH
- lvmetad pidfile [[PID_DIR/lvmetad.pid]]
- --with-localedir=DIR translation files in DIR [[PREFIX/share/locale]]
- --with-confdir=DIR configuration files in DIR [[/etc]]
- --with-staticdir=DIR static binaries in DIR [[EPREFIX/sbin]]
- --with-usrlibdir=DIR usrlib in DIR [[PREFIX/lib]]
- --with-usrsbindir=DIR usrsbin executables in DIR [[PREFIX/sbin]]
+ lvmetad pidfile [PID_DIR/lvmetad.pid]
+ --with-localedir=DIR translation files in DIR [PREFIX/share/locale]
+ --with-confdir=DIR configuration files in DIR [/etc]
+ --with-staticdir=DIR static binaries in DIR [EPREFIX/sbin]
+ --with-usrlibdir=DIR usrlib in DIR [PREFIX/lib]
+ --with-usrsbindir=DIR usrsbin executables in DIR [PREFIX/sbin]
--with-udev-prefix=UPREFIX
- install udev rule files in UPREFIX [[EPREFIX]]
- --with-udevdir=DIR udev rules in DIR [[UPREFIX/lib/udev/rules.d]]
+ install udev rule files in UPREFIX [EPREFIX]
+ --with-udevdir=DIR udev rules in DIR [UPREFIX/lib/udev/rules.d]
--with-systemdsystemunitdir=DIR
systemd service files in DIR
--with-tmpfilesdir=DIR install configuration files for management of
volatile files and directories in DIR
- [[PREFIX/lib/tmpfiles.d]]
+ [PREFIX/lib/tmpfiles.d]
--with-dmeventd-pidfile=PATH
- dmeventd pidfile [[PID_DIR/dmeventd.pid]]
+ dmeventd pidfile [PID_DIR/dmeventd.pid]
--with-dmeventd-path=PATH
- dmeventd path [[EPREFIX/sbin/dmeventd]]
+ dmeventd path [EPREFIX/sbin/dmeventd]
--with-default-system-dir=DIR
- default LVM system directory [[/etc/lvm]]
+ default LVM system directory [/etc/lvm]
--with-default-profile-subdir=SUBDIR
- default configuration profile subdir [[profile]]
+ default configuration profile subdir [profile]
--with-default-archive-subdir=SUBDIR
- default metadata archive subdir [[archive]]
+ default metadata archive subdir [archive]
--with-default-backup-subdir=SUBDIR
- default metadata backup subdir [[backup]]
+ default metadata backup subdir [backup]
--with-default-cache-subdir=SUBDIR
- default metadata cache subdir [[cache]]
+ default metadata cache subdir [cache]
--with-default-locking-dir=DIR
- default locking directory [[/var/lock/lvm]]
+ default locking directory [/var/lock/lvm]
--with-default-data-alignment=NUM
- set the default data alignment in MiB [[1]]
- --with-interface=IFACE choose kernel interface (ioctl) [[ioctl]]
+ set the default data alignment in MiB [1]
+ --with-interface=IFACE choose kernel interface (ioctl) [ioctl]
Some influential environment variables:
CC C compiler command
@@ -7244,14 +7251,44 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RAID" >&5
$as_echo "$RAID" >&6; }
+
+# Check whether --with-default-mirror-segtype was given.
+if test "${with_default_mirror_segtype+set}" = set; then :
+ withval=$with_default_mirror_segtype; DEFAULT_MIRROR_SEGTYPE=$withval
+else
+ DEFAULT_MIRROR_SEGTYPE="raid1"
+fi
+
+
+# Check whether --with-default-raid10r-segtype was given.
+if test "${with_default_raid10r_segtype+set}" = set; then :
+ withval=$with_default_raid10r_segtype; DEFAULT_RAID10_SEGTYPE=$withval
+else
+ DEFAULT_RAID10_SEGTYPE="raid10"
+fi
+
case "$RAID" in
- none|shared) ;;
+ none) test "$DEFAULT_MIRROR_SEGTYPE" = "raid1" && DEFAULT_MIRROR_SEGTYPE="mirror"
+ test "$DEFAULT_RAID10_SEGTYPE" = "raid10" && DEFAULT_RAID10_SEGTYPE="mirror" ;;
+ shared) ;;
internal)
$as_echo "#define RAID_INTERNAL 1" >>confdefs.h
;;
*) as_fn_error $? "--with-raid parameter invalid" "$LINENO" 5 ;;
esac
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_MIRROR_SEGTYPE "$DEFAULT_MIRROR_SEGTYPE"
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_RAID10_SEGTYPE "$DEFAULT_RAID10_SEGTYPE"
+_ACEOF
+
+
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include replicators" >&5
$as_echo_n "checking whether to include replicators... " >&6; }
@@ -7274,6 +7311,16 @@ $as_echo "#define REPLICATOR_INTERNAL 1" >>confdefs.h
*) as_fn_error $? "--with-replicators parameter invalid ($REPLICATORS)" "$LINENO" 5 ;;
esac
+
+
+# Check whether --with-default-sparse-segtype was given.
+if test "${with_default_sparse_segtype+set}" = set; then :
+ withval=$with_default_sparse_segtype; DEFAULT_SPARSE_SEGTYPE=$withval
+else
+ DEFAULT_SPARSE_SEGTYPE="thin"
+fi
+
+
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include thin provisioning" >&5
$as_echo_n "checking whether to include thin provisioning... " >&6; }
@@ -7322,13 +7369,20 @@ fi
$as_echo "$THIN" >&6; }
case "$THIN" in
- none|shared) ;;
+ none) test "$DEFAULT_SPARSE_SEGTYPE" = "thin" && DEFAULT_SPARSE_SEGTYPE="snapshot" ;;
+ shared) ;;
internal)
$as_echo "#define THIN_INTERNAL 1" >>confdefs.h
;;
*) as_fn_error $? "--with-thin parameter invalid ($THIN)" "$LINENO" 5 ;;
esac
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_SPARSE_SEGTYPE "$DEFAULT_SPARSE_SEGTYPE"
+_ACEOF
+
+
# Check whether --enable-thin_check_needs_check was given.
if test "${enable_thin_check_needs_check+set}" = set; then :
enableval=$enable_thin_check_needs_check; THIN_CHECK_NEEDS_CHECK=$enableval
@@ -7786,18 +7840,19 @@ $as_echo "$as_me: WARNING: thin_restore not found in path $PATH" >&2;}
THIN_CONFIGURE_WARN=y
}
fi
- ;;
-esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether thin_check supports the needs-check flag" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether thin_check supports the needs-check flag" >&5
$as_echo_n "checking whether thin_check supports the needs-check flag... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $THIN_CHECK_NEEDS_CHECK" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THIN_CHECK_NEEDS_CHECK" >&5
$as_echo "$THIN_CHECK_NEEDS_CHECK" >&6; }
-if test "$THIN_CHECK_NEEDS_CHECK" = yes; then
+ if test "$THIN_CHECK_NEEDS_CHECK" = yes; then
$as_echo "#define THIN_CHECK_NEEDS_CHECK 1" >>confdefs.h
-fi
+ fi
+
+ ;;
+esac
cat >>confdefs.h <<_ACEOF
@@ -12602,6 +12657,9 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
+
+
+
################################################################################
ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile conf/Makefile conf/example.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile
python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e0164f21886a5b49…
Commit: e0164f21886a5b4964110bcac65535a670fdf6f3
Parent: 87f59af15ce315bb76ebaa176dd458295f607816
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 23:38:02 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:58:48 2014 +0100
sparse: configurable type for sparse volumes
Support compile type configurable defaults for creation
of sparse volumes.
By default now create 'thin-pools' for sparse volumes.
Use the global/sparse_segtype_default to switch back to old
snapshots if needed.
Apply the same compile logic for newly introduces mirror/raid1 options.
---
WHATS_NEW | 1 +
conf/example.conf.in | 22 ++++++++++++++++-
configure.in | 52 +++++++++++++++++++++++++++++++++---------
lib/config/config_settings.h | 1 +
lib/config/defaults.h | 5 +--
lib/misc/configure.h.in | 9 +++++++
tools/lvcreate.c | 16 +++++++++----
7 files changed, 85 insertions(+), 21 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5ad246c..e59e0f4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Configurable support for creation of sparse volumes with thin-pools.
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.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index d1da23f..d1a1397 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -646,7 +646,7 @@ global {
#
# Specify the '--type <mirror|raid1>' option to override this default
# setting.
- mirror_segtype_default = "raid1"
+ mirror_segtype_default = "@DEFAULT_MIRROR_SEGTYPE@"
# 'raid10_segtype_default' determines the segment types used by default
# when the '--stripes/-i' and '--mirrors/-m' arguments are both specified
@@ -663,7 +663,25 @@ global {
# this setting is not advised.
# Specify the '--type <raid10|mirror>' option to override this default
# setting.
- raid10_segtype_default = "raid10"
+ raid10_segtype_default = "@DEFAULT_RAID10_SEGTYPE@"
+
+ # 'sparse_segtype_default' defines which segtype will be used when the
+ # shorthand '-V and -L' option is used for sparse volume creation.
+ #
+ # "snapshot" - The original snapshot implementation provided by LVM2/DM.
+ # It is using old snashot that mixes data and metadata within
+ # a single COW storage volume and has poor performs when
+ # the size of stored data passes hundereds of MB.
+ #
+ # "thin" - Newer implementation leverages thin provisioning target.
+ # It has bigger minimal chunk size (64KiB) and uses separate volume
+ # for metadata. It has better performance especially in case of
+ # bigger data uses. This device type has also full snapshot support.
+ #
+ # Specify the '--type <snapshot|thin>' option to override this default
+ # setting.
+ sparse_segtype_default = "@DEFAULT_SPARSE_SEGTYPE@"
+
# The default format for displaying LV names in lvdisplay was changed
# in version 2.02.89 to show the LV name and path separately.
diff --git a/configure.in b/configure.in
index 8d47bc7..9e10dc3 100644
--- a/configure.in
+++ b/configure.in
@@ -349,13 +349,29 @@ AC_ARG_WITH(raid,
RAID=$withval, RAID=internal)
AC_MSG_RESULT($RAID)
+AC_ARG_WITH(default-mirror-segtype,
+ AC_HELP_STRING([--with-default-mirror-segtype=TYPE],
+ [default mirror segtype: raid1/mirror [raid1]]),
+ DEFAULT_MIRROR_SEGTYPE=$withval, DEFAULT_MIRROR_SEGTYPE="raid1")
+AC_ARG_WITH(default-raid10r-segtype,
+ AC_HELP_STRING([--with-default-raid10-segtype=TYPE],
+ [default mirror segtype: raid10/mirror [raid10]]),
+ DEFAULT_RAID10_SEGTYPE=$withval, DEFAULT_RAID10_SEGTYPE="raid10")
case "$RAID" in
- none|shared) ;;
+ none) test "$DEFAULT_MIRROR_SEGTYPE" = "raid1" && DEFAULT_MIRROR_SEGTYPE="mirror"
+ test "$DEFAULT_RAID10_SEGTYPE" = "raid10" && DEFAULT_RAID10_SEGTYPE="mirror" ;;
+ shared) ;;
internal) AC_DEFINE([RAID_INTERNAL], 1,
[Define to 1 to include built-in support for raid.]) ;;
*) AC_MSG_ERROR([--with-raid parameter invalid]) ;;
esac
+AC_DEFINE_UNQUOTED([DEFAULT_MIRROR_SEGTYPE], ["$DEFAULT_MIRROR_SEGTYPE"],
+ [Default segtype used for mirror volumes.])
+
+AC_DEFINE_UNQUOTED([DEFAULT_RAID10_SEGTYPE], ["$DEFAULT_RAID10_SEGTYPE"],
+ [Default segtype used for raid10 volumes.])
+
################################################################################
dnl -- asynchronous volume replicator inclusion type
AC_MSG_CHECKING(whether to include replicators)
@@ -372,6 +388,12 @@ case "$REPLICATORS" in
*) AC_MSG_ERROR([--with-replicators parameter invalid ($REPLICATORS)]) ;;
esac
+
+AC_ARG_WITH(default-sparse-segtype,
+ AC_HELP_STRING([--with-default-sparse-segtype=TYPE],
+ [default sparse segtype: thin/snapshot [thin]]),
+ DEFAULT_SPARSE_SEGTYPE=$withval, DEFAULT_SPARSE_SEGTYPE="thin")
+
################################################################################
dnl -- thin provisioning
AC_MSG_CHECKING(whether to include thin provisioning)
@@ -399,12 +421,16 @@ AC_ARG_WITH(thin-restore,
AC_MSG_RESULT($THIN)
case "$THIN" in
- none|shared) ;;
+ none) test "$DEFAULT_SPARSE_SEGTYPE" = "thin" && DEFAULT_SPARSE_SEGTYPE="snapshot" ;;
+ shared) ;;
internal) AC_DEFINE([THIN_INTERNAL], 1,
[Define to 1 to include built-in support for thin provisioning.]) ;;
*) AC_MSG_ERROR([--with-thin parameter invalid ($THIN)]) ;;
esac
+AC_DEFINE_UNQUOTED([DEFAULT_SPARSE_SEGTYPE], ["$DEFAULT_SPARSE_SEGTYPE"],
+ [Default segtype used for sparse volumes.])
+
dnl -- thin_check needs-check flag
AC_ARG_ENABLE(thin_check_needs_check,
AC_HELP_STRING([--disable-thin_check_needs_check],
@@ -466,15 +492,16 @@ case "$THIN" in
THIN_CONFIGURE_WARN=y
}
fi
+
+ AC_MSG_CHECKING([whether thin_check supports the needs-check flag])
+ AC_MSG_RESULT([$THIN_CHECK_NEEDS_CHECK])
+ if test "$THIN_CHECK_NEEDS_CHECK" = yes; then
+ AC_DEFINE([THIN_CHECK_NEEDS_CHECK], 1, [Define to 1 if the external 'thin_check' tool requires the --clear-needs-check-flag option])
+ fi
+
;;
esac
-AC_MSG_CHECKING([whether thin_check supports the needs-check flag])
-AC_MSG_RESULT([$THIN_CHECK_NEEDS_CHECK])
-if test "$THIN_CHECK_NEEDS_CHECK" = yes; then
- AC_DEFINE([THIN_CHECK_NEEDS_CHECK], 1, [Define to 1 if the external 'thin_check' tool requires the --clear-needs-check-flag option])
-fi
-
AC_DEFINE_UNQUOTED([THIN_CHECK_CMD], ["$THIN_CHECK_CMD"],
[The path to 'thin_check', if available.])
@@ -1645,16 +1672,19 @@ AC_SUBST(CPG_CFLAGS)
AC_SUBST(CPG_LIBS)
AC_SUBST(CSCOPE_CMD)
AC_SUBST(DEBUG)
-AC_SUBST(DEFAULT_SYS_DIR)
AC_SUBST(DEFAULT_ARCHIVE_SUBDIR)
AC_SUBST(DEFAULT_BACKUP_SUBDIR)
AC_SUBST(DEFAULT_CACHE_SUBDIR)
-AC_SUBST(DEFAULT_PROFILE_SUBDIR)
AC_SUBST(DEFAULT_DATA_ALIGNMENT)
-AC_SUBST(DEFAULT_LOCK_DIR)
AC_SUBST(DEFAULT_DM_RUN_DIR)
+AC_SUBST(DEFAULT_LOCK_DIR)
+AC_SUBST(DEFAULT_MIRROR_SEGTYPE)
AC_SUBST(DEFAULT_PID_DIR)
+AC_SUBST(DEFAULT_PROFILE_SUBDIR)
+AC_SUBST(DEFAULT_RAID10_SEGTYPE)
AC_SUBST(DEFAULT_RUN_DIR)
+AC_SUBST(DEFAULT_SPARSE_SEGTYPE)
+AC_SUBST(DEFAULT_SYS_DIR)
AC_SUBST(DEVMAPPER)
AC_SUBST(DLM_CFLAGS)
AC_SUBST(DLM_LIBS)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index a6c1d1b..e944b81 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -175,6 +175,7 @@ cfg(global_detect_internal_vg_cache_corruption_CFG, "detect_internal_vg_cache_co
cfg(global_metadata_read_only_CFG, "metadata_read_only", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_METADATA_READ_ONLY, vsn(2, 2, 75), NULL)
cfg(global_mirror_segtype_default_CFG, "mirror_segtype_default", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_MIRROR_SEGTYPE, vsn(2, 2, 87), NULL)
cfg(global_raid10_segtype_default_CFG, "raid10_segtype_default", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_RAID10_SEGTYPE, vsn(2, 2, 99), NULL)
+cfg(global_sparse_segtype_default_CFG, "sparse_segtype_default", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_SPARSE_SEGTYPE, vsn(2, 2, 112), NULL)
cfg(global_lvdisplay_shows_full_device_path_CFG, "lvdisplay_shows_full_device_path", global_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_LVDISPLAY_SHOWS_FULL_DEVICE_PATH, vsn(2, 2, 89), NULL)
cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 93), NULL)
cfg(global_thin_check_executable_CFG, "thin_check_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_CHECK_CMD, vsn(2, 2, 94), NULL)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 2724cd1..acf768b 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -52,13 +52,12 @@
#define DEFAULT_METADATA_READ_ONLY 0
#define DEFAULT_LVDISPLAY_SHOWS_FULL_DEVICE_PATH 0
-#define DEFAULT_MIRROR_SEGTYPE "raid1"
#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 */
-#define DEFAULT_RAID10_SEGTYPE "raid10"
#define DEFAULT_RAID_FAULT_POLICY "warn"
+
#define DEFAULT_DMEVENTD_RAID_LIB "libdevmapper-event-lvm2raid.so"
#define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
#define DEFAULT_DMEVENTD_SNAPSHOT_LIB "libdevmapper-event-lvm2snapshot.so"
diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in
index f137f14..7c0d64c 100644
--- a/lib/misc/configure.h.in
+++ b/lib/misc/configure.h.in
@@ -68,18 +68,27 @@
/* Name of default locking directory. */
#undef DEFAULT_LOCK_DIR
+/* Default segtype used for mirror volumes. */
+#undef DEFAULT_MIRROR_SEGTYPE
+
/* Default directory to keep PID files in. */
#undef DEFAULT_PID_DIR
/* Name of default configuration profile subdirectory. */
#undef DEFAULT_PROFILE_SUBDIR
+/* Default segtype used for raid10 volumes. */
+#undef DEFAULT_RAID10_SEGTYPE
+
/* Default LVM run directory. */
#undef DEFAULT_RUN_DIR
/* Define to 0 to reinstate the pre-2.02.54 handling of unit suffixes. */
#undef DEFAULT_SI_UNIT_CONSISTENCY
+/* Default segtype used for sparse volumes. */
+#undef DEFAULT_SPARSE_SEGTYPE
+
/* Path to LVM system directory. */
#undef DEFAULT_SYS_DIR
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 78b6898..e507858 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -644,15 +644,21 @@ static int _lvcreate_params(struct cmd_context *cmd,
-1))
return_0;
/* More estimations from options after shortcuts */
- } else if (arg_is_set(cmd, snapshot_ARG))
+ } else if (arg_is_set(cmd, snapshot_ARG) &&
+ (arg_is_set(cmd, virtualoriginsize_ARG) ||
+ !arg_is_set(cmd, virtualsize_ARG)))
/* Snapshot has higher priority then thin */
segtype_str = "snapshot"; /* --thinpool makes thin volume */
- else if (arg_is_set(cmd, cache_ARG) || arg_count(cmd, cachepool_ARG))
+ else if (arg_is_set(cmd, cache_ARG) || arg_is_set(cmd, cachepool_ARG))
segtype_str = "cache";
- else if (arg_count(cmd, thin_ARG) || arg_count(cmd, thinpool_ARG) ||
- arg_is_set(cmd, virtualsize_ARG))
+ else if (arg_is_set(cmd, thin_ARG) || arg_is_set(cmd, thinpool_ARG))
segtype_str = "thin";
- else if (arg_uint_value(cmd, mirrors_ARG, 0)) {
+ else if (arg_is_set(cmd, virtualsize_ARG)) {
+ if (arg_is_set(cmd, virtualoriginsize_ARG))
+ segtype_str = "snapshot";
+ else
+ segtype_str = find_config_tree_str(cmd, global_sparse_segtype_default_CFG, NULL);
+ } else if (arg_uint_value(cmd, mirrors_ARG, 0)) {
/* Remember, '-m 0' implies stripe */
mirror_default_cfg = (arg_uint_value(cmd, stripes_ARG, 1) > 1)
? global_raid10_segtype_default_CFG : global_mirror_segtype_default_CFG;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=87f59af15ce315bb…
Commit: 87f59af15ce315bb76ebaa176dd458295f607816
Parent: 7049eeeb839b59314d07c0bac250c89cf8ac78f8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 17:13:05 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 30 23:51:39 2014 +0100
configure: option cleanup
Drop double [[ ]] around default args.
(AC_HELP_STRING is already quoted so double [[]] are not needed).
---
configure.in | 111 ++++++++++++++++++++++++++-------------------------------
1 files changed, 51 insertions(+), 60 deletions(-)
diff --git a/configure.in b/configure.in
index 3956ff0..8d47bc7 100644
--- a/configure.in
+++ b/configure.in
@@ -173,7 +173,7 @@ dnl -- Setup the ownership of the files
AC_MSG_CHECKING(file owner)
AC_ARG_WITH(user,
AC_HELP_STRING([--with-user=USER],
- [set the owner of installed files [[USER=]]]),
+ [set the owner of installed files [USER=]]),
OWNER=$withval)
AC_MSG_RESULT($OWNER)
test -n "$OWNER" && INSTALL="$INSTALL -o $OWNER"
@@ -183,7 +183,7 @@ dnl -- Setup the group ownership of the files
AC_MSG_CHECKING(group owner)
AC_ARG_WITH(group,
AC_HELP_STRING([--with-group=GROUP],
- [set the group owner of installed files [[GROUP=]]]),
+ [set the group owner of installed files [GROUP=]]),
GROUP=$withval)
AC_MSG_RESULT($GROUP)
test -n "$GROUP" && INSTALL="$INSTALL -g $GROUP"
@@ -194,7 +194,7 @@ AC_MSG_CHECKING(device node uid)
AC_ARG_WITH(device-uid,
AC_HELP_STRING([--with-device-uid=UID],
- [set the owner used for new device nodes [[UID=0]]]),
+ [set the owner used for new device nodes [UID=0]]),
DM_DEVICE_UID=$withval, DM_DEVICE_UID=0)
AC_MSG_RESULT($DM_DEVICE_UID)
@@ -204,7 +204,7 @@ AC_MSG_CHECKING(device node gid)
AC_ARG_WITH(device-gid,
AC_HELP_STRING([--with-device-gid=GID],
- [set the group used for new device nodes [[GID=0]]]),
+ [set the group used for new device nodes [GID=0]]),
DM_DEVICE_GID=$withval, DM_DEVICE_GID=0)
AC_MSG_RESULT($DM_DEVICE_GID)
@@ -214,14 +214,14 @@ AC_MSG_CHECKING(device node mode)
AC_ARG_WITH(device-mode,
AC_HELP_STRING([--with-device-mode=MODE],
- [set the mode used for new device nodes [[MODE=0600]]]),
+ [set the mode used for new device nodes [MODE=0600]]),
DM_DEVICE_MODE=$withval, DM_DEVICE_MODE=0600)
AC_MSG_RESULT($DM_DEVICE_MODE)
AC_MSG_CHECKING(when to create device nodes)
AC_ARG_WITH(device-nodes-on,
AC_HELP_STRING([--with-device-nodes-on=ON],
- [create nodes on resume or create [[ON=resume]]]),
+ [create nodes on resume or create [ON=resume]]),
ADD_NODE=$withval, ADD_NODE=resume)
case "$ADD_NODE" in
resume) add_on=DM_ADD_NODE_ON_RESUME;;
@@ -234,7 +234,7 @@ AC_DEFINE_UNQUOTED([DEFAULT_DM_ADD_NODE], $add_on, [Define default node creation
AC_MSG_CHECKING(default name mangling)
AC_ARG_WITH(default-name-mangling,
AC_HELP_STRING([--with-default-name-mangling=MANGLING],
- [default name mangling: auto/none/hex [[MANGLING=auto]]]),
+ [default name mangling: auto/none/hex [auto]]),
MANGLING=$withval, MANGLING=auto)
case "$MANGLING" in
auto) mangling=DM_STRING_MANGLING_AUTO;;
@@ -264,8 +264,7 @@ dnl -- format1 inclusion type
AC_MSG_CHECKING(whether to include support for lvm1 metadata)
AC_ARG_WITH(lvm1,
AC_HELP_STRING([--with-lvm1=TYPE],
- [LVM1 metadata support: internal/shared/none
- [[TYPE=internal]]]),
+ [LVM1 metadata support: internal/shared/none [internal]]),
LVM1=$withval, LVM1=internal)
AC_MSG_RESULT($LVM1)
@@ -282,8 +281,7 @@ dnl -- format_pool inclusion type
AC_MSG_CHECKING(whether to include support for GFS pool metadata)
AC_ARG_WITH(pool,
AC_HELP_STRING([--with-pool=TYPE],
- [GFS pool read-only support: internal/shared/none
- [[TYPE=internal]]]),
+ [GFS pool read-only support: internal/shared/none [internal]]),
POOL=$withval, POOL=internal)
AC_MSG_RESULT($POOL)
@@ -299,8 +297,7 @@ dnl -- cluster_locking inclusion type
AC_MSG_CHECKING(whether to include support for cluster locking)
AC_ARG_WITH(cluster,
AC_HELP_STRING([--with-cluster=TYPE],
- [cluster LVM locking support: internal/shared/none
- [[TYPE=internal]]]),
+ [cluster LVM locking support: internal/shared/none [internal]]),
CLUSTER=$withval)
AC_MSG_RESULT($CLUSTER)
@@ -316,8 +313,7 @@ dnl -- snapshots inclusion type
AC_MSG_CHECKING(whether to include snapshots)
AC_ARG_WITH(snapshots,
AC_HELP_STRING([--with-snapshots=TYPE],
- [snapshot support: internal/shared/none
- [[TYPE=internal]]]),
+ [snapshot support: internal/shared/none [internal]]),
SNAPSHOTS=$withval, SNAPSHOTS=internal)
AC_MSG_RESULT($SNAPSHOTS)
@@ -333,8 +329,7 @@ dnl -- mirrors inclusion type
AC_MSG_CHECKING(whether to include mirrors)
AC_ARG_WITH(mirrors,
AC_HELP_STRING([--with-mirrors=TYPE],
- [mirror support: internal/shared/none
- [[TYPE=internal]]]),
+ [mirror support: internal/shared/none [internal]]),
MIRRORS=$withval, MIRRORS=internal)
AC_MSG_RESULT($MIRRORS)
@@ -350,8 +345,7 @@ dnl -- raid inclusion type
AC_MSG_CHECKING(whether to include raid)
AC_ARG_WITH(raid,
AC_HELP_STRING([--with-raid=TYPE],
- [raid support: internal/shared/none
- [[TYPE=internal]]]),
+ [raid support: internal/shared/none [internal]]),
RAID=$withval, RAID=internal)
AC_MSG_RESULT($RAID)
@@ -367,8 +361,7 @@ dnl -- asynchronous volume replicator inclusion type
AC_MSG_CHECKING(whether to include replicators)
AC_ARG_WITH(replicators,
AC_HELP_STRING([--with-replicators=TYPE],
- [replicator support: internal/shared/none
- [[TYPE=none]]]),
+ [replicator support: internal/shared/none [none]]),
REPLICATORS=$withval, REPLICATORS=none)
AC_MSG_RESULT($REPLICATORS)
@@ -384,24 +377,23 @@ dnl -- thin provisioning
AC_MSG_CHECKING(whether to include thin provisioning)
AC_ARG_WITH(thin,
AC_HELP_STRING([--with-thin=TYPE],
- [thin provisioning support: internal/shared/none
- [[TYPE=internal]]]),
+ [thin provisioning support: internal/shared/none [internal]]),
THIN=$withval, THIN=internal)
AC_ARG_WITH(thin-check,
AC_HELP_STRING([--with-thin-check=PATH],
- [thin_check tool: [[autodetect]]]),
+ [thin_check tool: [autodetect]]),
THIN_CHECK_CMD=$withval, THIN_CHECK_CMD="autodetect")
AC_ARG_WITH(thin-dump,
AC_HELP_STRING([--with-thin-dump=PATH],
- [thin_dump tool: [[autodetect]]]),
+ [thin_dump tool: [autodetect]]),
THIN_DUMP_CMD=$withval, THIN_DUMP_CMD="autodetect")
AC_ARG_WITH(thin-repair,
AC_HELP_STRING([--with-thin-repair=PATH],
- [thin_repair tool: [[autodetect]]]),
+ [thin_repair tool: [autodetect]]),
THIN_REPAIR_CMD=$withval, THIN_REPAIR_CMD="autodetect")
AC_ARG_WITH(thin-restore,
AC_HELP_STRING([--with-thin-restore=PATH],
- [thin_restore tool: [[autodetect]]]),
+ [thin_restore tool: [autodetect]]),
THIN_RESTORE_CMD=$withval, THIN_RESTORE_CMD="autodetect")
AC_MSG_RESULT($THIN)
@@ -500,23 +492,23 @@ dnl -- cache inclusion type
AC_MSG_CHECKING(whether to include cache)
AC_ARG_WITH(cache,
AC_HELP_STRING([--with-cache=TYPE],
- [cache support: internal/shared/none [[TYPE=internal]]]),
+ [cache support: internal/shared/none [internal]]),
CACHE=$withval, CACHE="internal")
AC_ARG_WITH(cache-check,
AC_HELP_STRING([--with-cache-check=PATH],
- [cache_check tool: [[autodetect]]]),
+ [cache_check tool: [autodetect]]),
CACHE_CHECK_CMD=$withval, CACHE_CHECK_CMD="autodetect")
AC_ARG_WITH(cache-dump,
AC_HELP_STRING([--with-cache-dump=PATH],
- [cache_dump tool: [[autodetect]]]),
+ [cache_dump tool: [autodetect]]),
CACHE_DUMP_CMD=$withval, CACHE_DUMP_CMD="autodetect")
AC_ARG_WITH(cache-repair,
AC_HELP_STRING([--with-cache-repair=PATH],
- [cache_repair tool: [[autodetect]]]),
+ [cache_repair tool: [autodetect]]),
CACHE_REPAIR_CMD=$withval, CACHE_REPAIR_CMD="autodetect")
AC_ARG_WITH(cache-restore,
AC_HELP_STRING([--with-cache-restore=PATH],
- [cache_restore tool: [[autodetect]]]),
+ [cache_restore tool: [autodetect]]),
CACHE_RESTORE_CMD=$withval, CACHE_RESTORE_CMD="autodetect")
AC_MSG_RESULT($CACHE)
@@ -608,7 +600,7 @@ AC_ARG_ENABLE(ocf,
AC_MSG_RESULT($OCF)
AC_ARG_WITH(ocfdir,
AC_HELP_STRING([--with-ocfdir=DIR],
- [install OCF files in DIR [[PREFIX/lib/ocf/resource.d/lvm2]]]),
+ [install OCF files in [PREFIX/lib/ocf/resource.d/lvm2]]),
OCFDIR=$withval, OCFDIR='${prefix}/lib/ocf/resource.d/lvm2')
################################################################################
@@ -629,7 +621,7 @@ dnl -- Set up pidfile and run directory
AH_TEMPLATE(DEFAULT_PID_DIR)
AC_ARG_WITH(default-pid-dir,
AC_HELP_STRING([--with-default-pid-dir=PID_DIR],
- [Default directory to keep PID files in. [[/var/run]]]),
+ [Default directory to keep PID files in. [/var/run]]),
DEFAULT_PID_DIR="$withval", DEFAULT_PID_DIR="/var/run")
AC_DEFINE_UNQUOTED(DEFAULT_PID_DIR, ["$DEFAULT_PID_DIR"],
[Default directory to keep PID files in.])
@@ -637,7 +629,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_PID_DIR, ["$DEFAULT_PID_DIR"],
AH_TEMPLATE(DEFAULT_DM_RUN_DIR, [Name of default DM run directory.])
AC_ARG_WITH(default-dm-run-dir,
AC_HELP_STRING([--with-default-dm-run-dir=DM_RUN_DIR],
- [ Default DM run directory. [[/var/run]]]),
+ [ Default DM run directory. [/var/run]]),
DEFAULT_DM_RUN_DIR="$withval", DEFAULT_DM_RUN_DIR="/var/run")
AC_DEFINE_UNQUOTED(DEFAULT_DM_RUN_DIR, ["$DEFAULT_DM_RUN_DIR"],
[Default DM run directory.])
@@ -645,7 +637,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_DM_RUN_DIR, ["$DEFAULT_DM_RUN_DIR"],
AH_TEMPLATE(DEFAULT_RUN_DIR, [Name of default LVM run directory.])
AC_ARG_WITH(default-run-dir,
AC_HELP_STRING([--with-default-run-dir=RUN_DIR],
- [Default LVM run directory. [[/var/run/lvm]]]),
+ [Default LVM run directory. [/var/run/lvm]]),
DEFAULT_RUN_DIR="$withval", DEFAULT_RUN_DIR="/var/run/lvm")
AC_DEFINE_UNQUOTED(DEFAULT_RUN_DIR, ["$DEFAULT_RUN_DIR"],
[Default LVM run directory.])
@@ -661,7 +653,7 @@ AC_ARG_WITH(clvmd,
* singlenode (localhost only)
* all (autodetect)
* none (disable build)
- [[TYPE=none]]],
+ [[none]]],
CLVMD=$withval, CLVMD=none)
test "$CLVMD" = yes && CLVMD=all
AC_MSG_RESULT($CLVMD)
@@ -878,7 +870,7 @@ dnl -- clvmd pidfile
if test "$CLVMD" != none; then
AC_ARG_WITH(clvmd-pidfile,
AC_HELP_STRING([--with-clvmd-pidfile=PATH],
- [clvmd pidfile [[PID_DIR/clvmd.pid]]]),
+ [clvmd pidfile [PID_DIR/clvmd.pid]]),
CLVMD_PIDFILE=$withval,
CLVMD_PIDFILE="$DEFAULT_PID_DIR/clvmd.pid")
AC_DEFINE_UNQUOTED(CLVMD_PIDFILE, ["$CLVMD_PIDFILE"],
@@ -901,7 +893,7 @@ dnl -- cmirrord pidfile
if test "$BUILD_CMIRRORD" = yes; then
AC_ARG_WITH(cmirrord-pidfile,
AC_HELP_STRING([--with-cmirrord-pidfile=PATH],
- [cmirrord pidfile [[PID_DIR/cmirrord.pid]]]),
+ [cmirrord pidfile [PID_DIR/cmirrord.pid]]),
CMIRRORD_PIDFILE=$withval,
CMIRRORD_PIDFILE="$DEFAULT_PID_DIR/cmirrord.pid")
AC_DEFINE_UNQUOTED(CMIRRORD_PIDFILE, ["$CMIRRORD_PIDFILE"],
@@ -948,7 +940,7 @@ dnl -- Override optimisation
AC_MSG_CHECKING(for C optimisation flag)
AC_ARG_WITH(optimisation,
AC_HELP_STRING([--with-optimisation=OPT],
- [C optimisation flag [[OPT=-O2]]]),
+ [C optimisation flag [OPT=-O2]]),
COPTIMISE_FLAG=$withval)
AC_MSG_RESULT($COPTIMISE_FLAG)
@@ -1040,7 +1032,7 @@ if test "$BUILD_LVMETAD" = yes; then
AC_ARG_WITH(lvmetad-pidfile,
AC_HELP_STRING([--with-lvmetad-pidfile=PATH],
- [lvmetad pidfile [[PID_DIR/lvmetad.pid]]]),
+ [lvmetad pidfile [PID_DIR/lvmetad.pid]]),
LVMETAD_PIDFILE=$withval,
LVMETAD_PIDFILE="$DEFAULT_PID_DIR/lvmetad.pid")
AC_DEFINE_UNQUOTED(LVMETAD_PIDFILE, ["$LVMETAD_PIDFILE"],
@@ -1405,8 +1397,7 @@ if test "$INTL" = yes; then
AC_ARG_WITH(localedir,
AC_HELP_STRING([--with-localedir=DIR],
- [translation files in DIR
- [[PREFIX/share/locale]]]),
+ [translation files in DIR [PREFIX/share/locale]]),
LOCALEDIR=$withval, LOCALEDIR='${prefix}/share/locale')
fi
@@ -1414,33 +1405,33 @@ fi
dnl -- FIXME: need to switch to regular option here --sysconfdir
AC_ARG_WITH(confdir,
AC_HELP_STRING([--with-confdir=DIR],
- [configuration files in DIR [[/etc]]]),
+ [configuration files in DIR [/etc]]),
CONFDIR=$withval, CONFDIR='/etc')
AC_ARG_WITH(staticdir,
AC_HELP_STRING([--with-staticdir=DIR],
- [static binaries in DIR [[EPREFIX/sbin]]]),
+ [static binaries in DIR [EPREFIX/sbin]]),
STATICDIR=$withval, STATICDIR='${exec_prefix}/sbin')
AC_ARG_WITH(usrlibdir,
AC_HELP_STRING([--with-usrlibdir=DIR],
- [usrlib in DIR [[PREFIX/lib]]]),
+ [usrlib in DIR [PREFIX/lib]]),
usrlibdir=$withval, usrlibdir='${prefix}/lib')
AC_ARG_WITH(usrsbindir,
AC_HELP_STRING([--with-usrsbindir=DIR],
- [usrsbin executables in DIR [[PREFIX/sbin]]]),
+ [usrsbin executables in DIR [PREFIX/sbin]]),
usrsbindir=$withval, usrsbindir='${prefix}/sbin')
################################################################################
AC_ARG_WITH(udev_prefix,
AC_HELP_STRING([--with-udev-prefix=UPREFIX],
- [install udev rule files in UPREFIX [[EPREFIX]]]),
+ [install udev rule files in UPREFIX [EPREFIX]]),
udev_prefix=$withval, udev_prefix='${exec_prefix}')
AC_ARG_WITH(udevdir,
AC_HELP_STRING([--with-udevdir=DIR],
- [udev rules in DIR [[UPREFIX/lib/udev/rules.d]]]),
+ [udev rules in DIR [UPREFIX/lib/udev/rules.d]]),
udevdir=$withval, udevdir='${udev_prefix}/lib/udev/rules.d')
################################################################################
@@ -1462,7 +1453,7 @@ test -z "$systemdutildir" && systemdutildir='${exec_prefix}/lib/systemd';
################################################################################
AC_ARG_WITH(tmpfilesdir,
AC_HELP_STRING([--with-tmpfilesdir=DIR],
- [install configuration files for management of volatile files and directories in DIR [[PREFIX/lib/tmpfiles.d]]]),
+ [install configuration files for management of volatile files and directories in DIR [PREFIX/lib/tmpfiles.d]]),
tmpfilesdir=$withval, tmpfilesdir='${prefix}/lib/tmpfiles.d')
################################################################################
dnl -- Ensure additional headers required
@@ -1524,7 +1515,7 @@ dnl -- dmeventd pidfile and executable path
if test "$BUILD_DMEVENTD" = yes; then
AC_ARG_WITH(dmeventd-pidfile,
AC_HELP_STRING([--with-dmeventd-pidfile=PATH],
- [dmeventd pidfile [[PID_DIR/dmeventd.pid]]]),
+ [dmeventd pidfile [PID_DIR/dmeventd.pid]]),
DMEVENTD_PIDFILE=$withval,
DMEVENTD_PIDFILE="$DEFAULT_PID_DIR/dmeventd.pid")
AC_DEFINE_UNQUOTED(DMEVENTD_PIDFILE, ["$DMEVENTD_PIDFILE"],
@@ -1534,7 +1525,7 @@ fi
if test "$BUILD_DMEVENTD" = yes; then
AC_ARG_WITH(dmeventd-path,
AC_HELP_STRING([--with-dmeventd-path=PATH],
- [dmeventd path [[EPREFIX/sbin/dmeventd]]]),
+ [dmeventd path [EPREFIX/sbin/dmeventd]]),
DMEVENTD_PATH=$withval,
DMEVENTD_PATH="$lvm_exec_prefix/sbin/dmeventd")
AC_DEFINE_UNQUOTED(DMEVENTD_PATH, ["$DMEVENTD_PATH"],
@@ -1546,42 +1537,42 @@ dnl -- various defaults
dnl -- FIXME: need to switch to regular option here --sysconfdir
AC_ARG_WITH(default-system-dir,
AC_HELP_STRING([--with-default-system-dir=DIR],
- [default LVM system directory [[/etc/lvm]]]),
+ [default LVM system directory [/etc/lvm]]),
DEFAULT_SYS_DIR=$withval, DEFAULT_SYS_DIR="/etc/lvm")
AC_DEFINE_UNQUOTED(DEFAULT_SYS_DIR, ["$DEFAULT_SYS_DIR"],
[Path to LVM system directory.])
AC_ARG_WITH(default-profile-subdir,
AC_HELP_STRING([--with-default-profile-subdir=SUBDIR],
- [default configuration profile subdir [[profile]]]),
+ [default configuration profile subdir [profile]]),
DEFAULT_PROFILE_SUBDIR=$withval, DEFAULT_PROFILE_SUBDIR=profile)
AC_DEFINE_UNQUOTED(DEFAULT_PROFILE_SUBDIR, ["$DEFAULT_PROFILE_SUBDIR"],
[Name of default configuration profile subdirectory.])
AC_ARG_WITH(default-archive-subdir,
AC_HELP_STRING([--with-default-archive-subdir=SUBDIR],
- [default metadata archive subdir [[archive]]]),
+ [default metadata archive subdir [archive]]),
DEFAULT_ARCHIVE_SUBDIR=$withval, DEFAULT_ARCHIVE_SUBDIR=archive)
AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE_SUBDIR, ["$DEFAULT_ARCHIVE_SUBDIR"],
[Name of default metadata archive subdirectory.])
AC_ARG_WITH(default-backup-subdir,
AC_HELP_STRING([--with-default-backup-subdir=SUBDIR],
- [default metadata backup subdir [[backup]]]),
+ [default metadata backup subdir [backup]]),
DEFAULT_BACKUP_SUBDIR=$withval, DEFAULT_BACKUP_SUBDIR=backup)
AC_DEFINE_UNQUOTED(DEFAULT_BACKUP_SUBDIR, ["$DEFAULT_BACKUP_SUBDIR"],
[Name of default metadata backup subdirectory.])
AC_ARG_WITH(default-cache-subdir,
AC_HELP_STRING([--with-default-cache-subdir=SUBDIR],
- [default metadata cache subdir [[cache]]]),
+ [default metadata cache subdir [cache]]),
DEFAULT_CACHE_SUBDIR=$withval, DEFAULT_CACHE_SUBDIR=cache)
AC_DEFINE_UNQUOTED(DEFAULT_CACHE_SUBDIR, ["$DEFAULT_CACHE_SUBDIR"],
[Name of default metadata cache subdirectory.])
AC_ARG_WITH(default-locking-dir,
AC_HELP_STRING([--with-default-locking-dir=DIR],
- [default locking directory [[/var/lock/lvm]]]),
+ [default locking directory [/var/lock/lvm]]),
DEFAULT_LOCK_DIR=$withval, DEFAULT_LOCK_DIR="/var/lock/lvm")
AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR, ["$DEFAULT_LOCK_DIR"],
[Name of default locking directory.])
@@ -1590,7 +1581,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR, ["$DEFAULT_LOCK_DIR"],
dnl -- Setup default data alignment
AC_ARG_WITH(default-data-alignment,
AC_HELP_STRING([--with-default-data-alignment=NUM],
- [set the default data alignment in MiB [[1]]]),
+ [set the default data alignment in MiB [1]]),
DEFAULT_DATA_ALIGNMENT=$withval, DEFAULT_DATA_ALIGNMENT=1)
AC_DEFINE_UNQUOTED(DEFAULT_DATA_ALIGNMENT, [$DEFAULT_DATA_ALIGNMENT],
[Default data alignment.])
@@ -1600,7 +1591,7 @@ dnl -- which kernel interface to use (ioctl only)
AC_MSG_CHECKING(for kernel interface choice)
AC_ARG_WITH(interface,
AC_HELP_STRING([--with-interface=IFACE],
- [choose kernel interface (ioctl) [[ioctl]]]),
+ [choose kernel interface (ioctl) [ioctl]]),
interface=$withval, interface=ioctl)
test "$interface" != ioctl && AC_MSG_ERROR([--with-interface=ioctl required. fs no longer supported.])
AC_MSG_RESULT($interface)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7049eeeb839b5931…
Commit: 7049eeeb839b59314d07c0bac250c89cf8ac78f8
Parent: 2f7f6932dcd450ba75fe590aba8c09838d2618dc
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Oct 27 11:53:01 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Oct 27 11:53:01 2014 +0100
test: for issue fixed in previous commit 2f7f6932dcd450ba75fe590aba8c09838d2618dc
---
test/shell/report-select.sh | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/test/shell/report-select.sh b/test/shell/report-select.sh
index 11a4efd..70e5366 100644
--- a/test/shell/report-select.sh
+++ b/test/shell/report-select.sh
@@ -183,6 +183,11 @@ lvs_sel 'name="vol1"' "vol1"
# check reserved values are accepted for certain fields as well as usual values
vgs_sel 'vg_mda_copies=unmanaged' "$vg2 $vg3"
vgs_sel 'vg_mda_copies=2' "$vg1"
+# also, we must match only vg1, not including vg2 and vg3
+# when comparing ranges - unamanged is mapped onto 2^64 - 1 internally,
+# so we need to skip this internal value if it matches with selection criteria!
+vgs_sel 'vg_mda_copies>=2' "$vg1"
+not vgs_sel 'vg_mda_copies=18446744073709551615'
lvs_sel 'lv_read_ahead=auto' "vol1 vol2 orig snap"
lvs_sel 'lv_read_ahead=256k' "abc xyz"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2f7f6932dcd450ba…
Commit: 2f7f6932dcd450ba75fe590aba8c09838d2618dc
Parent: e223c801fc3eb12c2a4502aee471f18a0b903de8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Oct 27 11:25:08 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Oct 27 11:25:08 2014 +0100
report: selection: fix selection criteria to not match reserved values when using >, <, >=, <
Some values are reserved for special purpose like 'undefined', 'unmanaged' etc.
When using >, <, >= and < comparison operators where the range is considered,
do not include reserved values as proper values in this range which
would otherwise result in not so obvious criteria match (as the reserved value is
actually transparent for the user). It's incorrect.
Example scenario:
$ vgs -o vg_name,vg_mda_copies vg1 vg2
VG #VMdaCps
vg1 1
vg2 unmanaged
The "unmanaged" is actually mapped onto reserved value
18446744073709551615 (2^64 - 1) internally.
Such reseved value is already caught on selection criteria input
properly:
$ vgs -o name,vg_mda_copies vg1 vg2 -S 'vg_mda_copies=18446744073709551615'
Numeric value 18446744073709551615 found in selection is reserved.
However, we still need to fix situaton where the reserved value may be
included in resulting range:
Before this patch:
$ vgs -o vg_name,vg_mda_copies vg1 vg2 -S 'vg_mda_copies >= 1'
VG #VMdaCps
vg1 1
vg2 unmanaged
With this patch applied:
$ vgs -o vg_name,vg_mda_copies vg1 vg2 -S 'vg_mda_copies >= 1'
VG #VMdaCps
vg1 1
>From the examples above, we can see that without this patch applied,
the vg_mda_copies >= 1 also matched the reserved value 18446744073709551615
(which is represented by the "unamanged" string on report). When
applying the operators, such values must be skipped! They're meant to
be matched only against their string representation only, e.g.:
$ vgs -o name,vg_mda_copies vg1 vg2 -S 'vg_mda_copies=unmanaged'
VG #VMdaCps
vg2 unmanaged
...or any synonyms:
$ vgs -o name,vg_mda_copies vg1 vg2 -S 'vg_mda_copies=undefined'
VG #VMdaCps
vg2 unmanaged
---
WHATS_NEW_DM | 1 +
libdm/libdm-report.c | 118 ++++++++++++++++++++++++++------------------------
2 files changed, 62 insertions(+), 57 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 5ab34c1..6981f8f 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.91 -
====================================
+ Fix selection criteria to not match reserved values when using >, <, >=, <.
Add DM_LIST_HEAD_INIT macro to libdevmapper.h
Fix dm_is_dm_major to not issue error about missing /proc lines for dm module.
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 8c27c5b..f68aa85 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1234,7 +1234,49 @@ static void *_report_get_implicit_field_data(struct dm_report *rh __attribute__(
return NULL;
}
-static int _cmp_field_int(const char *field_id, uint64_t a, uint64_t b, uint32_t flags)
+static int _close_enough(double d1, double d2)
+{
+ return fabs(d1 - d2) < DBL_EPSILON;
+}
+
+/*
+ * Used to check whether a value of certain type used in selection is reserved.
+ */
+static int _check_value_is_reserved(struct dm_report *rh, unsigned type, const void *value)
+{
+ const struct dm_report_reserved_value *iter = rh->reserved_values;
+
+ if (!iter)
+ return 0;
+
+ while (iter->type) {
+ if (iter->type & type) {
+ switch (type) {
+ case DM_REPORT_FIELD_TYPE_NUMBER:
+ if (*(uint64_t *)iter->value == *(uint64_t *)value)
+ return 1;
+ break;
+ case DM_REPORT_FIELD_TYPE_STRING:
+ if (!strcmp((const char *)iter->value, (const char *) value))
+ return 1;
+ break;
+ case DM_REPORT_FIELD_TYPE_SIZE:
+ if (_close_enough(*(double *)iter->value, *(double *) value))
+ return 1;
+ break;
+ case DM_REPORT_FIELD_TYPE_STRING_LIST:
+ // TODO: add comparison for string list
+ break;
+ }
+ }
+ iter++;
+ }
+
+ return 0;
+}
+
+static int _cmp_field_int(struct dm_report *rh, const char *field_id,
+ uint64_t a, uint64_t b, uint32_t flags)
{
switch(flags & FLD_CMP_MASK) {
case FLD_CMP_EQUAL:
@@ -1242,13 +1284,13 @@ static int _cmp_field_int(const char *field_id, uint64_t a, uint64_t b, uint32_t
case FLD_CMP_NOT|FLD_CMP_EQUAL:
return a != b;
case FLD_CMP_NUMBER|FLD_CMP_GT:
- return a > b;
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_NUMBER, &a) ? 0 : a > b;
case FLD_CMP_NUMBER|FLD_CMP_GT|FLD_CMP_EQUAL:
- return a >= b;
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_NUMBER, &a) ? 0 : a >= b;
case FLD_CMP_NUMBER|FLD_CMP_LT:
- return a < b;
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_NUMBER, &a) ? 0 : a < b;
case FLD_CMP_NUMBER|FLD_CMP_LT|FLD_CMP_EQUAL:
- return a <= b;
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_NUMBER, &a) ? 0 : a <= b;
default:
log_error(INTERNAL_ERROR "_cmp_field_int: unsupported number "
"comparison type for field %s", field_id);
@@ -1257,12 +1299,8 @@ static int _cmp_field_int(const char *field_id, uint64_t a, uint64_t b, uint32_t
return 0;
}
-static int _close_enough(double d1, double d2)
-{
- return fabs(d1 - d2) < DBL_EPSILON;
-}
-
-static int _cmp_field_double(const char *field_id, double a, double b, uint32_t flags)
+static int _cmp_field_double(struct dm_report *rh, const char *field_id,
+ double a, double b, uint32_t flags)
{
switch(flags & FLD_CMP_MASK) {
case FLD_CMP_EQUAL:
@@ -1270,13 +1308,13 @@ static int _cmp_field_double(const char *field_id, double a, double b, uint32_t
case FLD_CMP_NOT|FLD_CMP_EQUAL:
return !_close_enough(a, b);
case FLD_CMP_NUMBER|FLD_CMP_GT:
- return (a > b) && !_close_enough(a, b);
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_SIZE, &a) ? 0 : (a > b) && !_close_enough(a, b);
case FLD_CMP_NUMBER|FLD_CMP_GT|FLD_CMP_EQUAL:
- return (a > b) || _close_enough(a, b);
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_SIZE, &a) ? 0 : (a > b) || _close_enough(a, b);
case FLD_CMP_NUMBER|FLD_CMP_LT:
- return (a < b) && !_close_enough(a, b);
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_SIZE, &a) ? 0 : (a < b) && !_close_enough(a, b);
case FLD_CMP_NUMBER|FLD_CMP_LT|FLD_CMP_EQUAL:
- return a < b || _close_enough(a, b);
+ return _check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_SIZE, &a) ? 0 : a < b || _close_enough(a, b);
default:
log_error(INTERNAL_ERROR "_cmp_field_double: unsupported number "
"comparison type for selection field %s", field_id);
@@ -1285,7 +1323,8 @@ static int _cmp_field_double(const char *field_id, double a, double b, uint32_t
return 0;
}
-static int _cmp_field_string(const char *field_id, const char *a, const char *b, uint32_t flags)
+static int _cmp_field_string(struct dm_report *rh __attribute__((unused)), const char *field_id,
+ const char *a, const char *b, uint32_t flags)
{
switch (flags & FLD_CMP_MASK) {
case FLD_CMP_EQUAL:
@@ -1377,7 +1416,8 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
return 0;
}
-static int _cmp_field_string_list(const char *field_id,
+static int _cmp_field_string_list(struct dm_report *rh __attribute__((unused)),
+ const char *field_id,
const struct str_list_sort_value *value,
const struct selection_str_list *selection, uint32_t flags)
{
@@ -1447,16 +1487,16 @@ static int _compare_selection_field(struct dm_report *rh,
return 0;
/* fall through */
case DM_REPORT_FIELD_TYPE_NUMBER:
- r = _cmp_field_int(field_id, *(const uint64_t *) f->sort_value, fs->v.i, fs->flags);
+ r = _cmp_field_int(rh, field_id, *(const uint64_t *) f->sort_value, fs->v.i, fs->flags);
break;
case DM_REPORT_FIELD_TYPE_SIZE:
- r = _cmp_field_double(field_id, *(const uint64_t *) f->sort_value, fs->v.d, fs->flags);
+ r = _cmp_field_double(rh, field_id, *(const uint64_t *) f->sort_value, fs->v.d, fs->flags);
break;
case DM_REPORT_FIELD_TYPE_STRING:
- r = _cmp_field_string(field_id, (const char *) f->sort_value, fs->v.s, fs->flags);
+ r = _cmp_field_string(rh, field_id, (const char *) f->sort_value, fs->v.s, fs->flags);
break;
case DM_REPORT_FIELD_TYPE_STRING_LIST:
- r = _cmp_field_string_list(field_id, (const struct str_list_sort_value *) f->sort_value,
+ r = _cmp_field_string_list(rh, field_id, (const struct str_list_sort_value *) f->sort_value,
fs->v.l, fs->flags);
break;
default:
@@ -1851,42 +1891,6 @@ static const char *_get_reserved(struct dm_report *rh, unsigned type,
return s;
}
-/*
- * Used to check whether a value of certain type used in selection is reserved.
- */
-static int _check_value_is_reserved(struct dm_report *rh, unsigned type, const void *value)
-{
- const struct dm_report_reserved_value *iter = rh->reserved_values;
-
- if (!iter)
- return 0;
-
- while (iter->type) {
- if (iter->type & type) {
- switch (type) {
- case DM_REPORT_FIELD_TYPE_NUMBER:
- if (*(uint64_t *)iter->value == *(uint64_t *)value)
- return 1;
- break;
- case DM_REPORT_FIELD_TYPE_STRING:
- if (!strcmp((const char *)iter->value, (const char *) value))
- return 1;
- break;
- case DM_REPORT_FIELD_TYPE_SIZE:
- if (_close_enough(*(double *)iter->value, *(double *) value))
- return 1;
- break;
- case DM_REPORT_FIELD_TYPE_STRING_LIST:
- // TODO: add comparison for string list
- break;
- }
- }
- iter++;
- }
-
- return 0;
-}
-
float dm_percent_to_float(dm_percent_t percent)
{
return (float) percent / DM_PERCENT_1;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e223c801fc3eb12c…
Commit: e223c801fc3eb12c2a4502aee471f18a0b903de8
Parent: c28a7706ed00c135e6fb06d22dde1c374f32f847
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 19:45:17 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 19:45:17 2014 +0100
pools: workaround hints
Missing code for stacked hint estimation
---
lib/metadata/pool_manip.c | 29 +++++++++++++++++++----------
test/shell/lvconvert-cache-raid.sh | 1 +
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index b84950c..d1b4497 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -324,16 +324,25 @@ int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
pool_data_lv = seg_lv(first_seg(pool_lv), 0);
dm_list_iterate_items(seg, &pool_data_lv->segments) {
- pv = seg_pv(seg, 0);
- if (chunk_size_calc_policy == THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE)
- hint = dev_optimal_io_size(cmd->dev_types, pv_dev(pv));
- else
- hint = dev_minimum_io_size(cmd->dev_types, pv_dev(pv));
- if (!hint)
- continue;
- if (previous_hint)
- hint = _lcm(previous_hint, hint);
- previous_hint = hint;
+ switch (seg_type(seg, 0)) {
+ case AREA_PV:
+ pv = seg_pv(seg, 0);
+ if (chunk_size_calc_policy == THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE)
+ hint = dev_optimal_io_size(cmd->dev_types, pv_dev(pv));
+ else
+ hint = dev_minimum_io_size(cmd->dev_types, pv_dev(pv));
+ if (!hint)
+ continue;
+
+ if (previous_hint)
+ hint = _lcm(previous_hint, hint);
+ previous_hint = hint;
+ break;
+ case AREA_LV:
+ /* FIXME: hint for stacked (raid) LVs - estimate geometry from LV ?? */
+ default:
+ break;
+ }
}
if (!hint)
diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh
index 3ac2d0b..16dd38e 100644
--- a/test/shell/lvconvert-cache-raid.sh
+++ b/test/shell/lvconvert-cache-raid.sh
@@ -46,6 +46,7 @@ lvremove -f $vg
lvcreate -n cpool_meta -m 1 --type raid1 -l 10 $vg
lvcreate -n cpool -m 1 --type raid1 -l 10 $vg
+lvs -a -o+seg_pe_ranges $vg
lvconvert --yes --type cache-pool --poolmetadata $vg/cpool_meta $vg/cpool
lvcreate -n corigin --type cache --cachepool $vg/cpool -l 10
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c28a7706ed00c135…
Commit: c28a7706ed00c135e6fb06d22dde1c374f32f847
Parent: 7bbf3cf3066a62c19e5ec439f658ae5253edaace
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 16:19:30 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
tests: update cache creation tests
---
test/shell/lvcreate-cache.sh | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index 69d0534..b37f321 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -202,6 +202,27 @@ check lv_attr_bit perm $vg/$lv6 "r"
lvremove -f $vg
+########################################
+# Validate args are properly preserved #
+########################################
+lvcreate --type cache-pool -L10 --chunksize 256 --cachemode writeback $vg/cpool1
+lvcreate -H -L10 $vg/cpool1
+check lv_field $vg/cpool1 chunksize "256.00k"
+check lv_field $vg/cpool1 cachemode "writeback"
+
+lvcreate --type cache-pool -L10 --chunksize 256 --cachemode writethrough $vg/cpool2
+lvcreate -H -L10 --chunksize 512 --cachemode writeback $vg/cpool2
+check lv_field $vg/cpool2 chunksize "512.00k"
+check lv_field $vg/cpool2 cachemode "writeback"
+
+# Chunk bigger then pool size
+fail lvcreate --type cache-pool -l1 --chunksize 1G $vg/cpool3
+
+lvcreate --type cache-pool -L10 $vg/cpool4
+fail lvcreate -H -L10 --chunksize 16M $vg/cpool4
+
+lvremove -f $vg
+
##############################
# Test things that should fail
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7bbf3cf3066a62c1…
Commit: 7bbf3cf3066a62c19e5ec439f658ae5253edaace
Parent: 70616187b32ee890eae8e8607c2d247d16cd6787
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 07:29:25 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
tests: lvcreate-update
Test with old mirror type.
---
test/shell/lvcreate-usage.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index c2b7112..05f2515 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -114,10 +114,10 @@ lvremove -f $vg
# - nonzero (bz186013)
# - a power of 2 and a multiple of page size
# - <= size of LV
-invalid lvcreate -m 1 -L 32m -n $lv -R 0 $vg 2>err
+invalid lvcreate --type mirror -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
+invalid lvcreate --type mirror -m 1 -L 32m -n $lv -R 11k $vg
+invalid lvcreate --type mirror -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 -f $vg
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=70616187b32ee890…
Commit: 70616187b32ee890eae8e8607c2d247d16cd6787
Parent: 205e3ff88898848b6e5dcfde74bff829bd27bf83
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 07:27:23 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
tests: pytest update
---
test/api/pytest.sh | 3 +++
test/api/python_lvm_unit.py | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/test/api/pytest.sh b/test/api/pytest.sh
index 7b6085f..36f55fa 100644
--- a/test/api/pytest.sh
+++ b/test/api/pytest.sh
@@ -21,6 +21,9 @@
# thus it needs dmeventd
#
+# Example of using 'gdb' with python:
+# gdb -ex r --args python FULL_PATH/lvm2/test/api/python_lvm_unit.py -v TestLvm.test_lv_active_inactive
+
#Locate the python binding library to use.
python_lib=$(find $abs_top_builddir -name lvm.so)
# Unable to test python bindings if library not available
diff --git a/test/api/python_lvm_unit.py b/test/api/python_lvm_unit.py
index ab2e86f..c338775 100755
--- a/test/api/python_lvm_unit.py
+++ b/test/api/python_lvm_unit.py
@@ -132,7 +132,7 @@ class TestLvm(unittest.TestCase):
vg.extend(d)
vg.createLvThinpool(pool_name, vg.getSize()/2, 0, 0,
- lvm.THIN_DISCARDS_PASSDOWN, 1)
+ lvm.THIN_DISCARDS_PASSDOWN, 1)
return vg
@staticmethod
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=205e3ff88898848b…
Commit: 205e3ff88898848b6e5dcfde74bff829bd27bf83
Parent: c9fbbf48baf9866dc57b336f9ca2b54346fb9827
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 16:18:53 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
lvcreate: delay check for free extents
As the rounding for cache creation may change the value of extents
postpone check for free extents.
---
lib/metadata/lv_manip.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1ab47c6..36bc2d8 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6636,14 +6636,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (!seg_is_virtual(lp) && !lp->approx_alloc &&
- (vg->free_count < lp->extents)) {
- log_error("Volume group \"%s\" has insufficient free space "
- "(%u extents): %u required.",
- vg->name, vg->free_count, lp->extents);
- return NULL;
- }
-
if ((lp->alloc != ALLOC_ANYWHERE) && (lp->stripes > dm_list_size(lp->pvh))) {
log_error("Number of stripes (%u) must not exceed "
"number of physical volumes (%d)", lp->stripes,
@@ -6836,6 +6828,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->wipe_signatures = 0;
}
+ if (!seg_is_virtual(lp) && !lp->approx_alloc &&
+ (vg->free_count < lp->extents)) {
+ log_error("Volume group \"%s\" has insufficient free space "
+ "(%u extents): %u required.",
+ vg->name, vg->free_count, lp->extents);
+ return NULL;
+ }
+
if (!archive(vg))
return_NULL;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c9fbbf48baf9866d…
Commit: c9fbbf48baf9866dc57b336f9ca2b54346fb9827
Parent: ff2e8b0de6aafcf304b30e5f90501f3638ead22f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 16:17:14 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
cache: support more args
Unlike with thin-pool - with cache we support all args also
directly when create cache volume.
So the result of 'separate' cache-pool creation and setting its
options should give same result as specifying those args
during cache creation.
Cache-pool values are used as defaults if the params are
not specified with cache creation.
---
lib/metadata/lv_manip.c | 11 ++++++-----
tools/lvcreate.c | 16 +++++++++++-----
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1e9d1c6..1ab47c6 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6629,7 +6629,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
}
- if (seg_is_pool(lp) &&
+ if ((seg_is_pool(lp) || seg_is_cache(lp)) &&
((uint64_t)lp->extents * vg->extent_size < lp->chunk_size)) {
log_error("Unable to create %s smaller than 1 chunk.",
lp->segtype->name);
@@ -6876,11 +6876,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* Unlock memory if possible */
memlock_unlock(vg->cmd);
- if (seg_is_cache_pool(lp)) {
- first_seg(lv)->chunk_size = lp->chunk_size;
- first_seg(lv)->feature_flags = lp->feature_flags;
+ if (seg_is_cache_pool(lp) || seg_is_cache(lp)) {
+ pool_lv = pool_lv ? : lv;
+ first_seg(pool_lv)->chunk_size = lp->chunk_size;
+ first_seg(pool_lv)->feature_flags = lp->feature_flags;
/* TODO: some calc_policy solution for cache ? */
- if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->passed_args,
+ if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, lp->passed_args,
THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) {
stack;
goto revert_new_lv;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 199636c..78b6898 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1035,6 +1035,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
static int _determine_cache_argument(struct volume_group *vg,
struct lvcreate_params *lp)
{
+ struct cmd_context *cmd = vg->cmd;
struct logical_volume *lv;
if (!lp->pool_name) {
@@ -1045,19 +1046,24 @@ static int _determine_cache_argument(struct volume_group *vg,
/* Pool exists, create cache volume */
lp->create_pool = 0;
lp->origin_name = NULL;
+ /* If cache args not given, use those from cache pool */
+ if (!arg_is_set(cmd, chunksize_ARG))
+ lp->chunk_size = first_seg(lv)->chunk_size;
+ if (!arg_is_set(cmd, cachemode_ARG))
+ lp->feature_flags = first_seg(lv)->feature_flags;
} else if (lv) {
/* Origin exists, create cache pool volume */
if (!validate_lv_cache_create_origin(lv))
return_0;
- if (arg_is_set(vg->cmd, permission_ARG) &&
+ if (arg_is_set(cmd, permission_ARG) &&
((lp->permission & LVM_WRITE) != (lv->status & LVM_WRITE))) {
/* Reverting permissions on all error path is very complicated */
log_error("Change of volume permission is unsupported with cache conversion, use lvchange.");
return 0;
}
/* FIXME: how to handle skip flag */
- if (arg_from_list_is_set(vg->cmd, "is unsupported with cache conversion",
+ if (arg_from_list_is_set(cmd, "is unsupported with cache conversion",
setactivationskip_ARG,
ignoreactivationskip_ARG,
-1))
@@ -1066,16 +1072,16 @@ static int _determine_cache_argument(struct volume_group *vg,
/* Put origin into resulting activation state first */
if (is_change_activating(lp->activate)) {
if ((lp->activate == CHANGE_AAY) &&
- !lv_passes_auto_activation_filter(vg->cmd, lv)) {
+ !lv_passes_auto_activation_filter(cmd, lv)) {
log_verbose("Skipping activation of cache origin %s.",
display_lvname(lv));
return 1;
- } else if (!activate_lv_excl_local(vg->cmd, lv)) {
+ } else if (!activate_lv_excl_local(cmd, lv)) {
log_error("Cannot activate cache origin %s.",
display_lvname(lv));
return 0;
}
- } else if (!deactivate_lv(vg->cmd, lv)) {
+ } else if (!deactivate_lv(cmd, lv)) {
log_error("Cannot deactivate activate cache origin %s.",
display_lvname(lv));
return 0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff2e8b0de6aafcf3…
Commit: ff2e8b0de6aafcf304b30e5f90501f3638ead22f
Parent: 52dfa6dd4491fd6f584b83d0924b82bea3bc1092
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 08:13:59 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
thin: simplify thin volume creation
Move code for creation of thin volume into a single place
out of lv_extend(). This allows to drop extra pool arg
for alloc_lv_segment() && lv_extend() and makes code
more easier to read and follow.
---
lib/format1/import-extents.c | 4 +-
lib/format_pool/import_export.c | 4 +-
lib/format_text/import_vsn1.c | 2 +-
lib/metadata/lv_alloc.h | 5 +-
lib/metadata/lv_manip.c | 135 ++++++++++++-------------------------
lib/metadata/merge.c | 2 +-
lib/metadata/metadata-exported.h | 2 +-
lib/metadata/pool_manip.c | 2 +-
tools/lvconvert.c | 2 +-
9 files changed, 54 insertions(+), 104 deletions(-)
diff --git a/lib/format1/import-extents.c b/lib/format1/import-extents.c
index f0f4f65..bfcf0de 100644
--- a/lib/format1/import-extents.c
+++ b/lib/format1/import-extents.c
@@ -226,7 +226,7 @@ static int _read_linear(struct cmd_context *cmd, struct lv_map *lvm)
len = _area_length(lvm, le);
if (!(seg = alloc_lv_segment(segtype, lvm->lv, le, len, 0, 0,
- NULL, NULL, 1, len, 0, 0, 0, NULL))) {
+ NULL, 1, len, 0, 0, 0, NULL))) {
log_error("Failed to allocate linear segment.");
return 0;
}
@@ -298,7 +298,7 @@ static int _read_stripes(struct cmd_context *cmd, struct lv_map *lvm)
if (!(seg = alloc_lv_segment(segtype, lvm->lv,
lvm->stripes * first_area_le,
lvm->stripes * area_len,
- 0, lvm->stripe_size, NULL, NULL,
+ 0, lvm->stripe_size, NULL,
lvm->stripes,
area_len, 0, 0, 0, NULL))) {
log_error("Failed to allocate striped segment.");
diff --git a/lib/format_pool/import_export.c b/lib/format_pool/import_export.c
index 6ef0757..1aeabe2 100644
--- a/lib/format_pool/import_export.c
+++ b/lib/format_pool/import_export.c
@@ -194,7 +194,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
if (!(seg = alloc_lv_segment(segtype, lv, *le_cur,
area_len * usp->num_devs, 0,
- usp->striping, NULL, NULL, usp->num_devs,
+ usp->striping, NULL, usp->num_devs,
area_len, 0, 0, 0, NULL))) {
log_error("Unable to allocate striped lv_segment structure");
return 0;
@@ -234,7 +234,7 @@ static int _add_linear_seg(struct dm_pool *mem,
if (!(seg = alloc_lv_segment(segtype, lv, *le_cur,
area_len, 0, usp->striping,
- NULL, NULL, 1, area_len,
+ NULL, 1, area_len,
POOL_PE_SIZE, 0, 0, NULL))) {
log_error("Unable to allocate linear lv_segment "
"structure");
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 1783b1e..c6a0cf9 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -363,7 +363,7 @@ static int _read_segment(struct logical_volume *lv, const struct dm_config_node
return_0;
if (!(seg = alloc_lv_segment(segtype, lv, start_extent,
- extent_count, 0, 0, NULL, NULL, area_count,
+ extent_count, 0, 0, NULL, area_count,
extent_count, 0, 0, 0, NULL))) {
log_error("Segment allocation failed");
return 0;
diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h
index 9824c67..1ac3f1f 100644
--- a/lib/metadata/lv_alloc.h
+++ b/lib/metadata/lv_alloc.h
@@ -24,7 +24,6 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
uint64_t status,
uint32_t stripe_size,
struct logical_volume *log_lv,
- struct logical_volume *thin_pool_lv,
uint32_t area_count,
uint32_t area_len,
uint32_t chunk_size,
@@ -79,9 +78,7 @@ int lv_add_mirror_lvs(struct logical_volume *lv,
int lv_add_log_segment(struct alloc_handle *ah, uint32_t first_area,
struct logical_volume *log_lv, uint64_t status);
int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
- uint32_t extents,
- const struct segment_type *segtype,
- const char *thin_pool_name);
+ uint32_t extents, const struct segment_type *segtype);
void alloc_destroy(struct alloc_handle *ah);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b12af6c..1e9d1c6 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -921,7 +921,6 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
uint64_t status,
uint32_t stripe_size,
struct logical_volume *log_lv,
- struct logical_volume *thin_pool_lv,
uint32_t area_count,
uint32_t area_len,
uint32_t chunk_size,
@@ -967,26 +966,6 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
dm_list_init(&seg->tags);
dm_list_init(&seg->thin_messages);
- if (thin_pool_lv) {
- /* If this is thin volume, thin snapshot is being created */
- if (lv_is_thin_volume(thin_pool_lv)) {
- seg->transaction_id = first_seg(first_seg(thin_pool_lv)->pool_lv)->transaction_id;
- if (!attach_pool_lv(seg, first_seg(thin_pool_lv)->pool_lv, thin_pool_lv, NULL))
- return_NULL;
- /* Use the same external origin */
- if (!attach_thin_external_origin(seg, first_seg(thin_pool_lv)->external_lv))
- return_NULL;
- } else if (lv_is_thin_pool(thin_pool_lv)) {
- seg->transaction_id = first_seg(thin_pool_lv)->transaction_id;
- if (!attach_pool_lv(seg, thin_pool_lv, NULL, NULL))
- return_NULL;
- } else {
- log_error(INTERNAL_ERROR "Volume %s is not thin volume or thin pool",
- thin_pool_lv->name);
- return NULL;
- }
- }
-
if (log_lv && !attach_mirror_log(seg, log_lv))
return_NULL;
@@ -1013,7 +992,7 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
if (!(seg = alloc_lv_segment(segtype, lv, old_le_count,
lv->le_count - old_le_count, status, 0,
- NULL, NULL, 0, lv->le_count - old_le_count,
+ NULL, 0, lv->le_count - old_le_count,
0, 0, 0, NULL))) {
log_error("Couldn't allocate new snapshot segment.");
return NULL;
@@ -1369,7 +1348,7 @@ int replace_lv_with_error_segment(struct logical_volume *lv)
/* FIXME Check for any attached LVs that will become orphans e.g. mirror logs */
- if (!lv_add_virtual_segment(lv, 0, len, get_segtype_from_string(lv->vg->cmd, "error"), NULL))
+ if (!lv_add_virtual_segment(lv, 0, len, get_segtype_from_string(lv->vg->cmd, "error")))
return_0;
return 1;
@@ -1859,7 +1838,7 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint64_t status,
if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count,
aa[0].len * area_multiple,
- status, stripe_size, NULL, NULL,
+ status, stripe_size, NULL,
area_count,
aa[0].len, 0u, region_size, 0u, NULL))) {
log_error("Couldn't allocate new LV segment.");
@@ -3011,21 +2990,9 @@ static int _allocate(struct alloc_handle *ah,
}
int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
- uint32_t extents, const struct segment_type *segtype,
- const char *thin_pool_name)
+ uint32_t extents, const struct segment_type *segtype)
{
struct lv_segment *seg;
- struct logical_volume *thin_pool_lv = NULL;
- struct lv_list *lvl;
-
- if (thin_pool_name) {
- if (!(lvl = find_lv_in_vg(lv->vg, thin_pool_name))) {
- log_error("Unable to find existing pool LV %s in VG %s.",
- thin_pool_name, lv->vg->name);
- return 0;
- }
- thin_pool_lv = lvl->lv;
- }
if (!dm_list_empty(&lv->segments) &&
(seg = last_seg(lv)) && (seg->segtype == segtype)) {
@@ -3033,9 +3000,9 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
seg->len += extents;
} else {
if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, extents,
- status, 0, NULL, thin_pool_lv, 0,
+ status, 0, NULL, 0,
extents, 0, 0, 0, NULL))) {
- log_error("Couldn't allocate new zero segment.");
+ log_error("Couldn't allocate new %s segment.", segtype->name);
return 0;
}
lv->status |= VIRTUAL;
@@ -3171,7 +3138,7 @@ static struct lv_segment *_convert_seg_to_mirror(struct lv_segment *seg,
if (!(newseg = alloc_lv_segment(get_segtype_from_string(seg->lv->vg->cmd, "mirror"),
seg->lv, seg->le, seg->len,
seg->status, seg->stripe_size,
- log_lv, NULL,
+ log_lv,
seg->area_count, seg->area_len,
seg->chunk_size, region_size,
seg->extents_copied, NULL))) {
@@ -3273,7 +3240,7 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
if (!(new_seg = alloc_lv_segment(segtype, copy_lv,
seg->le, seg->len, PVMOVE, 0,
- NULL, NULL, 1, seg->len,
+ NULL, 1, seg->len,
0, 0, 0, NULL)))
return_0;
@@ -3473,7 +3440,7 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
* First, create our top-level segment for our top-level LV
*/
if (!(mapseg = alloc_lv_segment(segtype, lv, 0, 0, lv->status,
- stripe_size, NULL, NULL,
+ stripe_size, NULL,
devices, 0, 0, region_size, 0, NULL))) {
log_error("Failed to create mapping segment for %s", lv->name);
return 0;
@@ -3665,7 +3632,7 @@ int lv_extend(struct logical_volume *lv,
const struct segment_type *segtype,
uint32_t stripes, uint32_t stripe_size,
uint32_t mirrors, uint32_t region_size,
- uint32_t extents, const char *thin_pool_name,
+ uint32_t extents,
struct dm_list *allocatable_pvs, alloc_policy_t alloc,
int approx_alloc)
{
@@ -3679,16 +3646,12 @@ int lv_extend(struct logical_volume *lv,
log_very_verbose("Adding segment of type %s to LV %s.", segtype->name, lv->name);
if (segtype_is_virtual(segtype))
- return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
+ return lv_add_virtual_segment(lv, 0u, extents, segtype);
- if (!lv->le_count &&
- (segtype_is_thin_pool(segtype) ||
- segtype_is_cache_pool(segtype))) {
+ if (!lv->le_count && segtype_is_pool(segtype)) {
/*
- * Thinpool and cache_pool allocations treat the metadata
- * device like a mirror log.
+ * Pool allocations treat the metadata device like a mirror log.
*/
- /* FIXME Allow pool and data on same device with NORMAL */
/* FIXME Support striped metadata pool */
log_count = 1;
} else if (segtype_is_raid(segtype) && !lv->le_count)
@@ -3704,7 +3667,7 @@ int lv_extend(struct logical_volume *lv,
if (segtype_is_raid(segtype))
new_extents -= ah->log_len * ah->area_multiple;
- if (segtype_is_thin_pool(segtype) || segtype_is_cache_pool(segtype)) {
+ if (segtype_is_pool(segtype)) {
if (!(r = create_pool(lv, segtype, ah, stripes, stripe_size)))
stack;
} else if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype)) {
@@ -4293,7 +4256,7 @@ static int _lvresize_poolmetadata(struct cmd_context *cmd, struct volume_group *
mseg->stripe_size,
seg_mirrors,
mseg->region_size,
- lp->poolmetadataextents - lv->le_count, NULL,
+ lp->poolmetadataextents - lv->le_count,
pvh, alloc, 0))
return_0;
@@ -4932,7 +4895,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
!lv_extend(lv, lp->segtype,
lp->stripes, lp->stripe_size,
lp->mirrors, first_seg(lv)->region_size,
- lp->extents - lv->le_count, NULL,
+ lp->extents - lv->le_count,
pvh, alloc, lp->approx_alloc))
return_NULL;
@@ -6017,7 +5980,7 @@ int remove_layer_from_lv(struct logical_volume *lv,
/* Replace the empty layer with error segment */
if (!(segtype = get_segtype_from_string(lv->vg->cmd, "error")))
return_0;
- if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype, NULL))
+ if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype))
return_0;
return 1;
@@ -6066,7 +6029,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
segtype = get_segtype_from_string(cmd, "error");
- if (!lv_add_virtual_segment(layer_lv, 0, lv_where->le_count, segtype, NULL)) {
+ if (!lv_add_virtual_segment(layer_lv, 0, lv_where->le_count, segtype)) {
log_error("Creation of transient LV %s for mirror conversion in VG %s failed.", name, lv_where->vg->name);
return NULL;
}
@@ -6117,7 +6080,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
/* allocate a new linear segment */
if (!(mapseg = alloc_lv_segment(segtype, lv_where, 0, layer_lv->le_count,
- status, 0, NULL, NULL, 1, layer_lv->le_count,
+ status, 0, NULL, 1, layer_lv->le_count,
0, 0, 0, NULL)))
return_NULL;
@@ -6174,7 +6137,7 @@ static int _extend_layer_lv_for_segment(struct logical_volume *layer_lv,
/* allocate a new segment */
if (!(mapseg = alloc_lv_segment(segtype, layer_lv, layer_lv->le_count,
seg->area_len, status, 0,
- NULL, NULL, 1, seg->area_len, 0, 0, 0, seg)))
+ NULL, 1, seg->area_len, 0, 0, 0, seg)))
return_0;
/* map the new segment to the original underlying are */
@@ -6445,7 +6408,7 @@ static struct logical_volume *_create_virtual_origin(struct cmd_context *cmd,
return_NULL;
if (!lv_extend(lv, segtype, 1, 0, 1, 0, voriginextents,
- NULL, NULL, ALLOC_INHERIT, 0))
+ NULL, ALLOC_INHERIT, 0))
return_NULL;
/* store vg on disk(s) */
@@ -6594,9 +6557,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
uint64_t status = lp->permission | VISIBLE_LV;
const struct segment_type *create_segtype = lp->segtype;
struct logical_volume *lv, *origin_lv = NULL;
- struct logical_volume *pool_lv;
+ struct logical_volume *pool_lv = NULL;
struct logical_volume *tmp_lv;
- const char *thin_name = NULL;
+ struct lv_segment *seg, *pool_seg;
if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) {
log_error("Logical volume \"%s\" already exists in "
@@ -6785,19 +6748,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- thin_name = lp->pool_name;
-
if (origin_lv) {
if (lv_is_locked(origin_lv)) {
log_error("Snapshots of locked devices are not supported.");
return NULL;
}
- /* For thin snapshot we must have matching pool */
- if (lv_is_thin_volume(origin_lv) &&
- (strcmp(first_seg(origin_lv)->pool_lv->name, lp->pool_name) == 0))
- thin_name = origin_lv->name;
-
lp->voriginextents = origin_lv->le_count;
/*
@@ -6883,7 +6839,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!archive(vg))
return_NULL;
- if (seg_is_thin_volume(lp)) {
+ if (pool_lv && seg_is_thin_volume(lp)) {
/* Ensure all stacked messages are submitted */
if ((pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
!update_pool_lv(pool_lv, 1))
@@ -6914,7 +6870,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->mirrors,
seg_is_pool(lp) ? lp->pool_metadata_extents : lp->region_size,
seg_is_thin_volume(lp) ? lp->voriginextents : lp->extents,
- thin_name, lp->pvh, lp->alloc, lp->approx_alloc))
+ lp->pvh, lp->alloc, lp->approx_alloc))
return_NULL;
/* Unlock memory if possible */
@@ -6943,32 +6899,29 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
stack;
goto revert_new_lv;
}
- } else if (seg_is_thin_volume(lp)) {
- pool_lv = first_seg(lv)->pool_lv;
- if (!(first_seg(lv)->device_id =
- get_free_pool_device_id(first_seg(pool_lv))))
+ } else if (pool_lv && seg_is_thin_volume(lp)) {
+ seg = first_seg(lv);
+ pool_seg = first_seg(pool_lv);
+ if (!(seg->device_id = get_free_pool_device_id(pool_seg)))
return_NULL;
- /*
- * Check if using 'external origin' or the 'normal' snapshot
- * within the same thin pool
- */
- if (origin_lv && (first_seg(origin_lv)->pool_lv != pool_lv)) {
- if (!pool_supports_external_origin(first_seg(pool_lv), origin_lv))
- return_0;
- if (origin_lv->status & LVM_WRITE) {
- log_error("Cannot use writable LV as the external origin.");
- return 0; // 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 0; // We can't be sure device is read-only
- }
- if (!attach_thin_external_origin(first_seg(lv), origin_lv))
+ seg->transaction_id = pool_seg->transaction_id;
+ if (origin_lv && lv_is_thin_volume(origin_lv) &&
+ (first_seg(origin_lv)->pool_lv == pool_lv)) {
+ /* For thin snapshot pool must match */
+ if (!attach_pool_lv(seg, pool_lv, origin_lv, NULL))
+ return_NULL;
+ /* Use the same external origin */
+ if (!attach_thin_external_origin(seg, first_seg(origin_lv)->external_lv))
+ return_NULL;
+ } else {
+ if (!attach_pool_lv(seg, pool_lv, NULL, NULL))
+ return_NULL;
+ /* If there is an external origin... */
+ if (!attach_thin_external_origin(seg, origin_lv))
return_NULL;
}
- if (!attach_pool_message(first_seg(pool_lv),
- DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
+ if (!attach_pool_message(pool_seg, DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
return_NULL;
}
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index c8c9543..5e09123 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -489,7 +489,7 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
if (!(split_seg = alloc_lv_segment(seg->segtype,
seg->lv, seg->le, seg->len,
seg->status, seg->stripe_size,
- seg->log_lv, seg->pool_lv,
+ seg->log_lv,
seg->area_count, seg->area_len,
seg->chunk_size, seg->region_size,
seg->extents_copied, seg->pvmove_source_seg))) {
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index d05333c..5ac68bf 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -709,7 +709,7 @@ int lv_extend(struct logical_volume *lv,
const struct segment_type *segtype,
uint32_t stripes, uint32_t stripe_size,
uint32_t mirrors, uint32_t region_size,
- uint32_t extents, const char *thin_pool_name,
+ uint32_t extents,
struct dm_list *allocatable_pvs, alloc_policy_t alloc,
int approx_alloc);
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index b4259a8..b84950c 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -638,7 +638,7 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
seg->stripe_size,
seg_mirrors,
seg->region_size,
- extents - lv->le_count, NULL,
+ extents - lv->le_count,
pvh, lv->alloc, 0))
return_0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 6d6d305..f22c84b 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3088,7 +3088,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
/* Allocate a new pool segment */
if (!(seg = alloc_lv_segment(lp->segtype, pool_lv, 0, data_lv->le_count,
- pool_lv->status, 0, NULL, NULL, 1,
+ pool_lv->status, 0, NULL, 1,
data_lv->le_count, 0, 0, 0, NULL)))
return_0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=52dfa6dd4491fd6f…
Commit: 52dfa6dd4491fd6f584b83d0924b82bea3bc1092
Parent: 25307e4add1e3f25cf5ae00d942df61afa46fe60
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 26 18:17:59 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 26 18:37:13 2014 +0100
cache: apply chunk rounding also for cache creation.
When we create volumes with chunk size bigger then extent size
we try to round up to some nearest chunk boundary.
Until now we did this for thins - use same logic for
cache volumes.
---
lib/metadata/lv_manip.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8523b58..b12af6c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3017,7 +3017,6 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
struct lv_segment *seg;
struct logical_volume *thin_pool_lv = NULL;
struct lv_list *lvl;
- uint32_t size;
if (thin_pool_name) {
if (!(lvl = find_lv_in_vg(lv->vg, thin_pool_name))) {
@@ -3026,17 +3025,6 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
return 0;
}
thin_pool_lv = lvl->lv;
- size = first_seg(thin_pool_lv)->chunk_size;
- if (lv->vg->extent_size < size) {
- /* Align extents on chunk boundary size */
- size = ((uint64_t)lv->vg->extent_size * extents + size - 1) /
- size * size / lv->vg->extent_size;
- if (size != extents) {
- log_print_unless_silent("Rounding size (%d extents) up to chunk boundary "
- "size (%d extents).", extents, size);
- extents = size;
- }
- }
}
if (!dm_list_empty(&lv->segments) &&
@@ -6722,6 +6710,20 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
display_lvname(pool_lv));
return NULL;
}
+
+ /* Validate volume size to to aling on chunk for small extents */
+ /* Cache chunk size is always set */
+ size = seg_is_cache(lp) ? lp->chunk_size : first_seg(pool_lv)->chunk_size;
+ if (size > vg->extent_size) {
+ /* Align extents on chunk boundary size */
+ size = ((uint64_t)vg->extent_size * lp->extents + size - 1) /
+ size * size / vg->extent_size;
+ if (size != lp->extents) {
+ log_print_unless_silent("Rounding size (%d extents) up to chunk boundary "
+ "size (%d extents).", lp->extents, size);
+ lp->extents = size;
+ }
+ }
}
/* Resolve origin volume */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=25307e4add1e3f25…
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;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=618d818c0d31bbfa…
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());
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7916cae697aed7e9…
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:
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3bb9629a8e1cd78…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e1dede6f6b8b2d05…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9642f013a104590b…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11ea72cfd872d4a5…
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);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=29c14a11943d52e4…
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)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd00d2c6eceb6536…
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;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=298de1f5c3c2a84e…
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 }
};
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=784c216d2beb21bf…
Commit: 784c216d2beb21bf793d33d1ebf600ab30454bb7
Parent: c7484a139a3b24d05459d8593309b518b4104172
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 20:50:26 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
lvcreate: check for conflicting -Zy -Wy
Let the finaly state of zero & wipe_signature to be
resolved later together with all the types.
Don't play with zero assigment and segtype flag
(i.e. thin-pool -Z has different meaning).
Check if the passed options do allow requested zeroing/wiping.
lvcreate without -Z or -W will fallback to warning if the device
cannot be zeroed, however if user requested them explicitely
it will give user error.
---
WHATS_NEW | 1 +
tools/lvcreate.c | 90 +++++++++++++++++++++++++++++++++---------------------
2 files changed, 56 insertions(+), 35 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c3d56de..b1f8410 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ 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.
Support lvcreate --type linear.
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2744b09..767405b 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -588,19 +588,6 @@ static int _read_activation_params(struct cmd_context *cmd,
lp->activate = (activation_change_t)
arg_uint_value(cmd, activate_ARG, CHANGE_AY);
- if (!is_change_activating(lp->activate)) {
- if (lp->zero && !seg_is_thin(lp)) {
- log_error("--activate n requires --zero n");
- return 0;
- }
- } else if (lp->activate == CHANGE_AAY) {
- if (arg_count(cmd, zero_ARG) || arg_count(cmd, wipesignatures_ARG)) {
- log_error("-Z and -W is incompatible with --activate a");
- return 0;
- }
- lp->zero = 0;
- }
-
/* Read ahead */
lp->read_ahead = arg_uint_value(cmd, readahead_ARG,
cmd->default_settings.read_ahead);
@@ -616,13 +603,6 @@ static int _read_activation_params(struct cmd_context *cmd,
"of %uK page size.", lp->read_ahead, pagesize >> 1);
}
- /* Permissions */
- if (!(lp->permission & LVM_WRITE)) {
- /* Must not zero/wipe read only volume */
- lp->zero = 0;
- lp->wipe_signatures = 0;
- }
-
/* Persistent minor (and major), default 'n' */
if (!get_and_validate_major_minor(cmd, vg->fid->fmt, &lp->major, &lp->minor))
return_0;
@@ -636,13 +616,6 @@ static int _read_activation_params(struct cmd_context *cmd,
if (arg_is_set(cmd, ignoreactivationskip_ARG))
lp->activation_skip |= ACTIVATION_SKIP_IGNORE;
- if (lp->zero && (lp->activation_skip & ACTIVATION_SKIP_SET_ENABLED)
- && !(lp->activation_skip & ACTIVATION_SKIP_IGNORE)) {
- log_error("--setactivationskip y requires either --zero n "
- "or --ignoreactivationskip");
- return 0;
- }
-
return 1;
}
@@ -984,16 +957,12 @@ static int _lvcreate_params(struct cmd_context *cmd,
}
}
- /*
- * Should we zero/wipe signatures on the lv.
- */
- lp->zero = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
- ? 0 : arg_int_value(cmd, zero_ARG, 1);
+ /* Should we zero/wipe signatures on the lv, default to 'y' */
+ lp->zero = arg_int_value(cmd, zero_ARG, 1);
- if (arg_count(cmd, wipesignatures_ARG)) {
+ if (arg_is_set(cmd, wipesignatures_ARG)) {
/* If -W/--wipesignatures is given on command line directly, respect it. */
- lp->wipe_signatures = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
- ? 0 : arg_int_value(cmd, wipesignatures_ARG, 1);
+ lp->wipe_signatures = arg_int_value(cmd, wipesignatures_ARG, 1);
} else {
/*
* If -W/--wipesignatures is not given on command line,
@@ -1346,6 +1315,53 @@ static int _check_pool_parameters(struct cmd_context *cmd,
return 1;
}
+/*
+ * Check zero_ARG with default value set to value of wipesignatures_ARG
+ * with its default set to 'n'. So if user specifies on command line either
+ * -Zy or -Wy it will check for incompatible options will report error then.
+ *
+ * Catching cases like we cannot fulfill:
+ * lvcreate [-an][-pr][-aay][-ky] [-Zy][-Wy]
+ */
+static int _check_zero_parameters(struct cmd_context *cmd, struct lvcreate_params *lp)
+{
+ char buf[NAME_LEN + 128];
+
+ /* -Z has different meaning for thins */
+ if (seg_is_thin(lp))
+ return 1;
+
+ /* If there is some problem, buffer will not be empty */
+ if (dm_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s",
+ lp->origin_name ? "origin " : "",
+ lp->origin_name ? : "",
+ lp->origin_name ? " " : "",
+ !(lp->permission & LVM_WRITE) ? "read-only " : "",
+ !is_change_activating(lp->activate) ? "inactive " : "",
+ (lp->activate == CHANGE_AAY) ? "auto activated " : "",
+ ((lp->activation_skip & ACTIVATION_SKIP_SET_ENABLED) &&
+ !(lp->activation_skip & ACTIVATION_SKIP_IGNORE))
+ ? "skipped from activation " : "") < 0) {
+ log_error(INTERNAL_ERROR "Buffer is too small for dm_snprintf().");
+ return 0;
+ }
+
+ if (buf[0] || (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)) {
+ /* Found condition that prevents zeroing */
+ if (arg_int_value(cmd, zero_ARG, arg_int_value(cmd, wipesignatures_ARG, 0))) {
+ if (!(lp->segtype->flags & SEG_CANNOT_BE_ZEROED)) {
+ log_error("Cannot zero %slogical volume with option -Zy or -Wy.", buf);
+ return 0;
+ }
+ log_print_unless_silent("Ignoring option -Zy or -Wy for unzeroable %s volume.",
+ lp->segtype->name);
+ }
+ lp->zero = lp->wipe_signatures = 0;
+ }
+
+ return 1;
+}
+
/*
* Ensure the set of thin parameters extracted from the command line is consistent.
@@ -1429,6 +1445,10 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
if (!_check_pool_parameters(cmd, vg, &lp, &lcp))
goto_out;
+ /* All types are checked */
+ if (!_check_zero_parameters(cmd, &lp))
+ return_0;
+
if (!_update_extents_params(vg, &lp, &lcp))
goto_out;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c7484a139a3b24d0…
Commit: c7484a139a3b24d05459d8593309b518b4104172
Parent: d13239b0547e09def4b58b0f49bd0252f459d431
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 23 14:26:16 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
toollib: persistent major minor
Deduce -M from presence of --minor, --major option if
not specified on command line.
---
WHATS_NEW | 1 +
tools/lvcreate.c | 37 +++++++++++--------------------
tools/toollib.c | 64 ++++++++++++++++++++++++++++++++---------------------
3 files changed, 53 insertions(+), 49 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 320bca3..c3d56de 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Better support for persistent major and minor options with lvcreate.
Refactor lvcreate towards more complete validation of all supported options.
Support lvcreate --type linear.
Improve _should_wipe_lv() to warn with message.
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index a789fb2..2744b09 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -623,20 +623,9 @@ static int _read_activation_params(struct cmd_context *cmd,
lp->wipe_signatures = 0;
}
- /* Persistent minor (and major) */
- if (arg_is_set(cmd, persistent_ARG)) {
- if (lp->create_pool && !seg_is_thin_volume(lp)) {
- log_error("--persistent is not permitted when creating a thin pool device.");
- return 0;
- }
-
- if (!get_and_validate_major_minor(cmd, vg->fid->fmt,
- &lp->major, &lp->minor))
- return_0;
- } else if (arg_is_set(cmd, major_ARG) || arg_is_set(cmd, minor_ARG)) {
- log_error("--major and --minor require -My.");
- return 0;
- }
+ /* Persistent minor (and major), default 'n' */
+ if (!get_and_validate_major_minor(cmd, vg->fid->fmt, &lp->major, &lp->minor))
+ return_0;
if (arg_is_set(cmd, setactivationskip_ARG)) {
lp->activation_skip |= ACTIVATION_SKIP_SET;
@@ -1316,10 +1305,14 @@ static int _check_pool_parameters(struct cmd_context *cmd,
return 0;
}
}
- /* When creating just pool the pool_name needs to be in lv_name */
- if (seg_is_pool(lp))
+ if (seg_is_pool(lp)) {
+ if (lp->major != -1 || lp->minor != -1) {
+ log_error("Persistent major and minor numbers are unsupported with pools.");
+ return 0;
+ }
+ /* When creating just pool the pool_name needs to be in lv_name */
lp->lv_name = lp->pool_name;
-
+ }
return 1;
}
/* Not creating new pool, but existing pool is needed */
@@ -1416,6 +1409,9 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
}
+ if (!_read_activation_params(cmd, vg, &lp))
+ goto_out;
+
/* Resolve segment types with opened VG */
if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp, &lcp))
goto_out;
@@ -1433,13 +1429,6 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
if (!_check_pool_parameters(cmd, vg, &lp, &lcp))
goto_out;
- /*
- * Check activation parameters to support inactive thin snapshot creation
- * FIXME: anything else needs to be moved past _determine_snapshot_type()?
- */
- if (!_read_activation_params(cmd, vg, &lp))
- goto_out;
-
if (!_update_extents_params(vg, &lp, &lcp))
goto_out;
diff --git a/tools/toollib.c b/tools/toollib.c
index a33e6c2..dd09811 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1181,55 +1181,69 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv, void *han
return ret_max;
}
+/*
+ * Parse persistent major minor parameters.
+ *
+ * --persistent is unspecified => state is deduced
+ * from presence of options --minor or --major.
+ *
+ * -Mn => --minor or --major not allowed.
+ *
+ * -My => --minor is required (and also --major on <=2.4)
+ */
int get_and_validate_major_minor(const struct cmd_context *cmd,
const struct format_type *fmt,
int32_t *major, int32_t *minor)
{
- if (!arg_int_value(cmd, persistent_ARG, 0)) {
+ if (arg_count(cmd, minor_ARG) > 1) {
+ log_error("Option --minor may not be repeated.");
+ return 0;
+ }
+
+ if (arg_count(cmd, major_ARG) > 1) {
+ log_error("Option -j|--major may not be repeated.");
+ return 0;
+ }
+
+ /* Check with default 'y' */
+ if (!arg_int_value(cmd, persistent_ARG, 1)) { /* -Mn */
if (arg_is_set(cmd, minor_ARG) || arg_is_set(cmd, major_ARG)) {
- log_error("--major and --minor incompatible with -Mn");
+ log_error("Options --major and --minor are incompatible with -Mn.");
return 0;
}
*major = *minor = -1;
return 1;
}
- if (arg_count(cmd, minor_ARG) > 1) {
- log_error("Option --minor may not be repeated.");
- return 0;
- }
+ /* -1 cannot be entered as an argument for --major, --minor */
+ *major = arg_int_value(cmd, major_ARG, -1);
+ *minor = arg_int_value(cmd, minor_ARG, -1);
- if (arg_count(cmd, major_ARG) > 1) {
- log_error("Option -j/--major may not be repeated.");
- return 0;
+ if (arg_is_set(cmd, persistent_ARG)) { /* -My */
+ if (*minor == -1) {
+ log_error("Please specify minor number with --minor when using -My.");
+ return 0;
+ }
}
if (!strncmp(cmd->kernel_vsn, "2.4.", 4)) {
/* Major is required for 2.4 */
- if (!arg_is_set(cmd, major_ARG)) {
- log_error("Please specify major number with "
- "--major when using -My");
+ if (arg_is_set(cmd, persistent_ARG) && *major < 0) {
+ log_error("Please specify major number with --major when using -My.");
return 0;
}
- *major = arg_int_value(cmd, major_ARG, -1);
} else {
- if (arg_is_set(cmd, major_ARG)) {
- log_warn("WARNING: Ignoring supplied major number - "
+ if (*major != -1) {
+ log_warn("WARNING: Ignoring supplied major number %d - "
"kernel assigns major numbers dynamically. "
"Using major number %d instead.",
- cmd->dev_types->device_mapper_major);
+ *major, cmd->dev_types->device_mapper_major);
}
- *major = cmd->dev_types->device_mapper_major;
+ /* Stay with dynamic major:minor if minor is not specified. */
+ *major = (*minor == -1) ? -1 : cmd->dev_types->device_mapper_major;
}
- if (!arg_is_set(cmd, minor_ARG)) {
- log_error("Please specify minor number with --minor when using -My.");
- return 0;
- }
-
- *minor = arg_int_value(cmd, minor_ARG, -1);
-
- if (!validate_major_minor(cmd, fmt, *major, *minor))
+ if ((*minor != -1) && !validate_major_minor(cmd, fmt, *major, *minor))
return_0;
return 1;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d13239b0547e09de…
Commit: d13239b0547e09def4b58b0f49bd0252f459d431
Parent: 51a29e60564d5379b38ee4688bca5eb9b844c410
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 24 15:26:41 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
lvcreate: new validation code
Refactor lvcreate code.
Prefer to use arg_outside_list_is_set() so we get automatic 'white-list'
validation of supported options with different segment types.
Drop used lp->cache, lp->cache and use seg_is_cache(), seg_is_thin()
Draw clear border where is the last moment we could change create
segment type.
When segment type is given with --type - do not allow it to be changed
later.
Put together tests related to individual segment types.
Finish cache conversion at proper part of lv_manip code after
the vg_metadata are written - so we could correcly clean-up created
stripe LV for cache volume.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 364 +++++++-------
lib/metadata/metadata-exported.h | 3 +-
liblvm/lvm_lv.c | 1 -
tools/lvcreate.c | 1061 ++++++++++++++++++++++----------------
5 files changed, 799 insertions(+), 631 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index fa88ddc..320bca3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Refactor lvcreate towards more complete validation of all supported options.
Support lvcreate --type linear.
Improve _should_wipe_lv() to warn with message.
Inform about temporarily created volumes only in verbose mode.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 277a51d..f2cf404 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6604,6 +6604,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
struct cmd_context *cmd = vg->cmd;
uint32_t size_rest;
uint64_t status = lp->permission | VISIBLE_LV;
+ const struct segment_type *create_segtype = lp->segtype;
struct logical_volume *lv, *origin_lv = NULL;
struct logical_volume *pool_lv;
struct logical_volume *tmp_lv;
@@ -6672,7 +6673,58 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->extents = lp->extents - size_rest + lp->stripes;
}
- if (seg_is_cache(lp)) {
+ if (!lp->extents && !seg_is_thin_volume(lp)) {
+ log_error(INTERNAL_ERROR "Unable to create new logical volume with no extents.");
+ return_NULL;
+ }
+
+ if (seg_is_pool(lp) &&
+ ((uint64_t)lp->extents * vg->extent_size < lp->chunk_size)) {
+ log_error("Unable to create %s smaller than 1 chunk.",
+ lp->segtype->name);
+ return NULL;
+ }
+
+ if (!seg_is_virtual(lp) && !lp->approx_alloc &&
+ (vg->free_count < lp->extents)) {
+ log_error("Volume group \"%s\" has insufficient free space "
+ "(%u extents): %u required.",
+ vg->name, vg->free_count, lp->extents);
+ return NULL;
+ }
+
+ if ((lp->alloc != ALLOC_ANYWHERE) && (lp->stripes > dm_list_size(lp->pvh))) {
+ log_error("Number of stripes (%u) must not exceed "
+ "number of physical volumes (%d)", lp->stripes,
+ dm_list_size(lp->pvh));
+ return NULL;
+ }
+
+ if (seg_is_pool(lp))
+ status |= LVM_WRITE; /* Pool is always writable */
+
+ 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);
+ return NULL;
+ }
+
+ if (!validate_lv_cache_create(NULL, origin_lv))
+ return_NULL;
+
+ /* Validate cache origin is exclusively active */
+ if (vg_is_clustered(origin_lv->vg) &&
+ locking_is_clustered() &&
+ locking_supports_remote_queries() &&
+ lv_is_active(origin_lv) &&
+ !lv_is_active_exclusive(origin_lv)) {
+ log_error("Cannot cache not exclusively active origin volume %s.",
+ 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;
@@ -6683,47 +6735,83 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (lv_is_locked(pool_lv)) {
- log_error("Caching locked devices is not supported.");
+ if (!lv_is_cache_pool(pool_lv)) {
+ log_error("Logical volume %s is not a cache pool.",
+ display_lvname(pool_lv));
return NULL;
}
- if (!lp->extents) {
- log_error("No size given for new cache origin LV.");
+ if (lv_is_locked(pool_lv)) {
+ log_error("Cannot use locked cache pool %s.",
+ display_lvname(pool_lv));
return NULL;
}
- if (!(lp->segtype = get_segtype_from_string(vg->cmd, "striped")))
+ /* Create cache origin for cache pool */
+ /* TODO: eventually support raid/mirrors with -m */
+ if (!(create_segtype = get_segtype_from_string(vg->cmd, "striped")))
return_0;
- } else if (seg_is_thin(lp) && lp->snapshot) {
- if (!lp->origin_name) {
- log_error(INTERNAL_ERROR "Origin LV is not defined.");
- return 0;
+ } else if (seg_is_mirrored(lp) || seg_is_raid(lp)) {
+ /* FIXME: this will not pass cluster lock! */
+ init_mirror_in_sync(lp->nosync);
+
+ if (lp->nosync) {
+ log_warn("WARNING: New %s won't be synchronised. "
+ "Don't read what you didn't write!",
+ lp->segtype->name);
+ status |= LV_NOTSYNCED;
}
- if (!(origin_lv = find_lv(vg, lp->origin_name))) {
- log_error("Couldn't find origin volume '%s'.",
- lp->origin_name);
+
+ 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 (lv_is_locked(origin_lv)) {
- log_error("Snapshots of locked devices are not supported.");
+ 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;
}
- lp->voriginextents = origin_lv->le_count;
- } else if (lp->snapshot) {
- if (!activation()) {
- log_error("Can't create snapshot without using "
- "device-mapper kernel driver");
+ if (!lv_is_thin_pool(pool_lv)) {
+ log_error("Logical volume %s is not a thin pool.",
+ display_lvname(pool_lv));
return NULL;
}
- /* Must zero cow */
- status |= LVM_WRITE;
+ if (lv_is_locked(pool_lv)) {
+ log_error("Cannot use locked thin pool %s.",
+ display_lvname(pool_lv));
+ return NULL;
+ }
- if (!lp->voriginsize) {
+ 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 (lv_is_locked(origin_lv)) {
+ log_error("Snapshots of locked devices are not supported.");
+ return NULL;
+ }
+
+ /* For thin snapshot we must have matching pool */
+ if (lv_is_thin_volume(origin_lv) &&
+ (strcmp(first_seg(origin_lv)->pool_lv->name, lp->pool_name) == 0))
+ thin_name = origin_lv->name;
+
+ lp->voriginextents = origin_lv->le_count;
+ }
+ } else if (lp->snapshot) {
+ if (!lp->voriginsize) {
if (!(origin_lv = find_lv(vg, lp->origin_name))) {
log_error("Couldn't find origin volume '%s'.",
lp->origin_name);
@@ -6771,86 +6859,28 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
}
- }
-
- if (!seg_is_thin_volume(lp) && !lp->extents) {
- log_error("Unable to create new logical volume with no extents");
- return NULL;
- }
-
- if (seg_is_pool(lp)) {
- if (((uint64_t)lp->extents * vg->extent_size < lp->chunk_size)) {
- log_error("Unable to create %s smaller than 1 chunk.",
- lp->segtype->name);
- return NULL;
- }
- }
- if (lp->snapshot && !seg_is_thin(lp) &&
- !cow_has_min_chunks(vg, lp->extents, lp->chunk_size))
- return NULL;
+ if (!cow_has_min_chunks(vg, lp->extents, lp->chunk_size))
+ return_NULL;
- if (!seg_is_virtual(lp) &&
- vg->free_count < lp->extents && !lp->approx_alloc) {
- log_error("Volume group \"%s\" has insufficient free space "
- "(%u extents): %u required.",
- vg->name, vg->free_count, lp->extents);
- return NULL;
- }
+ /* The snapshot segment gets created later */
+ if (!(create_segtype = get_segtype_from_string(cmd, "striped")))
+ return_NULL;
- if (lp->stripes > dm_list_size(lp->pvh) && lp->alloc != ALLOC_ANYWHERE) {
- log_error("Number of stripes (%u) must not exceed "
- "number of physical volumes (%d)", lp->stripes,
- dm_list_size(lp->pvh));
- return NULL;
+ /* Must zero cow */
+ status |= LVM_WRITE;
+ lp->zero = 1;
+ lp->wipe_signatures = 0;
}
- /* The snapshot segment gets created later */
- if (lp->snapshot && !seg_is_thin(lp) &&
- !(lp->segtype = get_segtype_from_string(cmd, "striped")))
- return_NULL;
-
if (!archive(vg))
return_NULL;
if (seg_is_thin_volume(lp)) {
/* Ensure all stacked messages are submitted */
- if (!lp->pool_name) {
- log_error(INTERNAL_ERROR "Undefined pool for thin volume segment.");
- 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;
- }
-
if ((pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
!update_pool_lv(pool_lv, 1))
return_NULL;
-
- /* For thin snapshot we must have matching pool */
- if (origin_lv && lv_is_thin_volume(origin_lv) && (!lp->pool_name ||
- (strcmp(first_seg(origin_lv)->pool_lv->name, lp->pool_name) == 0)))
- thin_name = origin_lv->name;
- else
- thin_name = lp->pool_name;
- }
-
- if (segtype_is_mirrored(lp->segtype) || segtype_is_raid(lp->segtype)) {
- init_mirror_in_sync(lp->nosync);
-
- if (lp->nosync) {
- log_warn("WARNING: New %s won't be synchronised. "
- "Don't read what you didn't write!",
- lp->segtype->name);
- status |= LV_NOTSYNCED;
- }
-
- lp->region_size = adjusted_mirror_region_size(vg->extent_size,
- lp->extents,
- lp->region_size, 0);
}
if (!(lv = lv_create_empty(new_lv_name ? : "lvol%d", NULL,
@@ -6862,7 +6892,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
log_debug_metadata("Setting read ahead sectors %u.", lv->read_ahead);
}
- if (!seg_is_thin_pool(lp) && lp->minor >= 0) {
+ if (!seg_is_pool(lp) && lp->minor >= 0) {
lv->major = lp->major;
lv->minor = lp->minor;
lv->status |= FIXED_MINOR;
@@ -6872,7 +6902,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
dm_list_splice(&lv->tags, &lp->tags);
- if (!lv_extend(lv, lp->segtype,
+ if (!lv_extend(lv, create_segtype,
lp->stripes, lp->stripe_size,
lp->mirrors,
seg_is_pool(lp) ? lp->pool_metadata_extents : lp->region_size,
@@ -6915,7 +6945,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* Check if using 'external origin' or the 'normal' snapshot
* within the same thin pool
*/
- if (lp->snapshot && (first_seg(origin_lv)->pool_lv != pool_lv)) {
+ if (origin_lv && (first_seg(origin_lv)->pool_lv != pool_lv)) {
if (!pool_supports_external_origin(first_seg(pool_lv), origin_lv))
return_0;
if (origin_lv->status & LVM_WRITE) {
@@ -6960,56 +6990,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (lv_activation_skip(lv, lp->activate, lp->activation_skip & ACTIVATION_SKIP_IGNORE))
lp->activate = CHANGE_AN;
- /*
- * Check if this is conversion inside lvcreate
- * Either we have origin or pool and created cache origin LV
- */
- if (lp->cache &&
- (lp->origin_name || (lp->pool_name && !lv_is_cache_pool(lv)))) {
- if (lp->origin_name) {
- if (!(origin_lv = find_lv(vg, lp->origin_name)))
- goto deactivate_and_revert_new_lv;
- pool_lv = lv; /* Cache pool is created */
- } else if (lp->pool_name) {
- if (!(pool_lv = find_lv(vg, lp->pool_name)))
- goto deactivate_and_revert_new_lv;
- origin_lv = lv; /* Cached origin is created */
- }
-
- if (!(tmp_lv = lv_cache_create(pool_lv, origin_lv)))
- goto deactivate_and_revert_new_lv;
-
- /* From here we cannot deactive_and_revert! */
- lv = tmp_lv;
-
- /*
- * We need to check if origin is active and in
- * that case reload cached LV.
- * There is no such problem with cache pool
- * since it cannot be activated.
- */
- if (lp->origin_name && lv_is_active(lv)) {
- if (!is_change_activating(lp->activate)) {
- /* User requested to create inactive cached volume */
- if (deactivate_lv(cmd, lv)) {
- log_error("Failed to deactivate %s.", display_lvname(lv));
- return NULL;
- }
- } else if (vg_is_clustered(lv->vg) &&
- locking_is_clustered() &&
- locking_supports_remote_queries() &&
- !lv_is_active_exclusive(lv)) {
- log_error("Only exclusively active %s could be converted.", display_lvname(lv));
- return NULL;
- } else {
- /* With exclusively active origin just reload */
- if (!lv_update_and_reload(lv))
- return_NULL;
- goto out; /* converted */
- }
- }
- }
-
/* store vg on disk(s) */
if (!vg_write(vg) || !vg_commit(vg)) {
if (seg_is_pool(lp)) {
@@ -7027,11 +7007,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
goto out;
}
- if (lv_is_cache_pool(lv)) {
- log_verbose("Cache pool is prepared.");
- goto out;
- }
-
/* Do not scan this LV until properly zeroed/wiped. */
if (_should_wipe_lv(lp, lv, 0))
lv->status |= LV_NOSCAN;
@@ -7039,7 +7014,18 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (lp->temporary)
lv->status |= LV_TEMPORARY;
- if (lv_is_thin_volume(lv)) {
+ if (seg_is_cache(lp)) {
+ /* TODO: support remote exclusive activation? */
+ if (is_change_activating(lp->activate) &&
+ !activate_lv_excl_local(cmd, lv)) {
+ log_error("Aborting. Failed to activate LV %s locally exclusively.",
+ display_lvname(lv));
+ goto revert_new_lv;
+ }
+ } else if (lv_is_cache_pool(lv)) {
+ /* Cache pool cannot be actived and zeroed */
+ log_very_verbose("Cache pool is prepared.");
+ } else if (lv_is_thin_volume(lv)) {
/* For snapshot, suspend active thin origin first */
if (origin_lv && lv_is_active(origin_lv) && lv_is_thin_volume(origin_lv)) {
if (!suspend_lv_origin(cmd, origin_lv)) {
@@ -7083,11 +7069,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
} else if (!lv_active_change(cmd, lv, lp->activate)) {
log_error("Failed to activate new LV.");
- if (lp->zero || lp->wipe_signatures ||
- lv_is_thin_pool(lv) ||
- lv_is_cache_type(lv))
- goto deactivate_and_revert_new_lv;
- return NULL;
+ goto deactivate_and_revert_new_lv;
}
if (_should_wipe_lv(lp, lv, 1)) {
@@ -7104,7 +7086,30 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
}
- if (lp->snapshot && !seg_is_thin(lp)) {
+ if (seg_is_cache(lp) || (origin_lv && lv_is_cache_pool(lv))) {
+ /* Finish cache conversion magic */
+ if (origin_lv) {
+ /* Convert origin to cached LV */
+ if (!(tmp_lv = lv_cache_create(lv, origin_lv))) {
+ /* TODO: do a better revert */
+ log_error("Aborting. Leaving cache pool %s and uncached origin volume %s.",
+ display_lvname(lv), display_lvname(origin_lv));
+ return NULL;
+ }
+ } else {
+ if (!(tmp_lv = lv_cache_create(pool_lv, lv))) {
+ /* 'lv' still keeps created new LV */
+ stack;
+ goto deactivate_and_revert_new_lv;
+ }
+ }
+ lv = tmp_lv;
+ if (!lv_update_and_reload(lv)) {
+ /* TODO: do a better revert */
+ log_error("Aborting. Manual intervention required.");
+ return NULL; /* FIXME: revert */
+ }
+ } else if (lp->snapshot) {
/* Reset permission after zeroing */
if (!(lp->permission & LVM_WRITE))
lv->status &= ~LVM_WRITE;
@@ -7177,35 +7182,26 @@ revert_new_lv:
struct logical_volume *lv_create_single(struct volume_group *vg,
struct lvcreate_params *lp)
{
+ const struct segment_type *segtype;
struct logical_volume *lv;
/* Create pool first if necessary */
- if (lp->create_pool) {
- if (seg_is_thin(lp)) {
- if (!seg_is_thin_pool(lp) &&
- !(lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool")))
- return_NULL;
-
- if (lp->pool_name && !apply_lvname_restrictions(lp->pool_name))
+ if (lp->create_pool && !seg_is_pool(lp)) {
+ segtype = lp->segtype;
+ if (seg_is_thin_volume(lp)) {
+ if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool")))
return_NULL;
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
-
- if (!lp->thin && !lp->snapshot)
- goto out;
-
- lp->pool_name = lv->name;
-
- if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
- return_NULL;
- } else if (seg_is_cache(lp) || seg_is_cache_pool(lp)) {
- if (!seg_is_cache_pool(lp) &&
- !(lp->segtype = get_segtype_from_string(vg->cmd,
- "cache-pool")))
- return_NULL;
-
- if (lp->pool_name && !apply_lvname_restrictions(lp->pool_name))
+ } else if (seg_is_cache(lp)) {
+ if (!lp->origin_name) {
+ /* Until we have --pooldatasize we are lost */
+ log_error(INTERNAL_ERROR "Unsupported creation of cache and cache pool volume.");
+ return NULL;
+ }
+ /* origin_name is defined -> creates cache LV with new cache pool */
+ if (!(lp->segtype = get_segtype_from_string(vg->cmd, "cache-pool")))
return_NULL;
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
@@ -7218,19 +7214,21 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
return lv;
}
- if (!lp->cache)
- goto out;
-
- lp->pool_name = lv->name;
- log_error("Creation of cache pool and cached volume in one command is not yet supported.");
+ log_error(INTERNAL_ERROR "Logical volume is not cache %s.",
+ display_lvname(lv));
+ return NULL;
+ } else {
+ log_error(INTERNAL_ERROR "Creation of pool for unsupported segment type %s.",
+ lp->segtype->name);
return NULL;
}
+ lp->pool_name = lv->name;
+ lp->segtype = segtype;
}
if (!(lv = _lv_create_an_lv(vg, lp, lp->lv_name)))
return_NULL;
-out:
if (lp->temporary)
log_verbose("Temporary logical volume \"%s\" created.", lv->name);
else
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 3d656b7..1100849 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -798,9 +798,7 @@ static inline int is_change_activating(activation_change_t change)
/* FIXME: refactor and reduce the size of this struct! */
struct lvcreate_params {
/* flags */
- int cache;
int snapshot; /* snap */
- int thin; /* thin */
int create_pool; /* pools */
int zero; /* all */
int wipe_signatures; /* all */
@@ -809,6 +807,7 @@ struct lvcreate_params {
int log_count; /* mirror */
int nosync; /* mirror */
int pool_metadata_spare; /* pools */
+ int type; /* type arg is given */
int temporary; /* temporary LV */
#define ACTIVATION_SKIP_SET 0x01 /* request to set LV activation skip flag state */
#define ACTIVATION_SKIP_SET_ENABLED 0x02 /* set the LV activation skip flag state to 'enabled' */
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 76a3164..f7f1596 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -611,7 +611,6 @@ static int _lv_set_thin_params(struct lvcreate_params *lp,
{
_lv_set_default_params(lp, vg, lvname, extents);
- lp->thin = 1;
lp->pool_name = pool_name;
lp->segtype = get_segtype_from_string(vg->cmd, "thin");
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index b6907f5..a789fb2 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -42,9 +42,9 @@ static int _set_vg_name(struct lvcreate_params *lp, const char *vg_name)
return 1;
}
-static int _lvcreate_name_params(struct lvcreate_params *lp,
- struct cmd_context *cmd,
- int *pargc, char ***pargv)
+static int _lvcreate_name_params(struct cmd_context *cmd,
+ int *pargc, char ***pargv,
+ struct lvcreate_params *lp)
{
int argc = *pargc;
char **argv = *pargv;
@@ -125,8 +125,6 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
"in one command is not yet supported.");
return 0;
}
-
- lp->cache = 1;
} else if (lp->snapshot && !arg_count(cmd, virtualsize_ARG)) {
/* argv[0] might be [vg/]origin */
if (!argc) {
@@ -379,167 +377,89 @@ static int _update_extents_params(struct volume_group *vg,
* Note: at this place all volume types needs to be already
* identified, do not change them here.
*/
-static int _read_size_params(struct lvcreate_params *lp,
- struct lvcreate_cmdline_params *lcp,
- struct cmd_context *cmd)
+static int _read_size_params(struct cmd_context *cmd,
+ struct lvcreate_params *lp,
+ struct lvcreate_cmdline_params *lcp)
{
- if (arg_count(cmd, extents_ARG) && arg_count(cmd, size_ARG)) {
- log_error("Please specify either size or extents (not both)");
- return 0;
- }
+ if (arg_from_list_is_negative(cmd, "may not be negative",
+ chunksize_ARG, extents_ARG,
+ mirrors_ARG,
+ maxrecoveryrate_ARG,
+ minrecoveryrate_ARG,
+ regionsize_ARG,
+ size_ARG,
+ stripes_ARG, stripesize_ARG,
+ virtualsize_ARG,
+ -1))
+ return_0;
- if (!lp->thin && !lp->snapshot && !arg_count(cmd, extents_ARG) && !arg_count(cmd, size_ARG)) {
- log_error("Please specify either size or extents");
- return 0;
- }
+ if (arg_from_list_is_zero(cmd, "may not be zero",
+ chunksize_ARG, extents_ARG,
+ regionsize_ARG,
+ size_ARG,
+ stripes_ARG, stripesize_ARG,
+ virtualsize_ARG,
+ -1))
+ return_0;
- /* poolmetadatasize_ARG is parsed in get_pool_params() */
- if (!lp->create_pool && arg_count(cmd, poolmetadatasize_ARG)) {
- log_error("--poolmetadatasize may only be specified when creating pools.");
- return 0;
- }
+ lp->voriginsize = arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0));
if (arg_count(cmd, extents_ARG)) {
- if (arg_sign_value(cmd, extents_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative number of extents is invalid.");
- return 0;
- }
- if (!(lp->extents = arg_uint_value(cmd, extents_ARG, 0))) {
- log_error("Number of extents may not be zero.");
+ if (arg_count(cmd, size_ARG)) {
+ log_error("Please specify either size or extents (not both).");
return 0;
}
+ lp->extents = arg_uint_value(cmd, extents_ARG, 0);
lcp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
- }
-
- /* Size returned in kilobyte units; held in sectors */
- if (arg_count(cmd, size_ARG)) {
- if (arg_sign_value(cmd, size_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative size is invalid.");
- return 0;
- }
- if (!(lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)))) {
- log_error("Size may not be zero.");
- return 0;
- }
+ } else if (arg_count(cmd, size_ARG)) {
+ lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
lcp->percent = PERCENT_NONE;
- }
-
- if (arg_count(cmd, virtualsize_ARG)) {
- if (!lp->thin && !lp->snapshot) {
- log_error("--virtualsize may only be specified when creating thins or virtual snapshots.");
- return 0;
- }
- if (arg_sign_value(cmd, virtualsize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative virtual origin size is invalid.");
- return 0;
- }
- /* Size returned in kilobyte units; held in sectors */
- if (!(lp->voriginsize = arg_uint64_value(cmd, virtualsize_ARG,
- UINT64_C(0)))) {
- log_error("Virtual origin size may not be zero.");
- return 0;
- }
+ } else if (!lp->snapshot && !seg_is_thin_volume(lp)) {
+ log_error("Please specify either size or extents.");
+ return 0;
}
return 1;
}
/*
- * Generic mirror parameter checks.
- * FIXME: Should eventually be moved into lvm library.
+ * Read parameters related to mirrors
*/
-static int _validate_mirror_params(const struct cmd_context *cmd __attribute__((unused)),
- const struct lvcreate_params *lp)
+static int _read_mirror_params(struct cmd_context *cmd,
+ struct lvcreate_params *lp)
{
- int pagesize = lvm_getpagesize();
-
- if (lp->region_size & (lp->region_size - 1)) {
- log_error("Region size (%" PRIu32 ") must be a power of 2",
- lp->region_size);
- return 0;
- }
-
- if (lp->region_size % (pagesize >> SECTOR_SHIFT)) {
- log_error("Region size (%" PRIu32 ") must be a multiple of "
- "machine memory page size (%d)",
- lp->region_size, pagesize >> SECTOR_SHIFT);
- return 0;
- }
-
- if (!lp->region_size) {
- log_error("Non-zero region size must be supplied.");
- return 0;
- }
-
- return 1;
-}
-
-static int _read_mirror_params(struct lvcreate_params *lp,
- struct cmd_context *cmd)
-{
- int region_size;
- const char *mirrorlog;
int corelog = arg_count(cmd, corelog_ARG);
+ const char *mirrorlog = arg_str_value(cmd, mirrorlog_ARG, corelog
+ ? "core" : DEFAULT_MIRRORLOG);
- mirrorlog = arg_str_value(cmd, mirrorlog_ARG,
- corelog ? "core" : DEFAULT_MIRRORLOG);
-
- if (strcmp("core", mirrorlog) && corelog) {
- log_error("Please use only one of --mirrorlog or --corelog");
- return 0;
- }
-
- if (!strcmp("mirrored", mirrorlog)) {
+ if (!strcmp("mirrored", mirrorlog))
lp->log_count = 2;
- } else if (!strcmp("disk", mirrorlog)) {
+ else if (!strcmp("disk", mirrorlog))
lp->log_count = 1;
- } else if (!strcmp("core", mirrorlog))
+ else if (!strcmp("core", mirrorlog)) {
lp->log_count = 0;
- else {
+ } else {
log_error("Unknown mirrorlog type: %s", mirrorlog);
return 0;
}
- log_verbose("Setting logging type to %s", mirrorlog);
-
- lp->nosync = arg_is_set(cmd, nosync_ARG);
-
- if (arg_count(cmd, regionsize_ARG)) {
- if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative regionsize is invalid");
- return 0;
- }
- lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
- } else {
- region_size = get_default_region_size(cmd);
- if (region_size < 0) {
- log_error("Negative regionsize in configuration file "
- "is invalid");
- return 0;
- }
- lp->region_size = region_size;
+ if (corelog && (lp->log_count != 0)) {
+ log_error("Please use only one of --corelog or --mirrorlog.");
+ return 0;
}
- if (!_validate_mirror_params(cmd, lp))
- return 0;
+ log_verbose("Setting logging type to %s", mirrorlog);
return 1;
}
-static int _read_raid_params(struct lvcreate_params *lp,
- struct cmd_context *cmd)
+/*
+ * Read parameters related to raids
+ */
+static int _read_raid_params(struct cmd_context *cmd,
+ struct lvcreate_params *lp)
{
- if (!segtype_is_raid(lp->segtype))
- return 1;
-
- if (arg_count(cmd, corelog_ARG) ||
- arg_count(cmd, mirrorlog_ARG)) {
- log_error("Log options not applicable to %s segtype",
- lp->segtype->name);
- return 0;
- }
-
- if (!strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10) && (lp->stripes < 2)) {
+ if ((lp->stripes < 2) && !strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
if (arg_count(cmd, stripes_ARG)) {
/* User supplied the bad argument */
log_error("Segment type 'raid10' requires 2 or more stripes.");
@@ -551,16 +471,6 @@ static int _read_raid_params(struct lvcreate_params *lp,
}
/*
- * RAID types without a mirror component do not take '-m' arg
- */
- if (!segtype_is_mirrored(lp->segtype) &&
- arg_count(cmd, mirrors_ARG)) {
- log_error("Mirror argument cannot be used with segment type, %s",
- lp->segtype->name);
- return 0;
- }
-
- /*
* RAID1 does not take a stripe arg
*/
if ((lp->stripes > 1) && seg_is_mirrored(lp) &&
@@ -570,41 +480,90 @@ static int _read_raid_params(struct lvcreate_params *lp,
return 0;
}
- /*
- * _read_mirror_params is called before _read_raid_params
- * and already sets:
- * lp->nosync
- * lp->region_size
- *
- * But let's ensure that programmers don't reorder
- * that by checking and warning if they aren't set.
- */
- if (!lp->region_size) {
- log_error(INTERNAL_ERROR "region_size not set.");
+ /* Rates are recorded in kiB/sec/disk, not sectors/sec/disk */
+ lp->min_recovery_rate = arg_uint_value(cmd, minrecoveryrate_ARG, 0) / 2;
+ lp->max_recovery_rate = arg_uint_value(cmd, maxrecoveryrate_ARG, 0) / 2;
+
+ if (lp->min_recovery_rate > lp->max_recovery_rate) {
+ log_error("Minimum recovery rate cannot be higher than maximum.");
return 0;
}
- if (arg_count(cmd, minrecoveryrate_ARG))
- lp->min_recovery_rate = arg_uint_value(cmd,
- minrecoveryrate_ARG, 0);
- if (arg_count(cmd, maxrecoveryrate_ARG))
- lp->max_recovery_rate = arg_uint_value(cmd,
- maxrecoveryrate_ARG, 0);
+ return 1;
+}
- /* Rates are recorded in kiB/sec/disk, not sectors/sec/disk */
- lp->min_recovery_rate /= 2;
- lp->max_recovery_rate /= 2;
+/*
+ * Read parameters related to mirrors and raids
+ */
+static int _read_mirror_and_raid_params(struct cmd_context *cmd,
+ struct lvcreate_params *lp)
+{
+ int pagesize = lvm_getpagesize();
- if (lp->max_recovery_rate &&
- (lp->max_recovery_rate < lp->min_recovery_rate)) {
- log_error("Minimum recovery rate cannot be higher than maximum.");
+ /* Common mirror and raid params */
+ if (arg_count(cmd, mirrors_ARG)) {
+ lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1;
+
+ if (lp->mirrors > DEFAULT_MIRROR_MAX_IMAGES) {
+ log_error("Only up to " DM_TO_STRING(DEFAULT_MIRROR_MAX_IMAGES)
+ " images in mirror supported currently.");
+ return 0;
+ }
+
+ if ((lp->mirrors > 2) && !strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ /*
+ * FIXME: When RAID10 is no longer limited to
+ * 2-way mirror, 'lv_mirror_count()'
+ * must also change for RAID10.
+ */
+ log_error("RAID10 currently supports "
+ "only 2-way mirroring (i.e. '-m 1')");
+ return 0;
+ }
+
+ if (lp->mirrors == 1) {
+ if (seg_is_mirrored(lp)) {
+ log_error("--mirrors must be at least 1 with segment type %s.", lp->segtype->name);
+ return 0;
+ }
+ log_print_unless_silent("Redundant mirrors argument: default is 0");
+ }
+ } else
+ /* Default to 2 mirrored areas if '--type mirror|raid1|raid10' */
+ lp->mirrors = seg_is_mirrored(lp) ? 2 : 1;
+
+ lp->nosync = arg_is_set(cmd, nosync_ARG);
+
+ if (!(lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0)) &&
+ ((lp->region_size = get_default_region_size(cmd)) <= 0)) {
+ log_error("regionsize in configuration file is invalid.");
+ return 0;
+ }
+
+ if (lp->region_size & (lp->region_size - 1)) {
+ log_error("Region size (%" PRIu32 ") must be a power of 2",
+ lp->region_size);
return 0;
}
+
+ if (lp->region_size % (pagesize >> SECTOR_SHIFT)) {
+ log_error("Region size (%" PRIu32 ") must be a multiple of "
+ "machine memory page size (%d)",
+ lp->region_size, pagesize >> SECTOR_SHIFT);
+ return 0;
+ }
+
+ if (seg_is_mirror(lp) && !_read_mirror_params(cmd, lp))
+ return_0;
+
+ if (seg_is_raid(lp) && !_read_raid_params(cmd, lp))
+ return_0;
+
return 1;
}
-static int _read_cache_pool_params(struct lvcreate_params *lp,
- struct cmd_context *cmd)
+static int _read_cache_params(struct cmd_context *cmd,
+ struct lvcreate_params *lp)
{
const char *cachemode;
@@ -620,9 +579,9 @@ static int _read_cache_pool_params(struct lvcreate_params *lp,
return 1;
}
-static int _read_activation_params(struct lvcreate_params *lp,
- struct cmd_context *cmd,
- struct volume_group *vg)
+static int _read_activation_params(struct cmd_context *cmd,
+ struct volume_group *vg,
+ struct lvcreate_params *lp)
{
unsigned pagesize;
@@ -658,14 +617,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
}
/* Permissions */
- lp->permission = arg_uint_value(cmd, permission_ARG,
- LVM_READ | LVM_WRITE);
-
- if (lp->snapshot) {
- /* Snapshot has to zero COW header */
- lp->zero = 1;
- lp->wipe_signatures = 0;
- } else if (!(lp->permission & LVM_WRITE)) {
+ if (!(lp->permission & LVM_WRITE)) {
/* Must not zero/wipe read only volume */
lp->zero = 0;
lp->wipe_signatures = 0;
@@ -673,7 +625,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
/* Persistent minor (and major) */
if (arg_is_set(cmd, persistent_ARG)) {
- if (lp->create_pool && !lp->thin) {
+ if (lp->create_pool && !seg_is_thin_volume(lp)) {
log_error("--persistent is not permitted when creating a thin pool device.");
return 0;
}
@@ -705,52 +657,58 @@ static int _read_activation_params(struct lvcreate_params *lp,
return 1;
}
-static int _lvcreate_params(struct lvcreate_params *lp,
- struct lvcreate_cmdline_params *lcp,
- struct cmd_context *cmd,
- int argc, char **argv)
+static int _lvcreate_params(struct cmd_context *cmd,
+ int argc, char **argv,
+ struct lvcreate_params *lp,
+ struct lvcreate_cmdline_params *lcp)
{
int contiguous;
struct arg_value_group_list *current_group;
const char *segtype_str;
const char *tag;
int only_linear = 0;
+ int mirror_default_cfg;
memset(lcp, 0, sizeof(*lcp));
dm_list_init(&lp->tags);
lp->target_attr = ~0;
lp->yes = arg_count(cmd, yes_ARG);
lp->force = (force_t) arg_count(cmd, force_ARG);
+ lp->permission = arg_uint_value(cmd, permission_ARG,
+ LVM_READ | LVM_WRITE);
- /* Set default segtype - remember, '-m 0' implies stripe. */
- if (arg_count(cmd, mirrors_ARG) &&
- arg_uint_value(cmd, mirrors_ARG, 0))
- if (arg_uint_value(cmd, arg_count(cmd, stripes_long_ARG) ?
- stripes_long_ARG : stripes_ARG, 1) > 1) {
- segtype_str = find_config_tree_str(cmd, global_raid10_segtype_default_CFG, NULL);;
- } else {
- segtype_str = find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL);
+ /*
+ * --type is the top most rule
+ *
+ * Ordering of following type tests is IMPORTANT
+ */
+ if ((segtype_str = arg_str_value(cmd, type_ARG, NULL))) {
+ lp->type = 1;
+ if (!strcmp(segtype_str, "linear")) {
+ segtype_str = "striped";
+ only_linear = 1; /* User requested linear only target */
}
- else if (arg_count(cmd, snapshot_ARG))
- segtype_str = "snapshot";
- else if (arg_count(cmd, cache_ARG))
- segtype_str = "cache";
- else if (arg_count(cmd, thin_ARG))
- segtype_str = "thin";
- /* estimations after valid shortcuts */
- else if (arg_count(cmd, cachepool_ARG))
+ if (arg_from_list_is_set(cmd, "is conflicting with option --type",
+ cache_ARG, thin_ARG, snapshot_ARG,
+ -1))
+ return_0;
+ /* More estimations from options after shortcuts */
+ } else if (arg_is_set(cmd, snapshot_ARG))
+ /* Snapshot has higher priority then thin */
+ segtype_str = "snapshot"; /* --thinpool makes thin volume */
+ else if (arg_is_set(cmd, cache_ARG) || arg_count(cmd, cachepool_ARG))
segtype_str = "cache";
- else if (arg_count(cmd, thinpool_ARG))
+ else if (arg_count(cmd, thin_ARG) || arg_count(cmd, thinpool_ARG) ||
+ arg_is_set(cmd, virtualsize_ARG))
segtype_str = "thin";
- else
+ else if (arg_uint_value(cmd, mirrors_ARG, 0)) {
+ /* Remember, '-m 0' implies stripe */
+ mirror_default_cfg = (arg_uint_value(cmd, stripes_ARG, 1) > 1)
+ ? global_raid10_segtype_default_CFG : global_mirror_segtype_default_CFG;
+ segtype_str = find_config_tree_str(cmd, mirror_default_cfg, NULL);
+ } else
segtype_str = "striped";
- segtype_str = arg_str_value(cmd, type_ARG, segtype_str);
- if (!strcmp(segtype_str, "linear")) {
- segtype_str = "striped";
- only_linear = 1; /* User requested linear only target */
- }
-
if (!(lp->segtype = get_segtype_from_string(cmd, segtype_str)))
return_0;
@@ -759,108 +717,269 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 0;
}
- if (seg_is_snapshot(lp) ||
- (!seg_is_thin(lp) && arg_count(cmd, virtualsize_ARG))) {
- if (arg_from_list_is_set(cmd, "is unsupported with snapshots",
- cache_ARG, cachepool_ARG,
- mirrors_ARG,
- thin_ARG,
- zero_ARG,
- -1))
+ /* Starts basic option validation for every segment type */
+
+ /* TODO: Use these ARGS macros also in commands.h ? */
+ /* ARGS are disjoint! sets of options */
+#define LVCREATE_ARGS \
+ activate_ARG,\
+ addtag_ARG,\
+ alloc_ARG,\
+ autobackup_ARG,\
+ available_ARG,\
+ contiguous_ARG,\
+ ignoreactivationskip_ARG,\
+ ignoremonitoring_ARG,\
+ name_ARG,\
+ noudevsync_ARG,\
+ permission_ARG,\
+ setactivationskip_ARG,\
+ test_ARG,\
+ type_ARG
+
+#define CACHE_POOL_ARGS \
+ cachemode_ARG,\
+ cachepool_ARG
+
+#define MIRROR_ARGS \
+ corelog_ARG,\
+ mirrorlog_ARG
+
+#define MIRROR_RAID_ARGS \
+ mirrors_ARG,\
+ nosync_ARG,\
+ regionsize_ARG
+
+#define PERSISTENT_ARGS \
+ major_ARG,\
+ minor_ARG,\
+ persistent_ARG
+
+#define POOL_ARGS \
+ pooldatasize_ARG,\
+ poolmetadatasize_ARG,\
+ poolmetadataspare_ARG
+
+#define RAID_ARGS \
+ maxrecoveryrate_ARG,\
+ minrecoveryrate_ARG,\
+ raidmaxrecoveryrate_ARG,\
+ raidminrecoveryrate_ARG
+
+#define SIZE_ARGS \
+ extents_ARG,\
+ size_ARG,\
+ stripes_ARG,\
+ stripesize_ARG
+
+#define THIN_POOL_ARGS \
+ discards_ARG,\
+ thinpool_ARG
+
+ /* Cache and cache-pool segment type */
+ if (seg_is_cache(lp)) {
+ /* Only supported with --type cache, -H, --cache */
+ if (arg_outside_list_is_set(cmd, "is unsupported with cache",
+ CACHE_POOL_ARGS,
+ LVCREATE_ARGS,
+ PERSISTENT_ARGS,
+ POOL_ARGS,
+ SIZE_ARGS,
+ cache_ARG,
+ chunksize_ARG,
+ wipesignatures_ARG, zero_ARG,
+ -1))
return_0;
-
- if (seg_is_pool(lp)) {
- log_error("Snapshots are incompatible with pool segment types.");
+ lp->create_pool = 1; /* Confirmed when opened VG */
+ } else if (seg_is_cache_pool(lp)) {
+ if (arg_outside_list_is_set(cmd, "is unsupported with cache pools",
+ CACHE_POOL_ARGS,
+ LVCREATE_ARGS,
+ POOL_ARGS,
+ SIZE_ARGS,
+ chunksize_ARG,
+ -1))
+ return_0;
+ if (!(lp->permission & LVM_WRITE)) {
+ log_error("Cannot create read-only cache pool.");
return 0;
}
+ lp->create_pool = 1;
+ } else if (arg_from_list_is_set(cmd, "is supported only with cache",
+ cache_ARG, CACHE_POOL_ARGS,
+ -1))
+ return_0;
+
+ /* Snapshot segment type */
+ if (seg_is_snapshot(lp)) {
+ /* Only supported with --type snapshot, -s, --snapshot */
+ if (arg_outside_list_is_set(cmd, "is unsupported with snapshots",
+ LVCREATE_ARGS,
+ PERSISTENT_ARGS,
+ SIZE_ARGS,
+ chunksize_ARG,
+ snapshot_ARG,
+ thinpool_ARG,
+ virtualoriginsize_ARG,
+ virtualsize_ARG,
+ -1))
+ return_0;
+
+ /* TODO: resolve this ambiguous case with --pooldatasize */
+ if (arg_is_set(cmd, thinpool_ARG)) {
+ if (lp->type) {
+ /* Unsupported with --type snapshot */
+ log_error("Snapshot segment type is incompatible with thin pools.");
+ return 0;
+ }
+
+ if (arg_from_list_is_set(cmd, "is unsupported with snapshots and --thinpool",
+ SIZE_ARGS,
+ chunksize_ARG,
+ virtualoriginsize_ARG,
+ virtualsize_ARG,
+ -1))
+ return_0;
+ }
- if (arg_is_set(cmd, thinpool_ARG) &&
- (arg_is_set(cmd, extents_ARG) || arg_is_set(cmd, size_ARG))) {
- log_error("Cannot specify snapshot size and thin pool.");
+ /* Snapshot segment type needs size/extents */
+ if (lp->type && !arg_is_set(cmd, size_ARG) && !arg_is_set(cmd, extents_ARG)) {
+ log_error("Snapshot segment type requires size or extents.");
return 0;
}
- lp->snapshot = 1;
- }
+ lp->snapshot = 1; /* Free arg is snapshot origin */
+ } else if (arg_from_list_is_set(cmd, "is supported only with sparse snapshots",
+ virtualoriginsize_ARG,
+ -1))
+ return_0;
+
+ /* Mirror segment type */
+ if (seg_is_mirror(lp)) {
+ if (arg_outside_list_is_set(cmd, "is unsupported with mirrors",
+ LVCREATE_ARGS,
+ MIRROR_ARGS,
+ MIRROR_RAID_ARGS,
+ PERSISTENT_ARGS,
+ SIZE_ARGS,
+ wipesignatures_ARG, zero_ARG,
+ -1))
+ return_0;
+ } else if (arg_from_list_is_set(cmd, "is supported only with mirrors",
+ MIRROR_ARGS,
+ -1))
+ return_0;
+ /* Raid segment type */
+ if (seg_is_raid(lp)) {
+ if (arg_outside_list_is_set(cmd, "is unsupported with raids",
+ LVCREATE_ARGS,
+ MIRROR_RAID_ARGS,
+ PERSISTENT_ARGS,
+ RAID_ARGS,
+ SIZE_ARGS,
+ wipesignatures_ARG, zero_ARG,
+ -1))
+ return_0;
+ } else if (arg_from_list_is_set(cmd, "is supported only with raids",
+ RAID_ARGS,
+ -1))
+ return_0;
+
+ /* Thin and thin-pool segment type */
if (seg_is_thin_volume(lp)) {
- if (arg_is_set(cmd, virtualsize_ARG))
- lp->thin = 1;
- else if (arg_is_set(cmd, name_ARG)) {
- log_error("Missing --virtualsize when specified --name of thin volume.");
- return 0;
- /* When no virtual size -> create thin-pool only */
- } else if (!(lp->segtype = get_segtype_from_string(cmd, "thin-pool")))
+ /* Only supported with --type thin, -T, --thin, -V */
+ if (arg_outside_list_is_set(cmd, "is unsupported with thins",
+ LVCREATE_ARGS,
+ PERSISTENT_ARGS,
+ POOL_ARGS,
+ SIZE_ARGS,
+ THIN_POOL_ARGS,
+ chunksize_ARG,
+ thin_ARG,
+ virtualsize_ARG,
+ wipesignatures_ARG, zero_ARG,
+ -1))
return_0;
- /* If size/extents given with thin, then we are creating a thin pool */
- if (arg_count(cmd, size_ARG) || arg_count(cmd, extents_ARG)) {
- if (lp->snapshot &&
- (arg_is_set(cmd, cachepool_ARG) || arg_is_set(cmd, thinpool_ARG))) {
- log_error("Size or extents cannot be specified with pool name.");
+ /* If size/extents given with thin, then we are also creating a thin-pool */
+ if (arg_is_set(cmd, size_ARG) || arg_is_set(cmd, extents_ARG)) {
+ if (arg_is_set(cmd, pooldatasize_ARG)) {
+ log_error("Please specify either size or pooldatasize.");
return 0;
}
lp->create_pool = 1;
- }
- } else if (seg_is_pool(lp)) {
- if (arg_from_list_is_set(cmd, "is unsupported with pool segment type",
- cache_ARG, mirrors_ARG, snapshot_ARG, thin_ARG,
- virtualsize_ARG,
- -1))
+ } else if (arg_from_list_is_set(cmd, "is supported only with thin pool creation",
+ POOL_ARGS,
+ SIZE_ARGS,
+ chunksize_ARG,
+ discards_ARG,
+ zero_ARG,
+ -1))
return_0;
- lp->create_pool = 1;
- }
- if (seg_is_mirrored(lp) || seg_is_raid(lp)) {
- /* Note: snapshots have snapshot_ARG or virtualsize_ARG */
- if (arg_from_list_is_set(cmd, "is unsupported with mirrored segment type",
- cache_ARG, cachepool_ARG,
- snapshot_ARG,
- thin_ARG, thinpool_ARG,
- virtualsize_ARG,
- -1))
+ if (!arg_is_set(cmd, virtualsize_ARG)) {
+ /* Without virtual size could be creation of thin-pool or snapshot */
+ if (lp->create_pool) {
+ if (lp->type) {
+ log_error("Thin segment type requires --virtualsize.");
+ return 0;
+ }
+
+ log_debug_metadata("Switching from thin to thin pool segment type.");
+ if (!(lp->segtype = get_segtype_from_string(cmd, "thin-pool")))
+ return_0;
+ } else /* Parse free arg as snapshot origin */
+ lp->snapshot = 1;
+ }
+ } else if (seg_is_thin_pool(lp)) {
+ if (arg_outside_list_is_set(cmd, "is unsupported with thin pools",
+ LVCREATE_ARGS,
+ POOL_ARGS,
+ SIZE_ARGS,
+ THIN_POOL_ARGS,
+ chunksize_ARG,
+ zero_ARG,
+ -1))
return_0;
- } else if (arg_from_list_is_set(cmd, "is unsupported without mirrored segment type",
- corelog_ARG, mirrorlog_ARG, nosync_ARG,
+ if (!(lp->permission & LVM_WRITE)) {
+ log_error("Cannot create read-only thin pool.");
+ return 0;
+ }
+ lp->create_pool = 1;
+ } else if (!lp->snapshot &&
+ arg_from_list_is_set(cmd, "is supported only with thins",
+ thin_ARG, THIN_POOL_ARGS,
-1))
return_0;
- /* Default to 2 mirrored areas if '--type mirror|raid1|raid10' */
- lp->mirrors = segtype_is_mirrored(lp->segtype) ? 2 : 1;
-
- if (arg_count(cmd, mirrors_ARG)) {
- if (arg_sign_value(cmd, mirrors_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Mirrors argument may not be negative");
+ /* Check options shared between more segment types */
+ if (!seg_is_mirror(lp) && !seg_is_raid(lp)) {
+ if (arg_from_list_is_set(cmd, "is supported only with mirrors or raids",
+ nosync_ARG,
+ regionsize_ARG,
+ -1))
+ return_0;
+ /* Let -m0 pass */
+ if (arg_int_value(cmd, mirrors_ARG, 0)) {
+ log_error("--mirrors is supported only with mirrors or raids");
return 0;
}
+ }
- lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1;
-
- if (lp->mirrors > DEFAULT_MIRROR_MAX_IMAGES) {
- log_error("Only up to " DM_TO_STRING(DEFAULT_MIRROR_MAX_IMAGES)
- " images in mirror supported currently.");
- return 0;
- }
+ if (!lp->create_pool && !lp->snapshot &&
+ arg_from_list_is_set(cmd, "is supported only with pools and snapshots",
+ chunksize_ARG,
+ -1))
+ return_0;
- if (lp->mirrors == 1) {
- if (segtype_is_mirrored(lp->segtype)) {
- log_error("--mirrors must be at least 1 with segment type %s.", lp->segtype->name);
- return 0;
- }
- log_print_unless_silent("Redundant mirrors argument: default is 0");
- }
+ if (!lp->snapshot && !seg_is_thin_volume(lp) &&
+ arg_from_list_is_set(cmd, "is supported only with sparse snapshots and thins",
+ virtualsize_ARG,
+ -1))
+ return_0;
- if ((lp->mirrors > 2) && !strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
- /*
- * FIXME: When RAID10 is no longer limited to
- * 2-way mirror, 'lv_mirror_count()'
- * must also change for RAID10.
- */
- log_error("RAID10 currently supports "
- "only 2-way mirroring (i.e. '-m 1')");
- return 0;
- }
- }
+ /* Basic segment type validation finished here */
if (activation() && lp->segtype->ops->target_present) {
if (!lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
@@ -898,22 +1017,15 @@ static int _lvcreate_params(struct lvcreate_params *lp,
lp->wipe_signatures = 0;
}
- if (arg_count(cmd, chunksize_ARG) &&
- (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS)) {
- log_error("Negative chunk size is invalid.");
- return 0;
- }
-
- if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
- !_read_size_params(lp, lcp, cmd) ||
+ if (!_lvcreate_name_params(cmd, &argc, &argv, lp) ||
+ !_read_size_params(cmd, lp, lcp) ||
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
(lp->create_pool &&
!get_pool_params(cmd, lp->segtype, &lp->passed_args,
&lp->pool_metadata_size, &lp->pool_metadata_spare,
&lp->chunk_size, &lp->discards, &lp->zero)) ||
- !_read_mirror_params(lp, cmd) ||
- !_read_raid_params(lp, cmd) ||
- !_read_cache_pool_params(lp, cmd))
+ !_read_cache_params(cmd, lp) ||
+ !_read_mirror_and_raid_params(cmd, lp))
return_0;
if (only_linear && lp->stripes > 1) {
@@ -930,22 +1042,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 0;
}
log_verbose("Setting chunksize to %s.", display_size(cmd, lp->chunk_size));
-
- if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
- return_0;
- } else if (!lp->create_pool && arg_count(cmd, chunksize_ARG)) {
- log_error("--chunksize is only available with snapshots and pools.");
- return 0;
}
- if (!lp->create_pool &&
- arg_count(cmd, poolmetadataspare_ARG)) {
- log_error("--poolmetadataspare is only available with pool creation.");
- return 0;
- }
- /*
- * Allocation parameters
- */
+ /* Allocation parameters */
contiguous = arg_int_value(cmd, contiguous_ARG, 0);
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lp->alloc);
@@ -991,31 +1090,59 @@ static int _determine_cache_argument(struct volume_group *vg,
{
struct logical_volume *lv;
- if (!seg_is_cache(lp)) {
- log_error(INTERNAL_ERROR
- "Unable to determine cache argument on %s segtype",
- lp->segtype->name);
- return 0;
- }
-
if (!lp->pool_name) {
lp->pool_name = lp->lv_name;
- } else if (lp->pool_name == lp->origin_name) {
- if (!(lv = find_lv(vg, lp->pool_name))) {
- /* Cache pool nor origin volume exists */
- lp->cache = 0;
- lp->origin_name = NULL;
- if (!(lp->segtype = get_segtype_from_string(vg->cmd, "cache-pool")))
- return_0;
- } else if (!lv_is_cache_pool(lv)) {
- /* Name arg in this case is for pool name */
- lp->pool_name = lp->lv_name;
- /* We were given origin for caching */
- } else {
- /* FIXME error on pool args */
- lp->create_pool = 0;
- lp->origin_name = NULL;
+ } else if ((lv = find_lv(vg, lp->pool_name)) && lv_is_cache_pool(lv)) {
+ /* Pool exists, create cache volume */
+ lp->create_pool = 0;
+ lp->origin_name = NULL;
+ } else if (lv) {
+ /* Origin exists, create cache pool volume */
+ if (!validate_lv_cache_create_origin(lv))
+ return_0;
+
+ if (arg_is_set(vg->cmd, permission_ARG) &&
+ ((lp->permission & LVM_WRITE) != (lv->status & LVM_WRITE))) {
+ /* Reverting permissions on all error path is very complicated */
+ log_error("Change of volume permission is unsupported with cache conversion, use lvchange.");
+ return 0;
}
+ /* FIXME: how to handle skip flag */
+ if (arg_from_list_is_set(vg->cmd, "is unsupported with cache conversion",
+ setactivationskip_ARG,
+ ignoreactivationskip_ARG,
+ -1))
+ return_0; /* TODO FIX THIS */
+
+ /* Put origin into resulting activation state first */
+ if (is_change_activating(lp->activate)) {
+ if ((lp->activate == CHANGE_AAY) &&
+ !lv_passes_auto_activation_filter(vg->cmd, lv)) {
+ log_verbose("Skipping activation of cache origin %s.",
+ display_lvname(lv));
+ return 1;
+ } else if (!activate_lv_excl_local(vg->cmd, lv)) {
+ log_error("Cannot activate cache origin %s.",
+ display_lvname(lv));
+ return 0;
+ }
+ } else if (!deactivate_lv(vg->cmd, lv)) {
+ log_error("Cannot deactivate activate cache origin %s.",
+ display_lvname(lv));
+ return 0;
+ }
+
+ /* lp->origin_name is already equal to lp->pool_name */
+ lp->pool_name = lp->lv_name; /* --name is cache pool name */
+ /* No zeroing of an existing origin! */
+ lp->zero = lp->wipe_signatures = 0;
+ } else {
+ /* Cache pool and cache volume needs to be created */
+ lp->origin_name = NULL;
+ /* --pooldatasize is needed here */
+ log_error("Ambiguous syntax, please create --type cache-pool %s separately.",
+ lp->pool_name);
+ return 0;
}
return 1;
@@ -1025,21 +1152,20 @@ static int _determine_cache_argument(struct volume_group *vg,
* Normal snapshot or thinly-provisioned snapshot?
*/
static int _determine_snapshot_type(struct volume_group *vg,
- struct lvcreate_params *lp)
+ struct lvcreate_params *lp,
+ struct lvcreate_cmdline_params *lcp)
{
- struct logical_volume *lv, *pool_lv = NULL;
+ struct logical_volume *origin_lv, *pool_lv = NULL;
- if (!(lv = find_lv(vg, lp->origin_name))) {
+ if (!(origin_lv = find_lv(vg, lp->origin_name))) {
log_error("Snapshot origin LV %s not found in Volume group %s.",
lp->origin_name, vg->name);
return 0;
}
+ if (lp->extents || lcp->size)
+ return 1; /* Size specified */
- if (lv_is_cache(lv)) {
- log_error("Snapshot of cache LV is not yet supported.");
- return 0;
- }
-
+ /* Check if we could make thin snapshot */
if (lp->pool_name) {
if (!(pool_lv = find_lv(vg, lp->pool_name))) {
log_error("Thin pool volume %s not found in Volume group %s.",
@@ -1052,24 +1178,63 @@ static int _determine_snapshot_type(struct volume_group *vg,
display_lvname(pool_lv));
return 0;
}
+ } else {
+ if (!lv_is_thin_volume(origin_lv)) {
+ if (!seg_is_thin(lp))
+ log_error("Please specify either size or extents with snapshots.");
+ else
+ log_error("Logical volume %s is not a thin volume. "
+ "Thin snapshot supports only thin origins.",
+ display_lvname(origin_lv));
+ return 0;
+ }
+ /* Origin thin volume without size makes thin segment */
+ lp->pool_name = first_seg(origin_lv)->pool_lv->name;
}
- if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
- if (lv_is_thin_volume(lv) && !lp->pool_name)
- lp->pool_name = first_seg(lv)->pool_lv->name;
+ log_debug_metadata("Switching from snapshot to thin segment type.");
+ if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
+ return_0;
+ lp->snapshot = 0;
- if (seg_is_thin(lp) || lp->pool_name) {
- if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
- return_0;
- return 1;
- }
+ return 1;
+}
- log_error("Please specify either size or extents with snapshots.");
- return 0;
- } else if (lp->pool_name) {
- log_error("Cannot specify size with thin pool snapshot.");
- return 0;
+static int _check_raid_parameters(struct volume_group *vg,
+ struct lvcreate_params *lp,
+ struct lvcreate_cmdline_params *lcp)
+{
+ unsigned devs = lcp->pv_count ? : dm_list_size(&vg->pvs);
+ struct cmd_context *cmd = vg->cmd;
+
+ /*
+ * If number of devices was not supplied, we can infer from
+ * the PVs given.
+ */
+ if (!seg_is_mirrored(lp)) {
+ if (!arg_count(cmd, stripes_ARG) &&
+ (devs > 2 * lp->segtype->parity_devs))
+ lp->stripes = devs - lp->segtype->parity_devs;
+
+ if (!lp->stripe_size)
+ lp->stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
+
+ if (lp->stripes <= lp->segtype->parity_devs) {
+ log_error("Number of stripes must be at least %d for %s",
+ lp->segtype->parity_devs + 1,
+ lp->segtype->name);
+ return 0;
+ }
+ } else if (!strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
+ if (!arg_count(cmd, stripes_ARG))
+ lp->stripes = devs / lp->mirrors;
+ if (lp->stripes < 2) {
+ log_error("Unable to create RAID10 LV,"
+ " insufficient number of devices.");
+ return 0;
+ }
}
+ /* 'mirrors' defaults to 2 - not the number of PVs supplied */
return 1;
}
@@ -1077,74 +1242,110 @@ static int _determine_snapshot_type(struct volume_group *vg,
static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_params *lp,
struct lvcreate_cmdline_params *lcp)
{
- struct logical_volume *pool_lv = NULL;
-
- if (!lp->thin && !lp->create_pool && !lp->snapshot) {
- log_error("Please specify device size(s).");
- return 0;
- }
-
- if (lp->thin && lp->snapshot) {
+ if (seg_is_thin_volume(lp) && lp->snapshot) {
log_error("Please either create snapshot or thin volume.");
return 0;
}
- if (lp->pool_name)
- pool_lv = find_lv(vg, lp->pool_name);
-
- if (!lp->create_pool) {
- if (arg_from_list_is_set(vg->cmd, "is only available with thin pool creation",
+ if (!seg_is_thin_volume(lp) && !lp->snapshot) {
+ /* Not creating thin volume nor snapshot */
+ if (arg_from_list_is_set(vg->cmd, "may only be given when creating a new thin Logical volume or snapshot",
+ permission_ARG,
+ persistent_ARG,
+ readahead_ARG,
+ -1))
+ return_0;
+ if (!lp->create_pool) {
+ /* Not even creating thin pool? */
+ log_error("Please specify device size(s).");
+ return 0;
+ }
+ } else if (!lp->create_pool) {
+ if (arg_from_list_is_set(vg->cmd, "is only available when creating thin pool",
alloc_ARG,
chunksize_ARG,
contiguous_ARG,
- discards_ARG,
- poolmetadatasize_ARG,
- poolmetadataspare_ARG,
stripes_ARG,
- stripesize_ARG,
zero_ARG,
-1))
return_0;
if (lcp->pv_count) {
- log_error("Only specify Physical volumes when allocating the thin pool.");
+ log_error("Only specify Physical volumes when allocating thin pool.");
return 0;
}
+ }
- if (!lp->pool_name) {
- log_error("Please specify name of existing thin pool.");
- return 0;
- }
+ return 1;
+}
+
+static int _check_pool_parameters(struct cmd_context *cmd,
+ struct volume_group *vg,
+ struct lvcreate_params *lp,
+ struct lvcreate_cmdline_params *lcp)
+{
+ struct logical_volume *pool_lv;
- if (!pool_lv) {
- log_error("Thin pool %s not found in Volume group %s.", lp->pool_name, vg->name);
+ if (!lp->create_pool &&
+ arg_from_list_is_set(cmd, "is only available with pools",
+ POOL_ARGS,
+ discards_ARG,
+ -1))
+ return_0;
+
+ if (!seg_is_cache(lp) &&
+ !seg_is_thin_volume(lp) &&
+ !seg_is_pool(lp)) {
+ if (lp->pool_name && !lp->snapshot) {
+ log_error("Segment type %s cannot use pool %s.",
+ lp->segtype->name, lp->pool_name);
return 0;
}
+ return 1; /* Pool unrelated types */
+ }
- if (!lv_is_thin_pool(pool_lv)) {
- log_error("Logical volume %s is not a thin pool.", display_lvname(pool_lv));
- return 0;
+ if (lp->create_pool) {
+ /* Given pool name needs to follow restrictions for created LV */
+ if (lp->pool_name) {
+ if (!apply_lvname_restrictions(lp->pool_name))
+ return_0;
+ /* We could check existance only when we have vg */
+ if (vg && find_lv(vg, lp->pool_name)) {
+ log_error("Logical volume %s already exists in Volume group %s.",
+ lp->pool_name, vg->name);
+ return 0;
+ }
}
- } else if (pool_lv) {
- log_error("Logical volume %s already exists in Volume group %s.", lp->pool_name, vg->name);
+ /* When creating just pool the pool_name needs to be in lv_name */
+ if (seg_is_pool(lp))
+ lp->lv_name = lp->pool_name;
+
+ return 1;
+ }
+ /* Not creating new pool, but existing pool is needed */
+ if (!lp->pool_name) {
+ if (lp->snapshot)
+ /* Taking snapshot via 'lvcreate -T vg/origin' */
+ return 1;
+ log_error("Please specify name of existing pool.");
return 0;
}
- if (!lp->thin && !lp->snapshot) {
- if (lp->lv_name) {
- log_error("--name may only be given when creating a new thin Logical volume or snapshot.");
- return 0;
- }
- if (arg_count(vg->cmd, readahead_ARG)) {
- log_error("--readhead may only be given when creating a new thin Logical volume or snapshot.");
+ if (vg) {
+ /* Validate pool has matching type */
+ if (!(pool_lv = find_lv(vg, lp->pool_name))) {
+ log_error("Pool %s not found in Volume group %s.",
+ lp->pool_name, vg->name);
return 0;
}
- if (arg_count(vg->cmd, permission_ARG)) {
- log_error("--permission may only be given when creating a new thin Logical volume or snapshot.");
+ if (seg_is_cache(lp) && !lv_is_cache_pool(pool_lv)) {
+ log_error("Logical volume %s is not a cache pool.",
+ display_lvname(pool_lv));
return 0;
}
- if (arg_count(vg->cmd, persistent_ARG)) {
- log_error("--persistent may only be given when creating a new thin Logical volume or snapshot.");
+ if (seg_is_thin_volume(lp) && !lv_is_thin_pool(pool_lv)) {
+ log_error("Logical volume %s is not a thin pool.",
+ display_lvname(pool_lv));
return 0;
}
}
@@ -1152,44 +1353,6 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
return 1;
}
-static int _check_raid_parameters(struct volume_group *vg,
- struct lvcreate_params *lp,
- struct lvcreate_cmdline_params *lcp)
-{
- unsigned devs = lcp->pv_count ? : dm_list_size(&vg->pvs);
- struct cmd_context *cmd = vg->cmd;
-
- /*
- * If number of devices was not supplied, we can infer from
- * the PVs given.
- */
- if (!seg_is_mirrored(lp)) {
- if (!arg_count(cmd, stripes_ARG) &&
- (devs > 2 * lp->segtype->parity_devs))
- lp->stripes = devs - lp->segtype->parity_devs;
-
- if (!lp->stripe_size)
- lp->stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
-
- if (lp->stripes <= lp->segtype->parity_devs) {
- log_error("Number of stripes must be at least %d for %s",
- lp->segtype->parity_devs + 1,
- lp->segtype->name);
- return 0;
- }
- } else if (!strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
- if (!arg_count(cmd, stripes_ARG))
- lp->stripes = devs / lp->mirrors;
- if (lp->stripes < 2) {
- log_error("Unable to create RAID10 LV,"
- " insufficient number of devices.");
- return 0;
- }
- }
- /* 'mirrors' defaults to 2 - not the number of PVs supplied */
-
- return 1;
-}
/*
* Ensure the set of thin parameters extracted from the command line is consistent.
@@ -1212,21 +1375,17 @@ static int _validate_internal_thin_processing(const struct lvcreate_params *lp)
r = 0;
}
- if ((lp->snapshot && !lp->origin_name) || (!lp->snapshot && lp->origin_name)) {
+ if ((!lp->origin_name && lp->snapshot) ||
+ (lp->origin_name && !lp->snapshot && !seg_is_thin_volume(lp))) {
log_error(INTERNAL_ERROR "Inconsistent snapshot and origin parameters identified.");
r = 0;
}
- if (!lp->thin && !lp->create_pool && !lp->snapshot) {
+ if (!lp->create_pool && !lp->snapshot && !seg_is_thin_volume(lp)) {
log_error(INTERNAL_ERROR "Failed to identify what type of thin target to use.");
r = 0;
}
- if (seg_is_thin_pool(lp) && lp->thin) {
- log_error(INTERNAL_ERROR "Thin volume cannot be created with thin pool segment type.");
- r = 0;
- }
-
return r;
}
@@ -1240,8 +1399,15 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
struct lvcreate_cmdline_params lcp;
struct volume_group *vg;
- if (!_lvcreate_params(&lp, &lcp, cmd, argc, argv))
+ if (!_lvcreate_params(cmd, argc, argv, &lp, &lcp)) {
+ stack;
return EINVALID_CMD_LINE;
+ }
+
+ if (!_check_pool_parameters(cmd, NULL, &lp, &lcp)) {
+ stack;
+ return EINVALID_CMD_LINE;
+ }
log_verbose("Finding volume group \"%s\"", lp.vg_name);
vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
@@ -1250,23 +1416,28 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
}
- if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp))
- goto_out;
-
- if (seg_is_thin(&lp) && !_check_thin_parameters(vg, &lp, &lcp))
+ /* Resolve segment types with opened VG */
+ if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp, &lcp))
goto_out;
if (seg_is_cache(&lp) && !_determine_cache_argument(vg, &lp))
goto_out;
+ /* All types resolved at this point, now only validation steps */
if (seg_is_raid(&lp) && !_check_raid_parameters(vg, &lp, &lcp))
goto_out;
+ if (seg_is_thin(&lp) && !_check_thin_parameters(vg, &lp, &lcp))
+ goto_out;
+
+ if (!_check_pool_parameters(cmd, vg, &lp, &lcp))
+ goto_out;
+
/*
* Check activation parameters to support inactive thin snapshot creation
* FIXME: anything else needs to be moved past _determine_snapshot_type()?
*/
- if (!_read_activation_params(&lp, cmd, vg))
+ if (!_read_activation_params(cmd, vg, &lp))
goto_out;
if (!_update_extents_params(vg, &lp, &lcp))
@@ -1284,7 +1455,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
lp.pool_name ? : "with generated name", lp.vg_name, lp.segtype->name);
}
- if (lp.thin)
+ if (seg_is_thin_volume(&lp))
log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s",
lp.lv_name ? : "with generated name",
lp.pool_name ? : "with generated name", lp.vg_name,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=51a29e60564d5379…
Commit: 51a29e60564d5379b38ee4688bca5eb9b844c410
Parent: dfcf03a9ce2fe9b618f44c5f99e13ff5610ffcc0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 24 15:21:48 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
pools: error path removes metadata
When pool volume is create - it has already managed to update metadata
once within lv_extend - so revert new created LV here.
---
lib/metadata/lv_manip.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5125412..277a51d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6888,8 +6888,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
first_seg(lv)->feature_flags = lp->feature_flags;
/* TODO: some calc_policy solution for cache ? */
if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->passed_args,
- THIN_CHUNK_SIZE_CALC_METHOD_GENERIC))
- return_NULL;
+ THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) {
+ stack;
+ goto revert_new_lv;
+ }
} else if (seg_is_raid(lp)) {
first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
@@ -6900,8 +6902,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */
first_seg(lv)->low_water_mark = 0;
if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->passed_args,
- lp->thin_chunk_size_calc_policy))
- return_NULL;
+ lp->thin_chunk_size_calc_policy)) {
+ stack;
+ goto revert_new_lv;
+ }
} else if (seg_is_thin_volume(lp)) {
pool_lv = first_seg(lv)->pool_lv;
if (!(first_seg(lv)->device_id =
@@ -7007,8 +7011,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/* store vg on disk(s) */
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ if (seg_is_pool(lp)) {
+ /* Pool volumes have already created metadata LV */
+ stack;
+ goto revert_new_lv;
+ }
return_NULL;
+ }
backup(vg);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dfcf03a9ce2fe9b6…
Commit: dfcf03a9ce2fe9b618f44c5f99e13ff5610ffcc0
Parent: 7359a9df889a2ed8d6e6114ecc3f57438a75d9d7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 11 18:36:40 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
lvcreate: handle linear segment
Put in code to accept 'linear' segment type
(when specified stripes cannot be used)
Also report 'error' when unknown type is specified.
---
WHATS_NEW | 1 +
tools/lvcreate.c | 10 ++++++++++
tools/lvmcmdline.c | 8 +++++++-
3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 70b41bc..fa88ddc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Support lvcreate --type linear.
Improve _should_wipe_lv() to warn with message.
Inform about temporarily created volumes only in verbose mode.
Better support for --test mode with pool creation.
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 301bda6..b6907f5 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -714,6 +714,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
struct arg_value_group_list *current_group;
const char *segtype_str;
const char *tag;
+ int only_linear = 0;
memset(lcp, 0, sizeof(*lcp));
dm_list_init(&lp->tags);
@@ -745,6 +746,10 @@ static int _lvcreate_params(struct lvcreate_params *lp,
segtype_str = "striped";
segtype_str = arg_str_value(cmd, type_ARG, segtype_str);
+ if (!strcmp(segtype_str, "linear")) {
+ segtype_str = "striped";
+ only_linear = 1; /* User requested linear only target */
+ }
if (!(lp->segtype = get_segtype_from_string(cmd, segtype_str)))
return_0;
@@ -911,6 +916,11 @@ static int _lvcreate_params(struct lvcreate_params *lp,
!_read_cache_pool_params(lp, cmd))
return_0;
+ if (only_linear && lp->stripes > 1) {
+ log_error("Cannot use stripes with linear type.");
+ return 0;
+ }
+
if (lp->snapshot && (lp->extents || lcp->size)) {
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 6e13679..bbf0145 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -564,7 +564,13 @@ int alloc_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values
int segtype_arg(struct cmd_context *cmd, struct arg_values *av)
{
- return get_segtype_from_string(cmd, av->value) ? 1 : 0;
+ struct segment_type *segtype;
+ const char *str = (!strcmp(av->value, "linear")) ? "striped" : av->value;
+
+ if (!(segtype = get_segtype_from_string(cmd, str)))
+ return_0;
+
+ return (!segtype_is_unknown(segtype)) ? 1 : 0;
}
/*
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7359a9df889a2ed8…
Commit: 7359a9df889a2ed8d6e6114ecc3f57438a75d9d7
Parent: 16320642813c811c30c9348c57b7f7fec1221ee9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 24 14:22:25 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
pool: better error path handling
Move test for size of new LV names in front before
any creation of LV.
Properly check striped segtype kernel presence,
since passed 'segtype' is already tested.
Keep deactivation error path local to wiping part of the function.
Create metadata with temporary flag (it's activated, zeroed
and deactivated).
---
lib/metadata/pool_manip.c | 52 +++++++++++++++++++++++++-------------------
1 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 02a82bd..b4259a8 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -390,6 +390,7 @@ int create_pool(struct logical_volume *pool_lv,
struct logical_volume *meta_lv, *data_lv;
struct lv_segment *seg;
char name[NAME_LEN];
+ int r;
if (pool_lv->le_count) {
log_error(INTERNAL_ERROR "Pool %s already has extents.",
@@ -397,14 +398,22 @@ int create_pool(struct logical_volume *pool_lv,
return 0;
}
+ if (dm_snprintf(name, sizeof(name), "%s_%s", pool_lv->name,
+ (segtype_is_cache_pool(segtype)) ?
+ "cmeta" : "tmeta") < 0) {
+ log_error("Name of logical volume %s is too long to be a pool name.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+
/* LV is not yet a pool, so it's extension from lvcreate */
if (!(striped = get_segtype_from_string(pool_lv->vg->cmd, "striped")))
return_0;
- if (activation() && segtype->ops->target_present &&
- !segtype->ops->target_present(pool_lv->vg->cmd, NULL, NULL)) {
+ if (activation() && striped->ops->target_present &&
+ !striped->ops->target_present(pool_lv->vg->cmd, NULL, NULL)) {
log_error("%s: Required device-mapper target(s) not "
- "detected in your kernel.", segtype->name);
+ "detected in your kernel.", striped->name);
return 0;
}
@@ -432,24 +441,25 @@ int create_pool(struct logical_volume *pool_lv,
* or directly converted to invisible device via suspend/resume
*/
pool_lv->status |= LV_TEMPORARY;
- if (!activate_lv_local(pool_lv->vg->cmd, pool_lv) ||
- /* Clear 4KB of pool metadata device. */
- !wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 })) {
- log_error("Aborting. Failed to wipe pool metadata %s.",
- pool_lv->name);
+ if (!activate_lv_local(pool_lv->vg->cmd, pool_lv)) {
+ log_error("Aborting. Failed to activate pool metadata %s.",
+ display_lvname(pool_lv));
goto bad;
}
+ /* Clear 4KB of pool metadata device. */
+ if (!(r = wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 }))) {
+ log_error("Aborting. Failed to wipe pool metadata %s.",
+ display_lvname(pool_lv));
+ }
pool_lv->status &= ~LV_TEMPORARY;
/* Deactivates cleared metadata LV */
- if (!deactivate_lv_local(pool_lv->vg->cmd, pool_lv))
- goto_bad;
- }
-
- if (dm_snprintf(name, sizeof(name), "%s_%s", pool_lv->name,
- (segtype_is_cache_pool(segtype)) ?
- "cmeta" : "tmeta") < 0) {
- log_error("Name is too long to be a pool name.");
- goto bad;
+ if (!deactivate_lv_local(pool_lv->vg->cmd, pool_lv)) {
+ log_error("Aborting. Could not deactivate pool metadata %s.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+ if (!r)
+ goto bad;
}
if (!(meta_lv = lv_create_empty(name, NULL, LVM_READ | LVM_WRITE,
@@ -486,12 +496,7 @@ int create_pool(struct logical_volume *pool_lv,
bad:
if (activation()) {
- if (lv_is_active_locally(pool_lv) &&
- deactivate_lv_local(pool_lv->vg->cmd, pool_lv)) {
- log_error("Aborting. Could not deactivate pool %s.",
- pool_lv->name);
- return 0;
- }
+ /* Without activation there was no intermediate commit */
if (!lv_remove(pool_lv) ||
!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
log_error("Manual intervention may be required to "
@@ -520,6 +525,7 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
.stripe_size = stripe_size,
.stripes = stripes,
.zero = 1,
+ .temporary = 1,
};
dm_list_init(&lvc.tags);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=16320642813c811c…
Commit: 16320642813c811c30c9348c57b7f7fec1221ee9
Parent: b23e125982ea5f1c4b712a31b2133526a8fc12d8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 13:53:36 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
cleanup: code move
Update comment and move code to new place.
Gets updated with next commit.
---
tools/lvcreate.c | 196 +++++++++++++++++++++++++++---------------------------
1 files changed, 98 insertions(+), 98 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 8c52611..301bda6 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -231,104 +231,6 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
}
/*
- * Normal snapshot or thinly-provisioned snapshot?
- */
-static int _determine_snapshot_type(struct volume_group *vg,
- struct lvcreate_params *lp)
-{
- struct logical_volume *lv, *pool_lv = NULL;
-
- if (!(lv = find_lv(vg, lp->origin_name))) {
- log_error("Snapshot origin LV %s not found in Volume group %s.",
- lp->origin_name, vg->name);
- return 0;
- }
-
- if (lv_is_cache(lv)) {
- log_error("Snapshot of cache LV is not yet supported.");
- return 0;
- }
-
- if (lp->pool_name) {
- if (!(pool_lv = find_lv(vg, lp->pool_name))) {
- log_error("Thin pool volume %s not found in Volume group %s.",
- lp->pool_name, vg->name);
- return 0;
- }
-
- if (!lv_is_thin_pool(pool_lv)) {
- log_error("Logical volume %s is not a thin pool volume.",
- display_lvname(pool_lv));
- return 0;
- }
- }
-
- if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
- if (lv_is_thin_volume(lv) && !lp->pool_name)
- lp->pool_name = first_seg(lv)->pool_lv->name;
-
- if (seg_is_thin(lp) || lp->pool_name) {
- if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
- return_0;
- return 1;
- }
-
- log_error("Please specify either size or extents with snapshots.");
- return 0;
- } else if (lp->pool_name) {
- log_error("Cannot specify size with thin pool snapshot.");
- return 0;
- }
-
- return 1;
-}
-
-/*
- * _determine_cache_argument
- * @vg
- * @lp
- *
- * 'lp->pool' is set with an LV that could be either the cache_pool
- * or the origin of the cached LV which is being created. This
- * function determines which it is and sets 'lp->origin' or
- * 'lp->pool' appropriately.
- */
-static int _determine_cache_argument(struct volume_group *vg,
- struct lvcreate_params *lp)
-{
- struct logical_volume *lv;
-
- if (!seg_is_cache(lp)) {
- log_error(INTERNAL_ERROR
- "Unable to determine cache argument on %s segtype",
- lp->segtype->name);
- return 0;
- }
-
- if (!lp->pool_name) {
- lp->pool_name = lp->lv_name;
- } else if (lp->pool_name == lp->origin_name) {
- if (!(lv = find_lv(vg, lp->pool_name))) {
- /* Cache pool nor origin volume exists */
- lp->cache = 0;
- lp->origin_name = NULL;
- if (!(lp->segtype = get_segtype_from_string(vg->cmd, "cache-pool")))
- return_0;
- } else if (!lv_is_cache_pool(lv)) {
- /* Name arg in this case is for pool name */
- lp->pool_name = lp->lv_name;
- /* We were given origin for caching */
- } else {
- /* FIXME error on pool args */
- lp->create_pool = 0;
- lp->origin_name = NULL;
- }
- }
-
- return 1;
-}
-
-/*
* Update extents parameters based on other parameters which affect the size
* calculation.
* NOTE: We must do this here because of the dm_percent_t typedef and because we
@@ -1064,6 +966,104 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 1;
}
+/*
+ * _determine_cache_argument
+ * @vg
+ * @lp
+ *
+ * 'lp->pool_name' is set with an LV that could be either the cache_pool name
+ * or the origin name of the cached LV which is being created.
+ * This function determines which it is and sets 'lp->origin_name' or
+ * 'lp->pool_name' appropriately.
+ */
+static int _determine_cache_argument(struct volume_group *vg,
+ struct lvcreate_params *lp)
+{
+ struct logical_volume *lv;
+
+ if (!seg_is_cache(lp)) {
+ log_error(INTERNAL_ERROR
+ "Unable to determine cache argument on %s segtype",
+ lp->segtype->name);
+ return 0;
+ }
+
+ if (!lp->pool_name) {
+ lp->pool_name = lp->lv_name;
+ } else if (lp->pool_name == lp->origin_name) {
+ if (!(lv = find_lv(vg, lp->pool_name))) {
+ /* Cache pool nor origin volume exists */
+ lp->cache = 0;
+ lp->origin_name = NULL;
+ if (!(lp->segtype = get_segtype_from_string(vg->cmd, "cache-pool")))
+ return_0;
+ } else if (!lv_is_cache_pool(lv)) {
+ /* Name arg in this case is for pool name */
+ lp->pool_name = lp->lv_name;
+ /* We were given origin for caching */
+ } else {
+ /* FIXME error on pool args */
+ lp->create_pool = 0;
+ lp->origin_name = NULL;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Normal snapshot or thinly-provisioned snapshot?
+ */
+static int _determine_snapshot_type(struct volume_group *vg,
+ struct lvcreate_params *lp)
+{
+ struct logical_volume *lv, *pool_lv = NULL;
+
+ if (!(lv = find_lv(vg, lp->origin_name))) {
+ log_error("Snapshot origin LV %s not found in Volume group %s.",
+ lp->origin_name, vg->name);
+ return 0;
+ }
+
+ if (lv_is_cache(lv)) {
+ log_error("Snapshot of cache LV is not yet supported.");
+ return 0;
+ }
+
+ if (lp->pool_name) {
+ if (!(pool_lv = find_lv(vg, lp->pool_name))) {
+ log_error("Thin pool volume %s not found in Volume group %s.",
+ lp->pool_name, vg->name);
+ return 0;
+ }
+
+ if (!lv_is_thin_pool(pool_lv)) {
+ log_error("Logical volume %s is not a thin pool volume.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+ }
+
+ if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
+ if (lv_is_thin_volume(lv) && !lp->pool_name)
+ lp->pool_name = first_seg(lv)->pool_lv->name;
+
+ if (seg_is_thin(lp) || lp->pool_name) {
+ if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
+ return_0;
+ return 1;
+ }
+
+ log_error("Please specify either size or extents with snapshots.");
+ return 0;
+ } else if (lp->pool_name) {
+ log_error("Cannot specify size with thin pool snapshot.");
+ return 0;
+ }
+
+ return 1;
+}
+
static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_params *lp,
struct lvcreate_cmdline_params *lcp)
{
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b23e125982ea5f1c…
Commit: b23e125982ea5f1c4b712a31b2133526a8fc12d8
Parent: 21798418fc81a232d00e5a93ce4071004e6f0fed
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 13:40:16 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
cleanup: function embeded
It's used just in one place now.
---
tools/lvcreate.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 7ccd9aa..8c52611 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -283,16 +283,6 @@ static int _determine_snapshot_type(struct volume_group *vg,
return 1;
}
-static int _lvcreate_update_pool_params(struct volume_group *vg,
- struct lvcreate_params *lp)
-{
- return update_pool_params(lp->segtype, vg, lp->target_attr,
- lp->passed_args, lp->extents,
- &lp->pool_metadata_size,
- &lp->thin_chunk_size_calc_policy, &lp->chunk_size,
- &lp->discards, &lp->zero);
-}
-
/*
* _determine_cache_argument
* @vg
@@ -458,7 +448,11 @@ static int _update_extents_params(struct volume_group *vg,
}
if (lp->create_pool) {
- if (!_lvcreate_update_pool_params(vg, lp))
+ if (!update_pool_params(lp->segtype, vg, lp->target_attr,
+ lp->passed_args, lp->extents,
+ &lp->pool_metadata_size,
+ &lp->thin_chunk_size_calc_policy, &lp->chunk_size,
+ &lp->discards, &lp->zero))
return_0;
if (!(lp->pool_metadata_extents =
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=21798418fc81a232…
Commit: 21798418fc81a232d00e5a93ce4071004e6f0fed
Parent: a330640063fed88616379e3c2e4e85b8e2e355b0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 13:38:47 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
cleanup: better stack tracing
Show proper backtrace on error path.
---
lib/metadata/lv_manip.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index fe0eead..5125412 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7113,16 +7113,20 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/* A virtual origin must be activated explicitly. */
- if (lp->voriginsize &&
- (!(origin_lv = _create_virtual_origin(cmd, vg, lv->name,
- lp->permission,
- lp->voriginextents)) ||
- !activate_lv_excl(cmd, origin_lv))) {
- log_error("Couldn't create virtual origin for LV %s",
- lv->name);
- if (origin_lv && !lv_remove(origin_lv))
+ if (lp->voriginsize) {
+ if (!(origin_lv = _create_virtual_origin(cmd, vg, lv->name,
+ lp->permission,
+ lp->voriginextents))) {
stack;
- goto deactivate_and_revert_new_lv;
+ goto deactivate_and_revert_new_lv;
+ }
+ if (!activate_lv_excl(cmd, origin_lv)) {
+ log_error("Couldn't get exclusive lock for virtual origin LV %s",
+ lv->name);
+ if (!lv_remove(origin_lv))
+ stack;
+ goto deactivate_and_revert_new_lv;
+ }
}
/*
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a330640063fed886…
Commit: a330640063fed88616379e3c2e4e85b8e2e355b0
Parent: 9a6758e953a83aeb1d384df97c6f18b542c569a2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 18 10:58:30 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200
options: introduce pooldatasize option
Introduce new option to specify pool data size.
This will be user to create i.e. cache & cachepool at once.
And possible for thin external origin snapshot.
This is only very basic patch to enable options, the
real working code will come later.
---
lib/metadata/metadata-exported.h | 2 ++
tools/args.h | 1 +
tools/commands.h | 7 +++++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index cfc0ce2..3d656b7 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -854,6 +854,8 @@ struct lvcreate_params {
uint64_t voriginsize; /* snapshot */
uint32_t pool_metadata_extents; /* pools */
uint64_t pool_metadata_size; /* pools */
+ uint32_t pool_data_extents; /* pools */
+ uint64_t pool_data_size; /* pools */
struct dm_list *pvh; /* all */
uint64_t permission; /* all */
diff --git a/tools/args.h b/tools/args.h
index 492eb28..4a4845f 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -69,6 +69,7 @@ arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0)
arg(originname_ARG, '\0', "originname", string_arg, 0)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
arg(poll_ARG, '\0', "poll", yes_no_arg, 0)
+arg(pooldatasize_ARG, '\0', "pooldatasize", size_mb_arg, 0)
arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0)
arg(poolmetadataspare_ARG, '\0', "poolmetadataspare", yes_no_arg, 0)
diff --git a/tools/commands.h b/tools/commands.h
index eb0d248..d4473a4 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -280,6 +280,7 @@ xx(lvcreate,
"\t[-n|--name LogicalVolumeName]\n"
"\t[--noudevsync]\n"
"\t[-p|--permission {r|rw}]\n"
+ "\t[--pooldatasize DataSize[bBsSkKmMgGtTpPeE]]\n"
"\t[--poolmetadatasize MetadataSize[bBsSkKmMgG]]\n"
"\t[--poolmetadataspare {y|n}]]\n"
"\t[--[raid]minrecoveryrate Rate]\n"
@@ -319,6 +320,7 @@ xx(lvcreate,
"\t[-K|--ignoreactivationskip]\n"
"\t{-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |\n"
"\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
+ "\t[--pooldatasize DataVolumeSize[bBsSkKmMgGtTpPeE]]\n"
"\t[--poolmetadatasize MetadataVolumeSize[bBsSkKmMgG]]\n"
"\t[-M|--persistent {y|n}] [-j|--major major] [--minor minor]\n"
"\t[--metadataprofile ProfileName]\n"
@@ -339,8 +341,9 @@ xx(lvcreate,
extents_ARG, ignoreactivationskip_ARG, ignoremonitoring_ARG, major_ARG,
metadataprofile_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG, monitor_ARG,
minrecoveryrate_ARG, maxrecoveryrate_ARG, name_ARG, nosync_ARG,
- noudevsync_ARG, permission_ARG, persistent_ARG, poolmetadatasize_ARG,
- poolmetadataspare_ARG, raidminrecoveryrate_ARG, raidmaxrecoveryrate_ARG,
+ noudevsync_ARG, permission_ARG, persistent_ARG,
+ pooldatasize_ARG, poolmetadatasize_ARG, poolmetadataspare_ARG,
+ raidminrecoveryrate_ARG, raidmaxrecoveryrate_ARG,
readahead_ARG, regionsize_ARG, setactivationskip_ARG, size_ARG, snapshot_ARG,
stripes_ARG, stripesize_ARG, test_ARG, thin_ARG, thinpool_ARG, type_ARG,
virtualoriginsize_ARG, virtualsize_ARG, wipesignatures_ARG, zero_ARG)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a6758e953a83aeb…
Commit: 9a6758e953a83aeb1d384df97c6f18b542c569a2
Parent: 37bd12e7ba60e5e6654d7edd912d011328401a21
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 24 13:07:02 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: use matching flags for permissions
Since our status bits are 64b - use uint64_t for permissions.
---
lib/metadata/metadata-exported.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 1af9cbf..cfc0ce2 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -856,7 +856,7 @@ struct lvcreate_params {
uint64_t pool_metadata_size; /* pools */
struct dm_list *pvh; /* all */
- uint32_t permission; /* all */
+ uint64_t permission; /* all */
uint32_t read_ahead; /* all */
int approx_alloc; /* all */
alloc_policy_t alloc; /* all */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=37bd12e7ba60e5e6…
Commit: 37bd12e7ba60e5e6654d7edd912d011328401a21
Parent: 958cae8fd8e03a1b3d060c07d49953bbdc419b9c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 23 12:40:15 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: lv_manip drops duplicated internal error
No reason to check the same condition twice with internal error.
---
lib/metadata/lv_manip.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 54fc6a8..fe0eead 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3717,11 +3717,6 @@ int lv_extend(struct logical_volume *lv,
new_extents -= ah->log_len * ah->area_multiple;
if (segtype_is_thin_pool(segtype) || segtype_is_cache_pool(segtype)) {
- if (lv->le_count) {
- /* lv_resize abstracts properly _tdata */
- log_error(INTERNAL_ERROR "Cannot lv_extend() the existing %s segment.", segtype->name);
- return 0;
- }
if (!(r = create_pool(lv, segtype, ah, stripes, stripe_size)))
stack;
} else if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype)) {
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=958cae8fd8e03a1b…
Commit: 958cae8fd8e03a1b3d060c07d49953bbdc419b9c
Parent: f2ea8904239752df231023a4a3aad704ed8edc73
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 12:03:07 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: use arg_is_set
---
tools/lvcreate.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 8b3255c..7ccd9aa 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -790,13 +790,13 @@ static int _read_activation_params(struct lvcreate_params *lp,
return 0;
}
- if (arg_count(cmd, setactivationskip_ARG)) {
+ if (arg_is_set(cmd, setactivationskip_ARG)) {
lp->activation_skip |= ACTIVATION_SKIP_SET;
if (arg_int_value(cmd, setactivationskip_ARG, 0))
lp->activation_skip |= ACTIVATION_SKIP_SET_ENABLED;
}
- if (arg_count(cmd, ignoreactivationskip_ARG))
+ if (arg_is_set(cmd, ignoreactivationskip_ARG))
lp->activation_skip |= ACTIVATION_SKIP_IGNORE;
if (lp->zero && (lp->activation_skip & ACTIVATION_SKIP_SET_ENABLED)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f2ea8904239752df…
Commit: f2ea8904239752df231023a4a3aad704ed8edc73
Parent: a4788b4994f4cbd5bccd411683704b2badf026d7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 21:49:07 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: don't backup twice
---
lib/metadata/lv_manip.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index df696e9..54fc6a8 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7052,8 +7052,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
stack;
goto revert_new_lv;
}
-
- backup(vg);
+ /* When change is activating, don't duplicate backup call */
+ if (!is_change_activating(lp->activate))
+ backup(vg);
}
if (is_change_activating(lp->activate)) {
/* Send message so that table preload knows new thin */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4788b4994f4cbd5…
Commit: a4788b4994f4cbd5bccd411683704b2badf026d7
Parent: b726003b859a5e2f7580855c10fe201f67e1dc06
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 11:23:33 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: move code for checking vg features
Move code that checks for needed VG features into separate
smaller function.
---
lib/metadata/lv_manip.c | 89 ++++++++++++++++++++++++++---------------------
1 files changed, 49 insertions(+), 40 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 3d6bb26..df696e9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6549,6 +6549,53 @@ static int _should_wipe_lv(struct lvcreate_params *lp,
return 0;
}
+/* Check if VG metadata supports needed features */
+static int _vg_check_features(struct volume_group *vg,
+ struct lvcreate_params *lp)
+{
+ uint32_t features = vg->fid->fmt->features;
+
+ if (vg_max_lv_reached(vg)) {
+ log_error("Maximum number of logical volumes (%u) reached "
+ "in volume group %s", vg->max_lv, vg->name);
+ return 0;
+ }
+
+ if (!(features & FMT_SEGMENTS) &&
+ (seg_is_cache(lp) ||
+ seg_is_cache_pool(lp) ||
+ seg_is_mirrored(lp) ||
+ seg_is_raid(lp) ||
+ seg_is_thin(lp))) {
+ log_error("Metadata does not support %s segments.",
+ lp->segtype->name);
+ return 0;
+ }
+
+ if (!(features & FMT_TAGS) && !dm_list_empty(&lp->tags)) {
+ log_error("Volume group %s does not support tags.", vg->name);
+ return 0;
+ }
+
+ if ((features & FMT_RESTRICTED_READAHEAD) &&
+ lp->read_ahead != DM_READ_AHEAD_AUTO &&
+ lp->read_ahead != DM_READ_AHEAD_NONE &&
+ (lp->read_ahead < 2 || lp->read_ahead > 120)) {
+ log_error("Metadata only supports readahead values between 2 and 120.");
+ return 0;
+ }
+
+ /* Need to check the vg's format to verify this - the cmd format isn't setup properly yet */
+ if (!(features & FMT_UNLIMITED_STRIPESIZE) &&
+ (lp->stripes > 1) && (lp->stripe_size > STRIPE_SIZE_MAX)) {
+ log_error("Stripe size may not exceed %s.",
+ display_size(vg->cmd, (uint64_t) STRIPE_SIZE_MAX));
+ return 0;
+ }
+
+ return 1;
+}
+
/* Thin notes:
* If lp->thin OR lp->activate is AY*, activate the pool if not already active.
* If lp->thin, create thin LV within the pool - as a snapshot if lp->snapshot.
@@ -6573,29 +6620,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (vg_max_lv_reached(vg)) {
- log_error("Maximum number of logical volumes (%u) reached "
- "in volume group %s", vg->max_lv, vg->name);
- return NULL;
- }
-
- if (!(vg->fid->fmt->features & FMT_SEGMENTS) &&
- (segtype_is_mirrored(lp->segtype) ||
- segtype_is_raid(lp->segtype) ||
- segtype_is_thin(lp->segtype) ||
- segtype_is_cache(lp->segtype))) {
- log_error("Metadata does not support %s segments.",
- lp->segtype->name);
- return NULL;
- }
-
- if (lp->read_ahead != DM_READ_AHEAD_AUTO &&
- lp->read_ahead != DM_READ_AHEAD_NONE &&
- (vg->fid->fmt->features & FMT_RESTRICTED_READAHEAD) &&
- (lp->read_ahead < 2 || lp->read_ahead > 120)) {
- log_error("Metadata only supports readahead values between 2 and 120.");
- return NULL;
- }
+ if (!_vg_check_features(vg, lp))
+ return_NULL;
if (!activation()) {
if (seg_is_cache(lp) ||
@@ -6644,15 +6670,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->stripe_size = vg->extent_size;
}
- /* Need to check the vg's format to verify this - the cmd format isn't setup properly yet */
- if (lp->stripes > 1 &&
- !(vg->fid->fmt->features & FMT_UNLIMITED_STRIPESIZE) &&
- (lp->stripe_size > STRIPE_SIZE_MAX)) {
- log_error("Stripe size may not exceed %s",
- display_size(cmd, (uint64_t) STRIPE_SIZE_MAX));
- return NULL;
- }
-
if ((size_rest = lp->extents % lp->stripes)) {
log_print_unless_silent("Rounding size (%d extents) up to stripe boundary "
"size (%d extents).", lp->extents,
@@ -6798,14 +6815,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
!(lp->segtype = get_segtype_from_string(cmd, "striped")))
return_NULL;
- if (!dm_list_empty(&lp->tags)) {
- if (!(vg->fid->fmt->features & FMT_TAGS)) {
- log_error("Volume group %s does not support tags",
- vg->name);
- return NULL;
- }
- }
-
if (!archive(vg))
return_NULL;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b726003b859a5e2f…
Commit: b726003b859a5e2f7580855c10fe201f67e1dc06
Parent: 9e85dbbfd0d965215a9fce55c29cfb967d0d6103
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 24 14:22:13 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: simplier lv name construction
Using NAME_LEN max lv name size.
---
lib/metadata/lv_manip.c | 24 ++++++------------------
1 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 244db1b..3d6bb26 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6053,8 +6053,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
{
static const char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
int r;
- char *name;
- size_t len;
+ char name[NAME_LEN];
struct dm_str_list *sl;
struct logical_volume *layer_lv;
struct segment_type *segtype;
@@ -6063,16 +6062,8 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
unsigned exclusive = 0;
/* create an empty layer LV */
- len = strlen(lv_where->name) + 32;
- if (!(name = alloca(len))) {
- log_error("layer name allocation failed. "
- "Remove new LV and retry.");
- return NULL;
- }
-
- if (dm_snprintf(name, len, "%s%s", lv_where->name, layer_suffix) < 0) {
- log_error("layer name allocation failed. "
- "Remove new LV and retry.");
+ if (dm_snprintf(name, sizeof(name), "%s%s", lv_where->name, layer_suffix) < 0) {
+ log_error("Layered name is too long. Please use shorter LV name.");
return NULL;
}
@@ -6453,8 +6444,7 @@ static struct logical_volume *_create_virtual_origin(struct cmd_context *cmd,
uint64_t voriginextents)
{
const struct segment_type *segtype;
- size_t len;
- char *vorigin_name;
+ char vorigin_name[NAME_LEN];
struct logical_volume *lv;
if (!(segtype = get_segtype_from_string(cmd, "zero"))) {
@@ -6462,10 +6452,8 @@ static struct logical_volume *_create_virtual_origin(struct cmd_context *cmd,
return NULL;
}
- len = strlen(lv_name) + 32;
- if (!(vorigin_name = alloca(len)) ||
- dm_snprintf(vorigin_name, len, "%s_vorigin", lv_name) < 0) {
- log_error("Virtual origin name allocation failed.");
+ if (dm_snprintf(vorigin_name, sizeof(vorigin_name), "%s_vorigin", lv_name) < 0) {
+ log_error("Virtual origin name is too long.");
return NULL;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9e85dbbfd0d96521…
Commit: 9e85dbbfd0d965215a9fce55c29cfb967d0d6103
Parent: cf674142a2c1504d5652a5dd5479041272fd34ec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 19 13:00:48 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: sort args alphabetically
Give it some order for easier human lookup for options we do support.
---
tools/args.h | 179 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 89 insertions(+), 90 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 531148c..492eb28 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -17,109 +17,108 @@
* Put all long args that don't have a corresponding short option first.
*/
/* *INDENT-OFF* */
-arg(version_ARG, '\0', "version", NULL, 0)
-arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
-arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
-arg(nolocking_ARG, '\0', "nolocking", NULL, 0)
-arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0)
-arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0)
-arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_arg, 0)
-arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
-arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0)
-arg(bootloaderareasize_ARG, '\0', "bootloaderareasize", size_mb_arg, 0)
-arg(norestorefile_ARG, '\0', "norestorefile", NULL, 0)
-arg(restorefile_ARG, '\0', "restorefile", string_arg, 0)
-arg(labelsector_ARG, '\0', "labelsector", int_arg, 0)
-arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg, 0)
-arg(aligned_ARG, '\0', "aligned", NULL, 0)
-arg(binary_ARG, '\0', "binary", NULL, 0)
-arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
-arg(noheadings_ARG, '\0', "noheadings", NULL, 0)
-arg(segments_ARG, '\0', "segments", NULL, 0)
-arg(units_ARG, '\0', "units", string_arg, 0)
-arg(nosuffix_ARG, '\0', "nosuffix", NULL, 0)
-arg(removemissing_ARG, '\0', "removemissing", NULL, 0)
-arg(restoremissing_ARG, '\0', "restoremissing", NULL, 0)
arg(abort_ARG, '\0', "abort", NULL, 0)
+arg(activationmode_ARG, '\0', "activationmode", string_arg, 0)
arg(addtag_ARG, '\0', "addtag", tag_arg, ARG_GROUPABLE)
-arg(deltag_ARG, '\0', "deltag", tag_arg, ARG_GROUPABLE)
-arg(refresh_ARG, '\0', "refresh", NULL, 0)
-arg(mknodes_ARG, '\0', "mknodes", NULL, 0)
-arg(minor_ARG, '\0', "minor", int_arg, ARG_GROUPABLE)
-arg(type_ARG, '\0', "type", segtype_arg, 0)
+arg(aligned_ARG, '\0', "aligned", NULL, 0)
arg(alloc_ARG, '\0', "alloc", alloc_arg, 0)
-arg(separator_ARG, '\0', "separator", string_arg, 0)
-arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL, 0)
-arg(nosync_ARG, '\0', "nosync", NULL, 0)
-arg(resync_ARG, '\0', "resync", NULL, 0)
-arg(corelog_ARG, '\0', "corelog", NULL, 0)
-arg(mirrorlog_ARG, '\0', "mirrorlog", string_arg, 0)
-arg(splitmirrors_ARG, '\0', "splitmirrors", int_arg, 0)
-arg(trackchanges_ARG, '\0', "trackchanges", NULL, 0)
-arg(replace_ARG, '\0', "replace", string_arg, ARG_GROUPABLE)
-arg(repair_ARG, '\0', "repair", NULL, 0)
-arg(use_policies_ARG, '\0', "use-policies", NULL, 0)
-arg(merge_ARG, '\0', "merge", NULL, 0)
-arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0)
-arg(config_ARG, '\0', "config", string_arg, 0)
-arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
+arg(atomic_ARG, '\0', "atomic", NULL, 0)
+arg(atversion_ARG, '\0', "atversion", string_arg, 0)
+arg(binary_ARG, '\0', "binary", NULL, 0)
+arg(bootloaderareasize_ARG, '\0', "bootloaderareasize", size_mb_arg, 0)
arg(cache_long_ARG, '\0', "cache", NULL, 0)
arg(cachemode_ARG, '\0', "cachemode", string_arg, 0)
arg(cachepool_ARG, '\0', "cachepool", string_arg, 0)
-arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0)
-arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0)
-arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
-arg(rows_ARG, '\0', "rows", NULL, 0)
+arg(commandprofile_ARG, '\0', "commandprofile", string_arg, 0)
+arg(config_ARG, '\0', "config", string_arg, 0)
+arg(configtype_ARG, '\0', "type", string_arg, 0)
+arg(corelog_ARG, '\0', "corelog", NULL, 0)
arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0)
arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", size_kb_arg, 0)
-arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
+arg(deltag_ARG, '\0', "deltag", tag_arg, ARG_GROUPABLE)
+arg(detachprofile_ARG, '\0', "detachprofile", NULL, 0)
+arg(discards_ARG, '\0', "discards", discards_arg, 0)
+arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg, 0)
+arg(force_long_ARG, '\0', "force", NULL, ARG_COUNTABLE)
+arg(ignoreadvanced_ARG, '\0', "ignoreadvanced", NULL, 0)
+arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
+arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0)
+arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0)
+arg(ignoreunsupported_ARG, '\0', "ignoreunsupported", NULL, 0)
+arg(labelsector_ARG, '\0', "labelsector", int_arg, 0)
+arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", size_kb_arg, 0)
+arg(merge_ARG, '\0', "merge", NULL, 0)
+arg(mergedconfig_ARG, '\0', "mergedconfig", NULL, 0)
+arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_arg, 0)
+arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0)
+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(mirrorsonly_ARG, '\0', "mirrorsonly", NULL, 0)
+arg(mknodes_ARG, '\0', "mknodes", NULL, 0)
+arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0)
+arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0)
+arg(noheadings_ARG, '\0', "noheadings", NULL, 0)
+arg(nolocking_ARG, '\0', "nolocking", NULL, 0)
+arg(norestorefile_ARG, '\0', "norestorefile", NULL, 0)
+arg(nosuffix_ARG, '\0', "nosuffix", NULL, 0)
+arg(nosync_ARG, '\0', "nosync", NULL, 0)
arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0)
arg(originname_ARG, '\0', "originname", string_arg, 0)
+arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
arg(poll_ARG, '\0', "poll", yes_no_arg, 0)
arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0)
arg(poolmetadataspare_ARG, '\0', "poolmetadataspare", yes_no_arg, 0)
-arg(discards_ARG, '\0', "discards", discards_arg, 0)
-arg(force_long_ARG, '\0', "force", NULL, ARG_COUNTABLE)
+arg(profile_ARG, '\0', "profile", string_arg, 0)
+arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0)
+arg(raidmaxrecoveryrate_ARG, '\0', "raidmaxrecoveryrate", size_kb_arg, 0)
+arg(raidminrecoveryrate_ARG, '\0', "raidminrecoveryrate", size_kb_arg, 0)
+arg(raidsyncaction_ARG, '\0', "raidsyncaction", string_arg, 0)
+arg(raidwritebehind_ARG, '\0', "raidwritebehind", int_arg, 0)
+arg(raidwritemostly_ARG, '\0', "raidwritemostly", string_arg, ARG_GROUPABLE)
+arg(readonly_ARG, '\0', "readonly", NULL, 0)
+arg(refresh_ARG, '\0', "refresh", NULL, 0)
+arg(removemissing_ARG, '\0', "removemissing", NULL, 0)
+arg(repair_ARG, '\0', "repair", NULL, 0)
+arg(replace_ARG, '\0', "replace", string_arg, ARG_GROUPABLE)
+arg(restorefile_ARG, '\0', "restorefile", string_arg, 0)
+arg(restoremissing_ARG, '\0', "restoremissing", NULL, 0)
+arg(resync_ARG, '\0', "resync", NULL, 0)
+arg(rows_ARG, '\0', "rows", NULL, 0)
+arg(segments_ARG, '\0', "segments", NULL, 0)
+arg(separator_ARG, '\0', "separator", string_arg, 0)
+arg(split_ARG, '\0', "split", NULL, 0)
+arg(splitcache_ARG, '\0', "splitcache", NULL, 0)
+arg(splitmirrors_ARG, '\0', "splitmirrors", int_arg, 0)
+arg(splitsnapshot_ARG, '\0', "splitsnapshot", NULL, 0)
arg(stripes_long_ARG, '\0', "stripes", int_arg, 0)
+arg(syncaction_ARG, '\0', "syncaction", string_arg, 0) /* FIXME Use custom validation fn */
arg(sysinit_ARG, '\0', "sysinit", NULL, 0)
arg(thinpool_ARG, '\0', "thinpool", string_arg, 0)
-arg(configtype_ARG, '\0', "type", string_arg, 0)
+arg(trackchanges_ARG, '\0', "trackchanges", NULL, 0)
+arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
+arg(type_ARG, '\0', "type", segtype_arg, 0)
+arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
+arg(uncache_ARG, '\0', "uncache", NULL, 0)
+arg(units_ARG, '\0', "units", string_arg, 0)
+arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
+arg(use_policies_ARG, '\0', "use-policies", NULL, 0)
+arg(validate_ARG, '\0', "validate", NULL, 0)
+arg(version_ARG, '\0', "version", NULL, 0)
+arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0)
+arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
arg(withcomments_ARG, '\0', "withcomments", NULL, 0)
arg(withversions_ARG, '\0', "withversions", NULL, 0)
-arg(ignoreadvanced_ARG, '\0', "ignoreadvanced", NULL, 0)
-arg(ignoreunsupported_ARG, '\0', "ignoreunsupported", NULL, 0)
-arg(atversion_ARG, '\0', "atversion", string_arg, 0)
-arg(validate_ARG, '\0', "validate", NULL, 0)
-arg(syncaction_ARG, '\0', "syncaction", string_arg, 0) /* FIXME Use custom validation fn */
-arg(raidsyncaction_ARG, '\0', "raidsyncaction", string_arg, 0)
-arg(writemostly_ARG, '\0', "writemostly", string_arg, ARG_GROUPABLE)
-arg(raidwritemostly_ARG, '\0', "raidwritemostly", string_arg, ARG_GROUPABLE)
arg(writebehind_ARG, '\0', "writebehind", int_arg, 0)
-arg(raidwritebehind_ARG, '\0', "raidwritebehind", int_arg, 0)
-arg(minrecoveryrate_ARG, '\0', "minrecoveryrate", size_kb_arg, 0)
-arg(raidminrecoveryrate_ARG, '\0', "raidminrecoveryrate", size_kb_arg, 0)
-arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", size_kb_arg, 0)
-arg(raidmaxrecoveryrate_ARG, '\0', "raidmaxrecoveryrate", size_kb_arg, 0)
-arg(commandprofile_ARG, '\0', "commandprofile", string_arg, 0)
-arg(metadataprofile_ARG, '\0', "metadataprofile", string_arg, 0)
-arg(profile_ARG, '\0', "profile", string_arg, 0)
-arg(detachprofile_ARG, '\0', "detachprofile", NULL, 0)
-arg(mergedconfig_ARG, '\0', "mergedconfig", NULL, 0)
-arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0)
-arg(splitsnapshot_ARG, '\0', "splitsnapshot", NULL, 0)
-arg(splitcache_ARG, '\0', "splitcache", NULL, 0)
-arg(uncache_ARG, '\0', "uncache", NULL, 0)
-arg(split_ARG, '\0', "split", NULL, 0)
-arg(readonly_ARG, '\0', "readonly", NULL, 0)
-arg(atomic_ARG, '\0', "atomic", NULL, 0)
-arg(activationmode_ARG, '\0', "activationmode", string_arg, 0)
-
+arg(writemostly_ARG, '\0', "writemostly", string_arg, ARG_GROUPABLE)
/* Allow some variations */
-arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
arg(allocation_ARG, '\0', "allocation", yes_no_arg, 0)
arg(available_ARG, '\0', "available", activation_arg, 0)
+arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
/*
* ... and now the short args.
@@ -145,32 +144,32 @@ arg(full_ARG, 'f', "full", NULL, 0)
arg(help_ARG, 'h', "help", NULL, 0)
arg(cache_ARG, 'H', "cache", NULL, 0)
arg(help2_ARG, '?', "", NULL, 0)
-arg(stripesize_ARG, 'I', "stripesize", size_kb_arg, 0)
-arg(stripes_ARG, 'i', "stripes", int_arg, 0)
arg(interval_ARG, 'i', "interval", int_arg, 0)
arg(iop_version_ARG, 'i', "iop_version", NULL, 0)
+arg(stripes_ARG, 'i', "stripes", int_arg, 0)
+arg(stripesize_ARG, 'I', "stripesize", size_kb_arg, 0)
arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg, 0)
arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg, 0)
arg(extents_ARG, 'l', "extents", int_arg_with_sign_and_percent, 0)
-arg(lvmpartition_ARG, 'l', "lvmpartition", NULL, 0)
arg(list_ARG, 'l', "list", NULL, 0)
-arg(size_ARG, 'L', "size", size_mb_arg, 0)
+arg(lvmpartition_ARG, 'l', "lvmpartition", NULL, 0)
arg(logicalextent_ARG, 'L', "logicalextent", int_arg_with_sign, 0)
+arg(size_ARG, 'L', "size", size_mb_arg, 0)
arg(persistent_ARG, 'M', "persistent", yes_no_arg, 0)
arg(major_ARG, 'j', "major", int_arg, ARG_GROUPABLE)
arg(setactivationskip_ARG, 'k', "setactivationskip", yes_no_arg, 0)
arg(ignoreactivationskip_ARG, 'K', "ignoreactivationskip", NULL, 0)
+arg(maps_ARG, 'm', "maps", NULL, 0)
arg(mirrors_ARG, 'm', "mirrors", int_arg_with_sign, 0)
arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_arg, 0)
-arg(maps_ARG, 'm', "maps", NULL, 0)
arg(name_ARG, 'n', "name", string_arg, 0)
-arg(oldpath_ARG, 'n', "oldpath", NULL, 0)
arg(nofsck_ARG, 'n', "nofsck", NULL, 0)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL, 0)
+arg(oldpath_ARG, 'n', "oldpath", NULL, 0)
arg(options_ARG, 'o', "options", string_arg, 0)
arg(sort_ARG, 'O', "sort", string_arg, 0)
-arg(permission_ARG, 'p', "permission", permission_arg, 0)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg, 0)
+arg(permission_ARG, 'p', "permission", permission_arg, 0)
arg(partial_ARG, 'P', "partial", NULL, 0)
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL, 0)
arg(quiet_ARG, 'q', "quiet", NULL, ARG_COUNTABLE)
@@ -179,12 +178,12 @@ arg(resizefs_ARG, 'r', "resizefs", NULL, 0)
arg(reset_ARG, 'R', "reset", NULL, 0)
arg(regionsize_ARG, 'R', "regionsize", size_mb_arg, 0)
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg, 0)
-arg(stdin_ARG, 's', "stdin", NULL, 0)
arg(snapshot_ARG, 's', "snapshot", NULL, 0)
arg(short_ARG, 's', "short", NULL, 0)
+arg(stdin_ARG, 's', "stdin", NULL, 0)
arg(select_ARG, 'S', "select", string_arg, 0)
-arg(thin_ARG, 'T', "thin", NULL, 0)
arg(test_ARG, 't', "test", NULL, 0)
+arg(thin_ARG, 'T', "thin", NULL, 0)
arg(uuid_ARG, 'u', "uuid", NULL, 0)
arg(uuidstr_ARG, 'u', "uuid", string_arg, 0)
arg(uuidlist_ARG, 'U', "uuidlist", NULL, 0)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cf674142a2c1504d…
Commit: cf674142a2c1504d5652a5dd5479041272fd34ec
Parent: 4f8ed25a999821cd37cc1e2c0051e60e8a63e371
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 18 11:01:34 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: move code
---
lib/metadata/lv_manip.c | 10 ++++------
tools/lvcreate.c | 5 ++---
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ec09b41..244db1b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6573,7 +6573,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
{
struct cmd_context *cmd = vg->cmd;
uint32_t size_rest;
- uint64_t status = UINT64_C(0);
+ uint64_t status = lp->permission | VISIBLE_LV;
struct logical_volume *lv, *origin_lv = NULL;
struct logical_volume *pool_lv;
struct logical_volume *tmp_lv;
@@ -6672,8 +6672,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->extents = lp->extents - size_rest + lp->stripes;
}
- status |= lp->permission | VISIBLE_LV;
-
if (seg_is_cache(lp)) {
if (!lp->pool_name) {
log_error(INTERNAL_ERROR "Cannot create thin volume without thin pool.");
@@ -6900,6 +6898,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->passed_args,
THIN_CHUNK_SIZE_CALC_METHOD_GENERIC))
return_NULL;
+ } else if (seg_is_raid(lp)) {
+ first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
+ first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
} else if (seg_is_thin_pool(lp)) {
first_seg(lv)->chunk_size = lp->chunk_size;
first_seg(lv)->zero_new_blocks = lp->zero ? 1 : 0;
@@ -6936,9 +6937,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!attach_pool_message(first_seg(pool_lv),
DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
return_NULL;
- } else if (seg_is_raid(lp)) {
- first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
- first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
}
/* FIXME Log allocation and attachment should have happened inside lv_extend. */
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 7573a2e..8b3255c 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -806,9 +806,6 @@ static int _read_activation_params(struct lvcreate_params *lp,
return 0;
}
- lp->yes = arg_count(cmd, yes_ARG);
- lp->force = (force_t) arg_count(cmd, force_ARG);
-
return 1;
}
@@ -825,6 +822,8 @@ static int _lvcreate_params(struct lvcreate_params *lp,
memset(lcp, 0, sizeof(*lcp));
dm_list_init(&lp->tags);
lp->target_attr = ~0;
+ lp->yes = arg_count(cmd, yes_ARG);
+ lp->force = (force_t) arg_count(cmd, force_ARG);
/* Set default segtype - remember, '-m 0' implies stripe. */
if (arg_count(cmd, mirrors_ARG) &&
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4f8ed25a999821cd…
Commit: 4f8ed25a999821cd37cc1e2c0051e60e8a63e371
Parent: c6456bd6390f6d99dd975f671c5730b0438c4c89
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 18 11:01:29 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: indent
Various indents and tiny error message improvements.
---
lib/metadata/lv_manip.c | 45 ++++++++++++++++---------------------
lib/metadata/metadata-exported.h | 4 +-
lib/metadata/pool_manip.c | 2 +-
tools/lvcreate.c | 30 +++++++++----------------
4 files changed, 34 insertions(+), 47 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6240f14..ec09b41 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6032,7 +6032,8 @@ int remove_layer_from_lv(struct logical_volume *lv,
return_0;
/* Replace the empty layer with error segment */
- segtype = get_segtype_from_string(lv->vg->cmd, "error");
+ if (!(segtype = get_segtype_from_string(lv->vg->cmd, "error")))
+ return_0;
if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype, NULL))
return_0;
@@ -6050,7 +6051,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
uint64_t status,
const char *layer_suffix)
{
- static char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
+ static const char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
int r;
char *name;
size_t len;
@@ -6129,7 +6130,6 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
/* Remove the temporary tags */
dm_list_iterate_items(sl, &lv_where->tags)
str_list_del(&layer_lv->tags, sl->str);
-
}
log_very_verbose("Inserting layer %s for %s",
@@ -6166,7 +6166,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
lv_names.old = lv_where->name;
lv_names.new = layer_lv->name;
if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
- return 0;
+ return_NULL;
break;
}
@@ -6635,8 +6635,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (lp->stripe_size > vg->extent_size) {
- if (segtype_is_raid(lp->segtype) &&
- (vg->extent_size < STRIPE_SIZE_MIN)) {
+ if (seg_is_raid(lp) && (vg->extent_size < STRIPE_SIZE_MIN)) {
/*
* FIXME: RAID will simply fail to load the table if
* this is the case, but we should probably
@@ -6677,13 +6676,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (seg_is_cache(lp)) {
if (!lp->pool_name) {
- log_error(INTERNAL_ERROR "Cannot create cached volume without cache pool.");
- return NULL;
+ log_error(INTERNAL_ERROR "Cannot create thin volume without thin pool.");
+ return NULL;
}
- /* We have the cache_pool, create the origin with cache */
if (!(pool_lv = find_lv(vg, lp->pool_name))) {
- log_error("Couldn't find cache pool volume %s in "
- "volume group %s.", lp->pool_name, vg->name);
+ log_error("Couldn't find volume %s in Volume group %s.",
+ lp->pool_name, vg->name);
return NULL;
}
@@ -6744,8 +6742,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
if (lv_is_locked(origin_lv)) {
- log_error("Snapshots of locked devices are not "
- "supported yet");
+ log_error("Snapshots of locked devices are not supported.");
return NULL;
}
if (lv_is_merging_origin(origin_lv)) {
@@ -6871,16 +6868,16 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
if (lp->read_ahead != lv->read_ahead) {
- log_verbose("Setting read ahead sectors");
lv->read_ahead = lp->read_ahead;
+ log_debug_metadata("Setting read ahead sectors %u.", lv->read_ahead);
}
if (!seg_is_thin_pool(lp) && lp->minor >= 0) {
lv->major = lp->major;
lv->minor = lp->minor;
lv->status |= FIXED_MINOR;
- log_verbose("Setting device number to (%d, %d)", lv->major,
- lv->minor);
+ log_debug_metadata("Setting device number to (%d, %d).",
+ lv->major, lv->minor);
}
dm_list_splice(&lv->tags, &lp->tags);
@@ -6963,8 +6960,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* it just as if CHANGE_AY was used, CHANGE_AN otherwise.
*/
if (lp->activate == CHANGE_AAY)
- lp->activate = lv_passes_auto_activation_filter(cmd, lv) ?
- CHANGE_ALY : CHANGE_ALN;
+ lp->activate = lv_passes_auto_activation_filter(cmd, lv)
+ ? CHANGE_ALY : CHANGE_ALN;
if (lv_activation_skip(lv, lp->activate, lp->activation_skip & ACTIVATION_SKIP_IGNORE))
lp->activate = CHANGE_AN;
@@ -7100,9 +7097,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
.yes = lp->yes,
.force = lp->force
})) {
- log_error("Aborting. Failed to wipe %s.",
- lp->snapshot ? "snapshot exception store" :
- "start of new LV");
+ log_error("Aborting. Failed to wipe %s.", lp->snapshot
+ ? "snapshot exception store" : "start of new LV");
goto deactivate_and_revert_new_lv;
}
}
@@ -7120,8 +7116,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if ((vg_is_clustered(vg) ||
(!lp->voriginsize && !lv_is_active(origin_lv))) &&
!deactivate_lv(cmd, lv)) {
- log_error("Aborting. Couldn't deactivate snapshot "
- "COW area. Manual intervention required.");
+ log_error("Aborting. Couldn't deactivate snapshot COW area. "
+ "Manual intervention required.");
return NULL;
}
@@ -7150,9 +7146,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* store vg on disk(s) */
if (!lv_update_and_reload(origin_lv))
- return_0;
+ return_NULL;
}
-
out:
return lv;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index bf6f1c1..1af9cbf 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -783,7 +783,7 @@ int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
typedef enum activation_change {
CHANGE_AY = 0, /* activate */
CHANGE_AN = 1, /* deactivate */
- CHANGE_AEY = 2, /* activate exclusively */
+ CHANGE_AEY = 2, /* activate exclusively */
CHANGE_ALY = 3, /* activate locally */
CHANGE_ALN = 4, /* deactivate locally */
CHANGE_AAY = 5 /* automatic activation */
@@ -801,7 +801,7 @@ struct lvcreate_params {
int cache;
int snapshot; /* snap */
int thin; /* thin */
- int create_pool; /* thin */
+ int create_pool; /* pools */
int zero; /* all */
int wipe_signatures; /* all */
int32_t major; /* all */
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 2fbadea..02a82bd 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -433,7 +433,7 @@ int create_pool(struct logical_volume *pool_lv,
*/
pool_lv->status |= LV_TEMPORARY;
if (!activate_lv_local(pool_lv->vg->cmd, pool_lv) ||
- /* Clear 4KB of metadata device for new thin-pool. */
+ /* Clear 4KB of pool metadata device. */
!wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe pool metadata %s.",
pool_lv->name);
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 5a91627..7573a2e 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -390,8 +390,8 @@ static int _update_extents_params(struct volume_group *vg,
extents = percent_of_extents(lp->extents, vg->extent_count, 0);
break;
case PERCENT_LV:
- log_error("Please express size as %s%%VG, %%PVS, "
- "or %%FREE.", (lp->snapshot) ? "%ORIGIN, " : "");
+ log_error("Please express size as %%FREE%s, %%PVS or %%VG.",
+ (lp->snapshot) ? ", %ORIGIN" : "");
return 0;
case PERCENT_ORIGIN:
if (lp->snapshot && lp->origin_name &&
@@ -667,8 +667,7 @@ static int _read_raid_params(struct lvcreate_params *lp,
/*
* RAID1 does not take a stripe arg
*/
- if ((lp->stripes > 1) &&
- segtype_is_mirrored(lp->segtype) &&
+ if ((lp->stripes > 1) && seg_is_mirrored(lp) &&
strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
log_error("Stripe argument cannot be used with segment type, %s",
lp->segtype->name);
@@ -713,11 +712,10 @@ static int _read_cache_pool_params(struct lvcreate_params *lp,
{
const char *cachemode;
- if (!segtype_is_cache_pool(lp->segtype))
+ if (!seg_is_cache(lp) && !seg_is_cache_pool(lp))
return 1;
- cachemode = arg_str_value(cmd, cachemode_ARG, NULL);
- if (!cachemode)
+ if (!(cachemode = arg_str_value(cmd, cachemode_ARG, NULL)))
cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
if (!get_cache_mode(cachemode, &lp->feature_flags))
@@ -748,9 +746,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
lp->zero = 0;
}
- /*
- * Read ahead.
- */
+ /* Read ahead */
lp->read_ahead = arg_uint_value(cmd, readahead_ARG,
cmd->default_settings.read_ahead);
pagesize = lvm_getpagesize() >> SECTOR_SHIFT;
@@ -765,9 +761,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
"of %uK page size.", lp->read_ahead, pagesize >> 1);
}
- /*
- * Permissions.
- */
+ /* Permissions */
lp->permission = arg_uint_value(cmd, permission_ARG,
LVM_READ | LVM_WRITE);
@@ -790,7 +784,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
if (!get_and_validate_major_minor(cmd, vg->fid->fmt,
&lp->major, &lp->minor))
- return_0;
+ return_0;
} else if (arg_is_set(cmd, major_ARG) || arg_is_set(cmd, minor_ARG)) {
log_error("--major and --minor require -My.");
return 0;
@@ -1048,13 +1042,11 @@ static int _lvcreate_params(struct lvcreate_params *lp,
* Allocation parameters
*/
contiguous = arg_int_value(cmd, contiguous_ARG, 0);
-
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
-
lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lp->alloc);
if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) {
- log_error("Conflicting contiguous and alloc arguments");
+ log_error("Conflicting contiguous and alloc arguments.");
return 0;
}
@@ -1063,12 +1055,12 @@ static int _lvcreate_params(struct lvcreate_params *lp,
continue;
if (!(tag = grouped_arg_str_value(current_group->arg_values, addtag_ARG, NULL))) {
- log_error("Failed to get tag");
+ log_error("Failed to get tag.");
return 0;
}
if (!str_list_add(cmd->mem, &lp->tags, tag)) {
- log_error("Unable to allocate memory for tag %s", tag);
+ log_error("Unable to allocate memory for tag %s.", tag);
return 0;
}
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c6456bd6390f6d99…
Commit: c6456bd6390f6d99dd975f671c5730b0438c4c89
Parent: df933c2ac92203c7352be2e7062ca8c01777cb51
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 22:43:42 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: commands.h update descriptions
---
tools/commands.h | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 524297d..eb0d248 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -121,7 +121,7 @@ xx(lvchange,
"\t[--monitor {y|n}]\n"
"\t[--poll {y|n}]\n"
"\t[--noudevsync]\n"
- "\t[-M|--persistent y|n] [--major major] [--minor minor]\n"
+ "\t[-M|--persistent y|n] [-j|--major major] [--minor minor]\n"
"\t[--metadataprofile ProfileName]\n"
"\t[-P|--partial]\n"
"\t[-p|--permission r|rw]\n"
@@ -221,25 +221,25 @@ xx(lvconvert,
"\t[--chunksize size]\n"
"\t[--discards {ignore|nopassdown|passdown}]\n"
"\t[--poolmetadataspare {y|n}]\n"
- "\t[--poolmetadata ThinMetadataLogicalVolume[Path] |\n"
- "\t [--poolmetadatasize size]\n"
- "\t [-r|--readahead ReadAheadSectors|auto|none]\n"
- "\t [--stripes Stripes [-I|--stripesize StripeSize]]]\n"
+ "\t[{--poolmetadata ThinMetadataLogicalVolume[Path] |\n"
+ "\t --poolmetadatasize size}]\n"
+ "\t[-r|--readahead ReadAheadSectors|auto|none]\n"
+ "\t[--stripes Stripes [-I|--stripesize StripeSize]]]\n"
"\t[--originname NewExternalOriginVolumeName]]\n"
"\t[-Z|--zero {y|n}]\n"
COMMON_OPTS
- "\t[ExternalOrigin|ThinDataPool]LogicalVolume[Path]\n\n"
+ "\t[ExternalOrigin|ThinDataPool]LogicalVolume[Path] [PhysicalVolumePath...]\n\n"
"lvconvert "
- "[--type cache[-pool]|--cache]\n"
+ "[--type cache[-pool]|-H|--cache]\n"
"\t[--cachepool CacheDataLogicalVolume[Path]]\n"
"\t[--cachemode CacheMode]\n"
"\t[--chunksize size]\n"
"\t[--poolmetadataspare {y|n}]]\n"
- "\t[--poolmetadata CacheMetadataLogicalVolume[Path] |\n"
- "\t [--poolmetadatasize size]\n"
+ "\t[{--poolmetadata CacheMetadataLogicalVolume[Path] |\n"
+ "\t --poolmetadatasize size}]\n"
COMMON_OPTS
- "\t[Cache|CacheDataPool]LogicalVolume[Path]\n\n",
+ "\t[Cache|CacheDataPool]LogicalVolume[Path] [PhysicalVolumePath...]\n\n",
alloc_ARG, background_ARG, cache_ARG, cachemode_ARG, cachepool_ARG, chunksize_ARG,
corelog_ARG, discards_ARG, force_ARG, interval_ARG, merge_ARG, mirrorlog_ARG,
@@ -273,9 +273,10 @@ xx(lvcreate,
"\t[-K|--ignoreactivationskip]\n"
"\t{-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |\n"
"\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
- "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n"
+ "\t[-M|--persistent {y|n}] [-j|--major major] [--minor minor]\n"
"\t[--metadataprofile ProfileName]\n"
- "\t[-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core|mirrored}|--corelog}]]\n"
+ "\t[-m|--mirrors Mirrors [--nosync]\n"
+ "\t [{--mirrorlog {disk|core|mirrored}|--corelog}]]\n"
"\t[-n|--name LogicalVolumeName]\n"
"\t[--noudevsync]\n"
"\t[-p|--permission {r|rw}]\n"
@@ -283,7 +284,7 @@ xx(lvcreate,
"\t[--poolmetadataspare {y|n}]]\n"
"\t[--[raid]minrecoveryrate Rate]\n"
"\t[--[raid]maxrecoveryrate Rate]\n"
- "\t[-r|--readahead ReadAheadSectors|auto|none]\n"
+ "\t[-r|--readahead {ReadAheadSectors|auto|none}]\n"
"\t[-R|--regionsize MirrorLogRegionSize]\n"
"\t[-T|--thin\n"
"\t [--discards {ignore|nopassdown|passdown}]\n"
@@ -319,7 +320,7 @@ xx(lvcreate,
"\t{-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |\n"
"\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
"\t[--poolmetadatasize MetadataVolumeSize[bBsSkKmMgG]]\n"
- "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n"
+ "\t[-M|--persistent {y|n}] [-j|--major major] [--minor minor]\n"
"\t[--metadataprofile ProfileName]\n"
"\t[-n|--name LogicalVolumeName]\n"
"\t[--noudevsync]\n"
@@ -848,7 +849,7 @@ xx(pvscan,
PERMITTED_READ_ONLY,
"pvscan\n"
"\t[-b|--background]\n"
- "\t[--cache [-a|--activate ay] [ DevicePath | --major major --minor minor]...]\n"
+ "\t[--cache [-a|--activate ay] [ DevicePath | -j|--major major --minor minor]...]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t{-e|--exported | -n|--novolumegroup}\n"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=df933c2ac92203c7…
Commit: df933c2ac92203c7352be2e7062ca8c01777cb51
Parent: f1cb267274916fcd63456a859ff433bdceefef07
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 18 10:58:23 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: commands.h shorted string
Replace " "\n" with simplier \n"
---
tools/commands.h | 498 +++++++++++++++++++++++++++---------------------------
1 files changed, 249 insertions(+), 249 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 2e99fb1..524297d 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -17,13 +17,13 @@
xx(e2fsadm,
"Resize logical volume and ext2 filesystem",
"e2fsadm "
- "[-d|--debug] " "[-h|--help] " "[-n|--nofsck]" "\n"
- "\t{[-l|--extents] [+|-]LogicalExtentsNumber |" "\n"
- "\t [-L|--size] [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}" "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version] " "\n"
- "\tLogicalVolumePath" "\n",
+ "[-d|--debug] " "[-h|--help] " "[-n|--nofsck]\n"
+ "\t{[-l|--extents] [+|-]LogicalExtentsNumber |\n"
+ "\t [-L|--size] [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\tLogicalVolumePath\n",
extents_ARG, size_ARG, nofsck_ARG, test_ARG)
*********/
@@ -31,7 +31,7 @@ xx(e2fsadm,
xx(devtypes,
"Display recognised built-in block device types",
PERMITTED_READ_ONLY,
- "devtypes" "\n"
+ "devtypes\n"
"\t[--aligned]\n"
"\t[--binary]\n"
"\t[--commandprofile ProfileName]\n"
@@ -47,7 +47,7 @@ xx(devtypes,
"\t[--separator Separator]\n"
"\t[--unbuffered]\n"
"\t[--unquoted]\n"
- "\t[--version]" "\n",
+ "\t[--version]\n",
aligned_ARG, binary_ARG, nameprefixes_ARG,
noheadings_ARG, nosuffix_ARG, options_ARG,
@@ -58,19 +58,19 @@ xx(dumpconfig,
"Dump configuration",
PERMITTED_READ_ONLY,
"dumpconfig\n"
- "\t[-f|--file filename] \n"
- "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata} \n"
- "\t[--atversion version]] \n"
- "\t[--ignoreadvanced] \n"
- "\t[--ignoreunsupported] \n"
- "\t[--config ConfigurationString] \n"
- "\t[--commandprofile ProfileName] \n"
- "\t[--profile ProfileName] \n"
- "\t[--metadataprofile ProfileName] \n"
- "\t[--mergedconfig] \n"
+ "\t[-f|--file filename]\n"
+ "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata}\n"
+ "\t[--atversion version]]\n"
+ "\t[--ignoreadvanced]\n"
+ "\t[--ignoreunsupported]\n"
+ "\t[--config ConfigurationString]\n"
+ "\t[--commandprofile ProfileName]\n"
+ "\t[--profile ProfileName]\n"
+ "\t[--metadataprofile ProfileName]\n"
+ "\t[--mergedconfig]\n"
"\t[--validate]\n"
- "\t[--withcomments] \n"
- "\t[--withversions] \n"
+ "\t[--withcomments]\n"
+ "\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
ignoreunsupported_ARG, mergedconfig_ARG, metadataprofile_ARG,
@@ -84,7 +84,7 @@ xx(formats,
xx(help,
"Display help for commands",
PERMITTED_READ_ONLY,
- "help <command>" "\n")
+ "help <command>\n")
/*********
xx(lvactivate,
@@ -117,13 +117,13 @@ xx(lvchange,
"\t[--ignoremonitoring]\n"
"\t[--ignoreskippedcluster]\n"
"\t[-k|--setactivationskip {y|n}]\n"
- "\t[-K|--ignoreactivationskip] \n"
+ "\t[-K|--ignoreactivationskip]\n"
"\t[--monitor {y|n}]\n"
"\t[--poll {y|n}]\n"
"\t[--noudevsync]\n"
"\t[-M|--persistent y|n] [--major major] [--minor minor]\n"
"\t[--metadataprofile ProfileName]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[-p|--permission r|rw]\n"
"\t[--[raid]minrecoveryrate Rate]\n"
"\t[--[raid]maxrecoveryrate Rate]\n"
@@ -253,15 +253,15 @@ xx(lvconvert,
xx(lvcreate,
"Create a logical volume",
0,
- "lvcreate " "\n"
+ "lvcreate\n"
"\t[-A|--autobackup {y|n}]\n"
"\t[-a|--activate [a|e|l]{y|n}]\n"
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-H|--cache\n"
- "\t [-c|--chunksize ChunkSize]\n"
"\t [--cachemode {writeback|writethrough}]\n"
"\t[--cachepool CachePoolLogicalVolume{Name|Path}]\n"
+ "\t[-c|--chunksize ChunkSize]\n"
"\t[-C|--contiguous {y|n}]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
@@ -270,7 +270,7 @@ xx(lvcreate,
"\t[--monitor {y|n}]\n"
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
"\t[-k|--setactivationskip {y|n}]\n"
- "\t[-K|--ignoreactivationskip] \n"
+ "\t[-K|--ignoreactivationskip]\n"
"\t{-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |\n"
"\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
"\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n"
@@ -279,15 +279,14 @@ xx(lvcreate,
"\t[-n|--name LogicalVolumeName]\n"
"\t[--noudevsync]\n"
"\t[-p|--permission {r|rw}]\n"
+ "\t[--poolmetadatasize MetadataSize[bBsSkKmMgG]]\n"
+ "\t[--poolmetadataspare {y|n}]]\n"
"\t[--[raid]minrecoveryrate Rate]\n"
"\t[--[raid]maxrecoveryrate Rate]\n"
"\t[-r|--readahead ReadAheadSectors|auto|none]\n"
"\t[-R|--regionsize MirrorLogRegionSize]\n"
"\t[-T|--thin\n"
- "\t [-c|--chunksize ChunkSize]\n"
"\t [--discards {ignore|nopassdown|passdown}]\n"
- "\t [--poolmetadatasize MetadataSize[bBsSkKmMgG]]\n"
- "\t [--poolmetadataspare {y|n}]]\n"
"\t[--thinpool ThinPoolLogicalVolume{Name|Path}]\n"
"\t[-t|--test]\n"
"\t[--type VolumeType]\n"
@@ -297,15 +296,16 @@ xx(lvcreate,
"\t[--version]\n"
"\tVolumeGroupName [PhysicalVolumePath...]\n\n"
- "lvcreate \n"
+ "lvcreate\n"
"\t{ {-s|--snapshot} OriginalLogicalVolume[Path] |\n"
"\t [-s|--snapshot] VolumeGroupName[Path] -V|--virtualsize VirtualSize}\n"
- "\t {-T|--thin} VolumeGroupName[Path][/PoolLogicalVolume] \n"
+ "\t {-H|--cache} VolumeGroupName[Path][/OriginalLogicalVolume]\n"
+ "\t {-T|--thin} VolumeGroupName[Path][/PoolLogicalVolume]\n"
"\t -V|--virtualsize VirtualSize}\n"
- "\t[-c|--chunksize]\n"
"\t[-A|--autobackup {y|n}]\n"
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
+ "\t[-c|--chunksize]\n"
"\t[-C|--contiguous {y|n}]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
@@ -315,7 +315,7 @@ xx(lvcreate,
"\t[--monitor {y|n}]\n"
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
"\t[-k|--setactivationskip {y|n}]\n"
- "\t[-K|--ignoreactivationskip] \n"
+ "\t[-K|--ignoreactivationskip]\n"
"\t{-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |\n"
"\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
"\t[--poolmetadatasize MetadataVolumeSize[bBsSkKmMgG]]\n"
@@ -326,10 +326,10 @@ xx(lvcreate,
"\t[-p|--permission {r|rw}]\n"
"\t[-r|--readahead ReadAheadSectors|auto|none]\n"
"\t[-t|--test]\n"
- "\t[--thinpool ThinPoolLogicalVolume[Path]]\n"
+ "\t[{--thinpool ThinPoolLogicalVolume[Path] |\n"
+ "\t --cachepool CachePoolLogicalVolume[Path]}]\n"
"\t[-v|--verbose]\n"
"\t[--version]\n"
-
"\t[PhysicalVolumePath...]\n\n",
addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, available_ARG,
@@ -357,11 +357,11 @@ xx(lvdisplay,
"\t[--ignoreskippedcluster]\n"
"\t[-m|--maps]\n"
"\t[--nosuffix]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n"
"\n"
"lvdisplay --columns|-C\n"
@@ -377,17 +377,17 @@ xx(lvdisplay,
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
"\t[-S|--select Selection]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
"\t[--segments]\n"
"\t[--separator Separator]\n"
"\t[--unbuffered]\n"
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
- aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG,
+ aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG,
ignoreskippedcluster_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG,
options_ARG, sort_ARG, partial_ARG, readonly_ARG, segments_ARG,
select_ARG, separator_ARG, unbuffered_ARG, units_ARG)
@@ -415,7 +415,7 @@ xx(lvextend,
"\t[-t|--test]\n"
"\t[--type VolumeType]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
alloc_ARG, autobackup_ARG, extents_ARG, force_ARG, mirrors_ARG,
@@ -432,7 +432,7 @@ xx(lvmchange,
"\t[-h|--help]\n"
"\t[-R|--reset]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n",
+ "\t[--version]\n",
reset_ARG)
@@ -445,7 +445,7 @@ xx(lvmdiskscan,
"\t[-h|--help]\n"
"\t[-l|--lvmpartition]\n"
"\t[--readonly]\n"
- "\t[--version]" "\n",
+ "\t[--version]\n",
lvmpartition_ARG, readonly_ARG)
@@ -457,8 +457,8 @@ xx(lvmsadc,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
- "\t[LogFilePath]\n" )
+ "\t[--version]\n"
+ "\t[LogFilePath]\n")
xx(lvmsar,
"Create activity report",
@@ -470,7 +470,7 @@ xx(lvmsar,
"\t[-h|--help]\n"
"\t[-s|--stdin]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tLogFilePath\n",
full_ARG, stdin_ARG)
@@ -491,7 +491,7 @@ xx(lvreduce,
"\t[-r|--resizefs]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[-y|--yes]\n"
"\tLogicalVolume[Path]\n",
@@ -510,7 +510,7 @@ xx(lvremove,
"\t[--noudevsync]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
autobackup_ARG, force_ARG, noudevsync_ARG, test_ARG)
@@ -519,15 +519,15 @@ xx(lvrename,
"Rename a logical volume",
0,
"lvrename\n"
- "\t[-A|--autobackup {y|n}] " "\n"
+ "\t[-A|--autobackup {y|n}]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-h|-?|--help] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|-?|--help]\n"
"\t[--noudevsync]\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose]" "\n"
- "\t[--version] " "\n"
- "\t{ OldLogicalVolumePath NewLogicalVolumePath |" "\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\t{ OldLogicalVolumePath NewLogicalVolumePath |\n"
"\t VolumeGroupName OldLogicalVolumeName NewLogicalVolumeName }\n",
autobackup_ARG, noudevsync_ARG, test_ARG)
@@ -552,7 +552,7 @@ xx(lvresize,
"\t[-t|--test]\n"
"\t[--type VolumeType]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
alloc_ARG, autobackup_ARG, extents_ARG, force_ARG, nofsck_ARG,
@@ -563,7 +563,7 @@ xx(lvresize,
xx(lvs,
"Display information about logical volumes",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
- "lvs" "\n"
+ "lvs\n"
"\t[-a|--all]\n"
"\t[--aligned]\n"
"\t[--binary]\n"
@@ -577,7 +577,7 @@ xx(lvs,
"\t[--nosuffix]\n"
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
"\t[--rows]\n"
"\t[--segments]\n"
@@ -588,7 +588,7 @@ xx(lvs,
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
"\t[--unquoted]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
aligned_ARG, all_ARG, binary_ARG, ignorelockingfailure_ARG,
@@ -600,17 +600,17 @@ xx(lvs,
xx(lvscan,
"List all logical volumes in all volume groups",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
- "lvscan " "\n"
+ "lvscan\n"
"\t[-a|--all]\n"
- "\t[-b|--blockdevice] " "\n"
+ "\t[-b|--blockdevice]\n"
"\t[--cache]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-h|-?|--help] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|-?|--help]\n"
"\t[--ignorelockingfailure]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
- "\t[-v|--verbose] " "\n"
+ "\t[-v|--verbose]\n"
"\t[--version]\n",
all_ARG, blockdevice_ARG, ignorelockingfailure_ARG, partial_ARG,
@@ -633,7 +633,7 @@ xx(pvchange,
"\t[-v|--verbose]\n"
"\t[--addtag Tag]\n"
"\t[--deltag Tag]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[PhysicalVolumePath...]\n",
all_ARG, allocatable_ARG, allocation_ARG, autobackup_ARG, deltag_ARG,
@@ -642,14 +642,14 @@ xx(pvchange,
xx(pvresize,
"Resize physical volume(s)",
0,
- "pvresize " "\n"
+ "pvresize\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug]" "\n"
- "\t[-h|-?|--help] " "\n"
- "\t[--setphysicalvolumesize PhysicalVolumeSize[bBsSkKmMgGtTpPeE]" "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|-?|--help]\n"
+ "\t[--setphysicalvolumesize PhysicalVolumeSize[bBsSkKmMgGtTpPeE]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
"\tPhysicalVolume [PhysicalVolume...]\n",
physicalvolumesize_ARG, test_ARG)
@@ -661,9 +661,9 @@ xx(pvck,
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
- "\t[--labelsector sector] " "\n"
+ "\t[--labelsector sector]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tPhysicalVolume [PhysicalVolume...]\n",
labelsector_ARG)
@@ -671,27 +671,27 @@ xx(pvck,
xx(pvcreate,
"Initialize physical volume(s) for use by LVM",
0,
- "pvcreate " "\n"
+ "pvcreate\n"
"\t[--norestorefile]\n"
"\t[--restorefile file]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug]" "\n"
- "\t[-f[f]|--force [--force]] " "\n"
- "\t[-h|-?|--help] " "\n"
- "\t[--labelsector sector] " "\n"
- "\t[-M|--metadatatype 1|2]" "\n"
- "\t[--pvmetadatacopies #copies]" "\n"
- "\t[--bootloaderareasize BootLoaderAreaSize[bBsSkKmMgGtTpPeE]]" "\n"
- "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n"
- "\t[--dataalignment Alignment[bBsSkKmMgGtTpPeE]]" "\n"
- "\t[--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]]" "\n"
- "\t[--setphysicalvolumesize PhysicalVolumeSize[bBsSkKmMgGtTpPeE]" "\n"
- "\t[-t|--test] " "\n"
- "\t[-u|--uuid uuid] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[-y|--yes]" "\n"
+ "\t[-d|--debug]\n"
+ "\t[-f[f]|--force [--force]]\n"
+ "\t[-h|-?|--help]\n"
+ "\t[--labelsector sector]\n"
+ "\t[-M|--metadatatype 1|2]\n"
+ "\t[--pvmetadatacopies #copies]\n"
+ "\t[--bootloaderareasize BootLoaderAreaSize[bBsSkKmMgGtTpPeE]]\n"
+ "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]\n"
+ "\t[--dataalignment Alignment[bBsSkKmMgGtTpPeE]]\n"
+ "\t[--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]]\n"
+ "\t[--setphysicalvolumesize PhysicalVolumeSize[bBsSkKmMgGtTpPeE]\n"
+ "\t[-t|--test]\n"
+ "\t[-u|--uuid uuid]\n"
+ "\t[-v|--verbose]\n"
+ "\t[-y|--yes]\n"
"\t[-Z|--zero {y|n}]\n"
- "\t[--version] " "\n"
+ "\t[--version]\n"
"\tPhysicalVolume [PhysicalVolume...]\n",
dataalignment_ARG, dataalignmentoffset_ARG, bootloaderareasize_ARG,
@@ -703,18 +703,18 @@ xx(pvcreate,
xx(pvdata,
"Display the on-disk metadata for physical volume(s)",
0,
- "pvdata " "\n"
- "\t[-a|--all] " "\n"
+ "pvdata\n"
+ "\t[-a|--all]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-E|--physicalextent] " "\n"
- "\t[-h|-?|--help]" "\n"
- "\t[-L|--logicalvolume] " "\n"
- "\t[-P[P]|--physicalvolume [--physicalvolume]]" "\n"
- "\t[-U|--uuidlist] " "\n"
- "\t[-v[v]|--verbose [--verbose]] " "\n"
- "\t[-V|--volumegroup]" "\n"
- "\t[--version] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-E|--physicalextent]\n"
+ "\t[-h|-?|--help]\n"
+ "\t[-L|--logicalvolume]\n"
+ "\t[-P[P]|--physicalvolume [--physicalvolume]]\n"
+ "\t[-U|--uuidlist]\n"
+ "\t[-v[v]|--verbose [--verbose]]\n"
+ "\t[-V|--volumegroup]\n"
+ "\t[--version]\n"
"\tPhysicalVolume [PhysicalVolume...]\n",
all_ARG, logicalextent_ARG, physicalextent_ARG,
@@ -736,7 +736,7 @@ xx(pvdisplay,
"\t[-s|--short]\n"
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[PhysicalVolumePath [PhysicalVolumePath...]]\n"
"\n"
"pvdisplay --columns|-C\n"
@@ -757,7 +757,7 @@ xx(pvdisplay,
"\t[--unbuffered]\n"
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[PhysicalVolumePath [PhysicalVolumePath...]]\n",
aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG,
@@ -768,7 +768,7 @@ xx(pvdisplay,
xx(pvmove,
"Move extents from one physical volume to another",
ALL_VGS_IS_DEFAULT, /* For polldaemon to find pvmoves in-progress using process_each_vg. */
- "pvmove " "\n"
+ "pvmove\n"
"\t[--abort]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[--atomic]\n"
@@ -793,15 +793,15 @@ xx(pvmove,
xx(pvremove,
"Remove LVM label(s) from physical volume(s)",
0,
- "pvremove " "\n"
+ "pvremove\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug]" "\n"
- "\t[-f[f]|--force [--force]] " "\n"
- "\t[-h|-?|--help] " "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version] " "\n"
- "\t[-y|--yes]" "\n"
+ "\t[-d|--debug]\n"
+ "\t[-f[f]|--force [--force]]\n"
+ "\t[-h|-?|--help]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\t[-y|--yes]\n"
"\tPhysicalVolume [PhysicalVolume...]\n",
force_ARG, test_ARG)
@@ -809,13 +809,13 @@ xx(pvremove,
xx(pvs,
"Display information about physical volumes",
CACHE_VGMETADATA | PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_ALL_DEVS,
- "pvs" "\n"
+ "pvs\n"
"\t[-a|--all]\n"
"\t[--aligned]\n"
"\t[--binary]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug]" "\n"
- "\t[-h|-?|--help] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|-?|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[--ignoreskippedcluster]\n"
"\t[--nameprefixes]\n"
@@ -823,7 +823,7 @@ xx(pvs,
"\t[--nosuffix]\n"
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
"\t[--rows]\n"
"\t[--segments]\n"
@@ -846,19 +846,19 @@ xx(pvs,
xx(pvscan,
"List all physical volumes",
PERMITTED_READ_ONLY,
- "pvscan " "\n"
+ "pvscan\n"
"\t[-b|--background]\n"
"\t[--cache [-a|--activate ay] [ DevicePath | --major major --minor minor]...]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t{-e|--exported | -n|--novolumegroup} " "\n"
- "\t[-h|-?|--help]" "\n"
+ "\t[-d|--debug]\n"
+ "\t{-e|--exported | -n|--novolumegroup}\n"
+ "\t[-h|-?|--help]\n"
"\t[--ignorelockingfailure]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
- "\t[-s|--short] " "\n"
- "\t[-u|--uuid] " "\n"
- "\t[-v|--verbose] " "\n"
+ "\t[-s|--short]\n"
+ "\t[-u|--uuid]\n"
+ "\t[-v|--verbose]\n"
"\t[--version]\n",
activate_ARG, available_ARG, backgroundfork_ARG, cache_long_ARG,
@@ -878,16 +878,16 @@ xx(tags,
xx(vgcfgbackup,
"Backup volume group configuration(s)",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
- "vgcfgbackup " "\n"
+ "vgcfgbackup\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-f|--file filename] " "\n"
- "\t[-h|-?|--help] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-f|--file filename]\n"
+ "\t[-h|-?|--help]\n"
"\t[--ignorelockingfailure]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
- "\t[-v|--verbose]" "\n"
- "\t[--version] " "\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
"\t[VolumeGroupName...]\n",
file_ARG, ignorelockingfailure_ARG, partial_ARG, readonly_ARG)
@@ -895,17 +895,17 @@ xx(vgcfgbackup,
xx(vgcfgrestore,
"Restore volume group configuration",
0,
- "vgcfgrestore " "\n"
+ "vgcfgrestore\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-f|--file filename] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-f|--file filename]\n"
"\t[--force]\n"
- "\t[-l[l]|--list [--list]]" "\n"
- "\t[-M|--metadatatype 1|2]" "\n"
- "\t[-h|--help]" "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose]" "\n"
- "\t[--version] " "\n"
+ "\t[-l[l]|--list [--list]]\n"
+ "\t[-M|--metadatatype 1|2]\n"
+ "\t[-h|--help]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
"\tVolumeGroupName",
file_ARG, force_long_ARG, list_ARG, metadatatype_ARG, test_ARG)
@@ -913,36 +913,36 @@ xx(vgcfgrestore,
xx(vgchange,
"Change volume group attributes",
CACHE_VGMETADATA | PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
- "vgchange" "\n"
- "\t[-A|--autobackup {y|n}] " "\n"
- "\t[--alloc AllocationPolicy] " "\n"
- "\t[-P|--partial] " "\n"
+ "vgchange\n"
+ "\t[-A|--autobackup {y|n}]\n"
+ "\t[--alloc AllocationPolicy]\n"
+ "\t[-P|--partial]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[--detachprofile] " "\n"
- "\t[-h|--help] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[--detachprofile]\n"
+ "\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[--ignoremonitoring]\n"
"\t[--ignoreskippedcluster]\n"
- "\t[-K|--ignoreactivationskip] \n"
+ "\t[-K|--ignoreactivationskip]\n"
"\t[--metadataprofile ProfileName]\n"
"\t[--monitor {y|n}]\n"
- "\t[--[vg]metadatacopies #copies] " "\n"
+ "\t[--[vg]metadatacopies #copies]\n"
"\t[--poll {y|n}]\n"
"\t[--noudevsync]\n"
"\t[--refresh]\n"
"\t[--sysinit]\n"
- "\t[-t|--test]" "\n"
- "\t[-u|--uuid] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version]" "\n"
- "\t{-a|--activate [a|e|l]{y|n} |" "\n"
- "\t[--activationmode {complete|degraded|partial}]" "\n"
- "\t -c|--clustered {y|n} |" "\n"
- "\t -x|--resizeable {y|n} |" "\n"
- "\t -l|--logicalvolume MaxLogicalVolumes |" "\n"
- "\t -p|--maxphysicalvolumes MaxPhysicalVolumes |" "\n"
- "\t -s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE] |" "\n"
+ "\t[-t|--test]\n"
+ "\t[-u|--uuid]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\t{-a|--activate [a|e|l]{y|n} |\n"
+ "\t[--activationmode {complete|degraded|partial}]\n"
+ "\t -c|--clustered {y|n} |\n"
+ "\t -x|--resizeable {y|n} |\n"
+ "\t -l|--logicalvolume MaxLogicalVolumes |\n"
+ "\t -p|--maxphysicalvolumes MaxPhysicalVolumes |\n"
+ "\t -s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE] |\n"
"\t --addtag Tag |\n"
"\t --deltag Tag}\n"
"\t[VolumeGroupName...]\n",
@@ -964,52 +964,52 @@ xx(vgck,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
- "\t[VolumeGroupName...]\n" )
+ "\t[--version]\n"
+ "\t[VolumeGroupName...]\n")
xx(vgconvert,
"Change volume group metadata format",
0,
- "vgconvert " "\n"
+ "vgconvert\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug]" "\n"
- "\t[-h|--help] " "\n"
- "\t[--labelsector sector] " "\n"
- "\t[-M|--metadatatype 1|2]" "\n"
- "\t[--pvmetadatacopies #copies]" "\n"
- "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n"
- "\t[--bootloaderareasize BootLoaderAreaSize[bBsSkKmMgGtTpPeE]]" "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--labelsector sector]\n"
+ "\t[-M|--metadatatype 1|2]\n"
+ "\t[--pvmetadatacopies #copies]\n"
+ "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]\n"
+ "\t[--bootloaderareasize BootLoaderAreaSize[bBsSkKmMgGtTpPeE]]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
"\tVolumeGroupName [VolumeGroupName...]\n",
force_ARG, test_ARG, labelsector_ARG, bootloaderareasize_ARG,
metadatatype_ARG, metadatacopies_ARG, pvmetadatacopies_ARG,
- metadatasize_ARG )
+ metadatasize_ARG)
xx(vgcreate,
"Create a volume group",
0,
- "vgcreate" "\n"
- "\t[-A|--autobackup {y|n}] " "\n"
- "\t[--addtag Tag] " "\n"
- "\t[--alloc AllocationPolicy] " "\n"
- "\t[-c|--clustered {y|n}] " "\n"
+ "vgcreate\n"
+ "\t[-A|--autobackup {y|n}]\n"
+ "\t[--addtag Tag]\n"
+ "\t[--alloc AllocationPolicy]\n"
+ "\t[-c|--clustered {y|n}]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug]" "\n"
- "\t[-h|--help]" "\n"
- "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]\n"
"\t[--metadataprofile ProfileName]\n"
- "\t[-M|--metadatatype 1|2] " "\n"
- "\t[--[vg]metadatacopies #copies] " "\n"
- "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes] " "\n"
- "\t[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]] " "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose]" "\n"
- "\t[--version] " "\n"
- "\t[-y|--yes]" "\n"
- "\t[ PHYSICAL DEVICE OPTIONS ] " "\n"
+ "\t[-M|--metadatatype 1|2]\n"
+ "\t[--[vg]metadatacopies #copies]\n"
+ "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes]\n"
+ "\t[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\t[-y|--yes]\n"
+ "\t[ PHYSICAL DEVICE OPTIONS ]\n"
"\tVolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]\n",
addtag_ARG, alloc_ARG, autobackup_ARG, clustered_ARG, maxlogicalvolumes_ARG,
@@ -1021,40 +1021,40 @@ xx(vgcreate,
xx(vgdisplay,
"Display volume group information",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
- "vgdisplay " "\n"
- "\t[-A|--activevolumegroups]" "\n"
- "\t[-c|--colon | -s|--short | -v|--verbose]" "\n"
+ "vgdisplay\n"
+ "\t[-A|--activevolumegroups]\n"
+ "\t[-c|--colon | -s|--short | -v|--verbose]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-h|--help] " "\n"
- "\t[--ignorelockingfailure]" "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--ignorelockingfailure]\n"
"\t[--ignoreskippedcluster]\n"
"\t[--nosuffix]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[VolumeGroupName [VolumeGroupName...]]\n"
"\n"
"vgdisplay --columns|-C\n"
"\t[--aligned]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-h|--help] " "\n"
- "\t[--ignorelockingfailure]" "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--ignorelockingfailure]\n"
"\t[--ignoreskippedcluster]\n"
"\t[--noheadings]\n"
"\t[--nosuffix]\n"
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[-S|--select Selection]\n"
"\t[--readonly]\n"
"\t[--separator Separator]\n"
"\t[--unbuffered]\n"
"\t[--units hHbBsSkKmMgGtTpPeE]\n"
- "\t[--verbose]" "\n"
- "\t[--version]" "\n"
+ "\t[--verbose]\n"
+ "\t[--version]\n"
"\t[VolumeGroupName [VolumeGroupName...]]\n",
activevolumegroups_ARG, aligned_ARG, colon_ARG, columns_ARG,
@@ -1065,13 +1065,13 @@ xx(vgdisplay,
xx(vgexport,
"Unregister volume group(s) from the system",
ALL_VGS_IS_DEFAULT,
- "vgexport " "\n"
- "\t[-a|--all] " "\n"
+ "vgexport\n"
+ "\t[-a|--all]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-h|--help]" "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
"\tVolumeGroupName [VolumeGroupName...]\n",
all_ARG, test_ARG)
@@ -1088,9 +1088,9 @@ xx(vgextend,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[-y|--yes]\n"
- "\t[ PHYSICAL DEVICE OPTIONS ] " "\n"
+ "\t[ PHYSICAL DEVICE OPTIONS ]\n"
"\tVolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]\n",
autobackup_ARG, test_ARG,
@@ -1102,16 +1102,16 @@ xx(vgextend,
xx(vgimport,
"Register exported volume group with system",
ALL_VGS_IS_DEFAULT,
- "vgimport " "\n"
+ "vgimport\n"
"\t[-a|--all]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-f|--force] " "\n"
- "\t[-h|--help] " "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose]" "\n"
- "\t[--version]" "\n"
- "\tVolumeGroupName..." "\n",
+ "\t[-d|--debug]\n"
+ "\t[-f|--force]\n"
+ "\t[-h|--help]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\tVolumeGroupName...\n",
all_ARG, force_ARG, test_ARG)
@@ -1126,7 +1126,7 @@ xx(vgmerge,
"\t[-l|--list]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tDestinationVolumeGroupName SourceVolumeGroupName\n",
autobackup_ARG, list_ARG, test_ARG)
@@ -1141,7 +1141,7 @@ xx(vgmknodes,
"\t[--ignorelockingfailure]\n"
"\t[--refresh]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\t[VolumeGroupName...]\n",
ignorelockingfailure_ARG, refresh_ARG)
@@ -1160,7 +1160,7 @@ xx(vgreduce,
"\t[-f|--force]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tVolumeGroupName\n"
"\t[PhysicalVolumePath...]\n",
@@ -1178,7 +1178,7 @@ xx(vgremove,
"\t[--noudevsync]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tVolumeGroupName [VolumeGroupName...]\n",
force_ARG, noudevsync_ARG, test_ARG)
@@ -1193,7 +1193,7 @@ xx(vgrename,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
"\tOldVolumeGroupPath NewVolumeGroupPath |\n"
"\tOldVolumeGroupName NewVolumeGroupName\n",
@@ -1202,7 +1202,7 @@ xx(vgrename,
xx(vgs,
"Display information about volume groups",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
- "vgs" "\n"
+ "vgs\n"
"\t[--aligned]\n"
"\t[--binary]\n"
"\t[-a|--all]\n"
@@ -1216,7 +1216,7 @@ xx(vgs,
"\t[--nosuffix]\n"
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[--readonly]\n"
"\t[--rows]\n"
"\t[-S|--select Selection]\n"
@@ -1245,31 +1245,31 @@ xx(vgscan,
"\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[--mknodes]\n"
- "\t[-P|--partial] " "\n"
+ "\t[-P|--partial]\n"
"\t[-v|--verbose]\n"
- "\t[--version]" "\n",
+ "\t[--version]\n",
cache_long_ARG, ignorelockingfailure_ARG, mknodes_ARG, partial_ARG)
xx(vgsplit,
"Move physical volumes into a new or existing volume group",
0,
- "vgsplit " "\n"
- "\t[-A|--autobackup {y|n}] " "\n"
- "\t[--alloc AllocationPolicy] " "\n"
- "\t[-c|--clustered {y|n}] " "\n"
+ "vgsplit\n"
+ "\t[-A|--autobackup {y|n}]\n"
+ "\t[--alloc AllocationPolicy]\n"
+ "\t[-c|--clustered {y|n}]\n"
"\t[--commandprofile ProfileName]\n"
- "\t[-d|--debug] " "\n"
- "\t[-h|--help] " "\n"
- "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n"
- "\t[-M|--metadatatype 1|2] " "\n"
- "\t[--[vg]metadatacopies #copies] " "\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]\n"
+ "\t[-M|--metadatatype 1|2]\n"
+ "\t[--[vg]metadatacopies #copies]\n"
"\t[-n|--name LogicalVolumeName]\n"
- "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes] " "\n"
- "\t[-t|--test] " "\n"
- "\t[-v|--verbose] " "\n"
- "\t[--version]" "\n"
- "\tSourceVolumeGroupName DestinationVolumeGroupName" "\n"
+ "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes]\n"
+ "\t[-t|--test]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\tSourceVolumeGroupName DestinationVolumeGroupName\n"
"\t[PhysicalVolumePath...]\n",
alloc_ARG, autobackup_ARG, clustered_ARG,
@@ -1279,4 +1279,4 @@ xx(vgsplit,
xx(version,
"Display software and driver version information",
PERMITTED_READ_ONLY,
- "version\n" )
+ "version\n")
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1cb267274916fcd…
Commit: f1cb267274916fcd63456a859ff433bdceefef07
Parent: be3f666ef3ad25f2af598ecfa305ab9c2f7de3f4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 23 14:27:05 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
lv_manip: preserve read-only status in layered volume
---
lib/metadata/lv_manip.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 3c84a5c..6240f14 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6075,7 +6075,9 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
return NULL;
}
- if (!(layer_lv = lv_create_empty(name, NULL, LVM_READ | LVM_WRITE,
+ if (!(layer_lv = lv_create_empty(name, NULL,
+ /* Preserve read-only flag */
+ LVM_READ | (lv_where->status & LVM_WRITE),
ALLOC_INHERIT, lv_where->vg))) {
log_error("Creation of layer LV failed");
return NULL;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=be3f666ef3ad25f2…
Commit: be3f666ef3ad25f2af598ecfa305ab9c2f7de3f4
Parent: 2fc403b0fc5c7fffec4d7864433d0db3c139995c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 13:29:25 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
lv_manip: improve should_wipe reporting
We want to print smarter warning message only when
the zeroing was not provided on the first zeroable segment
of newly created LV.
Put warning within _should_wipe_lv function to avoid reevaluation
of same conditions twice.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 40 +++++++++++++++++++++++++---------------
2 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e2372e5..70b41bc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Improve _should_wipe_lv() to warn with message.
Inform about temporarily created volumes only in verbose mode.
Better support for --test mode with pool creation.
Query lock holding LV when replacing and converting raid volumes.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 61620e5..3c84a5c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6530,14 +6530,31 @@ int lv_activation_skip(struct logical_volume *lv, activation_change_t activate,
return 1;
}
-static int _should_wipe_lv(struct lvcreate_params *lp, struct logical_volume *lv) {
- int r = lp->zero | lp->wipe_signatures;
+static int _should_wipe_lv(struct lvcreate_params *lp,
+ struct logical_volume *lv, int warn)
+{
+ /* Unzeroable segment */
+ if (first_seg(lv)->segtype->flags & SEG_CANNOT_BE_ZEROED)
+ return 0;
- if (!seg_is_thin(lp) && !seg_is_cache_pool(lp))
- return r;
+ /* Thin snapshot need not to be zeroed */
+ /* Thin pool with zeroing doesn't need zeroing or wiping */
+ if (lv_is_thin_volume(lv) &&
+ (first_seg(lv)->origin ||
+ first_seg(first_seg(lv)->pool_lv)->zero_new_blocks))
+ return 0;
- if (lv_is_thin_volume(lv))
- return r && !lp->snapshot && !first_seg(first_seg(lv)->pool_lv)->zero_new_blocks;
+ /* Cannot zero read-only volume */
+ if ((lv->status & LVM_WRITE) &&
+ (lp->zero || lp->wipe_signatures))
+ return 1;
+
+ if (warn && (!lp->zero || !(lv->status & LVM_WRITE)))
+ log_warn("WARNING: Logical volume %s not zeroed.",
+ display_lvname(lv));
+ if (warn && (!lp->wipe_signatures || !(lv->status & LVM_WRITE)))
+ log_verbose("Signature wiping on logical volume %s not requested.",
+ display_lvname(lv));
return 0;
}
@@ -7017,7 +7034,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/* Do not scan this LV until properly zeroed/wiped. */
- if (_should_wipe_lv(lp, lv))
+ if (_should_wipe_lv(lp, lv, 0))
lv->status |= LV_NOSCAN;
if (lp->temporary)
@@ -7073,14 +7090,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (!seg_is_thin(lp) && !lp->snapshot) {
- if (!lp->zero)
- log_warn("WARNING: \"%s/%s\" not zeroed", lv->vg->name, lv->name);
- if (!lp->wipe_signatures)
- log_verbose("Signature wiping on \"%s/%s\" not requested", lv->vg->name, lv->name);
- }
-
- if (_should_wipe_lv(lp, lv)) {
+ if (_should_wipe_lv(lp, lv, 1)) {
if (!wipe_lv(lv, (struct wipe_params)
{
.do_zero = lp->zero,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2fc403b0fc5c7fff…
Commit: 2fc403b0fc5c7fffec4d7864433d0db3c139995c
Parent: fd1aa7fd5a1ccd7ebcf3446988110ad5c16fddc7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 15 15:06:42 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
toollib: new arg list functions
Check for negative arg list:
arg_from_list_is_negative()
Check for zero arg in list:
arg_from_list_is_zero()
---
tools/lvmcmdline.c | 35 +++++++++++++++++++++++++++++++++++
tools/tools.h | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 4c61332..6e13679 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -127,6 +127,41 @@ int arg_outside_list_is_set(const struct cmd_context *cmd, const char *err_found
return 0;
}
+int arg_from_list_is_negative(const struct cmd_context *cmd, const char *err_found, ...)
+{
+ int arg, ret = 0;
+ va_list ap;
+
+ va_start(ap, err_found);
+ while ((arg = va_arg(ap, int)) != -1)
+ if (arg_sign_value(cmd, arg, SIGN_NONE) == SIGN_MINUS) {
+ if (err_found)
+ log_error("%s %s.", arg_long_option_name(arg), err_found);
+ ret = 1;
+ }
+ va_end(ap);
+
+ return ret;
+}
+
+int arg_from_list_is_zero(const struct cmd_context *cmd, const char *err_found, ...)
+{
+ int arg, ret = 0;
+ va_list ap;
+
+ va_start(ap, err_found);
+ while ((arg = va_arg(ap, int)) != -1)
+ if (arg_is_set(cmd, arg) &&
+ !arg_int_value(cmd, arg, 0)) {
+ if (err_found)
+ log_error("%s %s.", arg_long_option_name(arg), err_found);
+ ret = 1;
+ }
+ va_end(ap);
+
+ return ret;
+}
+
unsigned grouped_arg_is_set(const struct arg_values *av, int a)
{
return grouped_arg_count(av, a) ? 1 : 0;
diff --git a/tools/tools.h b/tools/tools.h
index 5fa1ab6..75c3eaa 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -148,6 +148,8 @@ unsigned arg_count(const struct cmd_context *cmd, int a);
unsigned arg_is_set(const struct cmd_context *cmd, int a);
int arg_from_list_is_set(const struct cmd_context *cmd, const char *err_found, ...);
int arg_outside_list_is_set(const struct cmd_context *cmd, const char *err_found, ...);
+int arg_from_list_is_negative(const struct cmd_context *cmd, const char *err_found, ...);
+int arg_from_list_is_zero(const struct cmd_context *cmd, const char *err_found, ...);
const char *arg_long_option_name(int a);
const char *arg_value(const struct cmd_context *cmd, int a);
const char *arg_str_value(const struct cmd_context *cmd, int a, const char *def);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd1aa7fd5a1ccd7e…
Commit: fd1aa7fd5a1ccd7ebcf3446988110ad5c16fddc7
Parent: 128131dbc579daf510c4aa7b5cd8f0ca076539a3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 11 09:10:07 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
segments: disable init of free segment
Since it is not needed and would require separate
code for validation disable its initialization.
---
lib/commands/toolcontext.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index e38aa56..72525f5 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1218,7 +1218,7 @@ static int _init_segtypes(struct cmd_context *cmd)
init_striped_segtype,
init_zero_segtype,
init_error_segtype,
- init_free_segtype,
+ /* disabled until needed init_free_segtype, */
#ifdef SNAPSHOT_INTERNAL
init_snapshot_segtype,
#endif
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=128131dbc579daf5…
Commit: 128131dbc579daf510c4aa7b5cd8f0ca076539a3
Parent: 8a2f553b7d5f516ac750aadd4ca75cc4a20aef15
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 19 22:04:02 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
lvconvert: external detects more conflicts
Check for more prohibited types for external origin conversion.
TODO: Move this function to separate validation code.
(Continuing in release fixes.)
---
tools/lvconvert.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 9155998..eb8a83b 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2664,12 +2664,16 @@ static int _lvconvert_thin(struct cmd_context *cmd,
return 0;
}
- if (lv_is_cache_type(lv) ||
+ if (lv_is_locked(lv) ||
+ !lv_is_visible(lv) ||
+ lv_is_cache_type(lv) ||
lv_is_cow(lv) ||
lv_is_pool(lv) ||
- lv_is_thin_pool_data(lv) ||
- lv_is_thin_pool_metadata(lv)) {
- log_error("Can't use %s %s as external origin.",
+ lv_is_pool_data(lv) ||
+ lv_is_pool_metadata(lv)) {
+ log_error("Can't use%s%s %s %s as external origin.",
+ lv_is_locked(lv) ? " locked" : "",
+ lv_is_visible(lv) ? "" : " hidden",
lvseg_name(first_seg(lv)),
display_lvname(lv));
return 0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8a2f553b7d5f516a…
Commit: 8a2f553b7d5f516ac750aadd4ca75cc4a20aef15
Parent: f7cfea251c07b3a63131320cf4751b91480b9be7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 12:12:45 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
lvcreate: move tests that requires activation
Tests that needs active kernel driver put in single place.
---
lib/metadata/lv_manip.c | 48 ++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6caa284..61620e5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6590,6 +6590,31 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
+ if (!activation()) {
+ if (seg_is_cache(lp) ||
+ seg_is_mirror(lp) ||
+ seg_is_raid(lp) ||
+ seg_is_thin(lp) ||
+ lp->snapshot) {
+ /*
+ * FIXME: For thin pool add some code to allow delayed
+ * initialization of empty thin pool volume.
+ * i.e. using some LV flag, fake message,...
+ * and testing for metadata pool header signature?
+ */
+ log_error("Can't create %s without using "
+ "device-mapper kernel driver.",
+ lp->segtype->name);
+ return NULL;
+ }
+ /* Does LV need to be zeroed? */
+ if (lp->zero && !seg_is_thin(lp)) {
+ log_error("Can't wipe start of new LV without using "
+ "device-mapper kernel driver.");
+ return NULL;
+ }
+ }
+
if (lp->stripe_size > vg->extent_size) {
if (segtype_is_raid(lp->segtype) &&
(vg->extent_size < STRIPE_SIZE_MIN)) {
@@ -6629,13 +6654,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->extents = lp->extents - size_rest + lp->stripes;
}
- /* Does LV need to be zeroed? Thin handles this as a per-pool in-kernel setting. */
- if (lp->zero && !segtype_is_thin(lp->segtype) && !activation()) {
- log_error("Can't wipe start of new LV without using "
- "device-mapper kernel driver");
- return NULL;
- }
-
status |= lp->permission | VISIBLE_LV;
if (seg_is_cache(lp)) {
@@ -6773,22 +6791,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (!activation() &&
- (seg_is_mirrored(lp) ||
- seg_is_raid(lp) ||
- seg_is_pool(lp))) {
- /*
- * FIXME: For thin pool add some code to allow delayed
- * initialization of empty thin pool volume.
- * i.e. using some LV flag, fake message,...
- * and testing for metadata pool header signature?
- */
- log_error("Can't create %s without using "
- "device-mapper kernel driver.",
- lp->segtype->name);
- return NULL;
- }
-
/* The snapshot segment gets created later */
if (lp->snapshot && !seg_is_thin(lp) &&
!(lp->segtype = get_segtype_from_string(cmd, "striped")))
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f7cfea251c07b3a6…
Commit: f7cfea251c07b3a63131320cf4751b91480b9be7
Parent: 2c057f33f3581aa29f79bb0a62c7115da30f8672
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 21:53:48 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
lvcreate: better logging for temporary device
Hide creation of temporary LVs and print them only in verbose mode.
e.g. hides confusing message about creation of _pmspare
device during creation of pool.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b197568..e2372e5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Inform about temporarily created volumes only in verbose mode.
Better support for --test mode with pool creation.
Query lock holding LV when replacing and converting raid volumes.
Add extra validate for locked lv within validate_lv_cache_create().
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f60b964..6caa284 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7217,7 +7217,10 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
return_NULL;
out:
- log_print_unless_silent("Logical volume \"%s\" created", lv->name);
+ if (lp->temporary)
+ log_verbose("Temporary logical volume \"%s\" created.", lv->name);
+ else
+ log_print_unless_silent("Logical volume \"%s\" created.", lv->name);
return lv;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2c057f33f3581aa2…
Commit: 2c057f33f3581aa29f79bb0a62c7115da30f8672
Parent: 237c54802c88f0a7045d11642884c3d69e46180d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 10 22:22:43 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
segtypes: macro segtype_is_unknown
---
lib/metadata/segtype.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index e0c46df..749b188 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -57,6 +57,7 @@ struct dev_manager;
#define segtype_is_thin_pool(segtype) ((segtype)->flags & SEG_THIN_POOL ? 1 : 0)
#define segtype_is_thin_volume(segtype) ((segtype)->flags & SEG_THIN_VOLUME ? 1 : 0)
#define segtype_is_virtual(segtype) ((segtype)->flags & SEG_VIRTUAL ? 1 : 0)
+#define segtype_is_unknown(segtype) ((segtype)->flags & SEG_UNKNOWN ? 1 : 0)
#define seg_is_cache(seg) segtype_is_cache((seg)->segtype)
#define seg_is_cache_pool(seg) segtype_is_cache_pool((seg)->segtype)
@@ -73,10 +74,10 @@ struct dev_manager;
#define seg_is_thin_pool(seg) segtype_is_thin_pool((seg)->segtype)
#define seg_is_thin_volume(seg) segtype_is_thin_volume((seg)->segtype)
#define seg_is_virtual(seg) segtype_is_virtual((seg)->segtype)
+#define seg_unknown(seg) segtype_is_unknown((seg)->segtype)
#define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0)
#define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0)
#define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0)
-#define seg_unknown(seg) ((seg)->segtype->flags & SEG_UNKNOWN ? 1 : 0)
struct segment_type {
struct dm_list list; /* Internal */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=237c54802c88f0a7…
Commit: 237c54802c88f0a7045d11642884c3d69e46180d
Parent: 5bdf48b489660d1e99631fcb950c2094a9d158c2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 11 18:17:46 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
tools: read yes_no_arg via int_value
yes_no_arg is already parsed so read parsed value as int.
---
tools/lvchange.c | 10 ++++------
tools/lvconvert.c | 6 ++----
tools/lvcreate.c | 10 +++++-----
tools/pvchange.c | 15 +++------------
tools/toollib.c | 11 ++++-------
tools/vgchange.c | 4 ++--
6 files changed, 20 insertions(+), 36 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 6cb6f15..6697905 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -461,12 +461,10 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
{
- int want_contiguous = 0;
- alloc_policy_t alloc;
-
- want_contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
- alloc = want_contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
- alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, alloc);
+ int want_contiguous = arg_int_value(cmd, contiguous_ARG, 0);
+ alloc_policy_t alloc = (alloc_policy_t)
+ arg_uint_value(cmd, alloc_ARG, (want_contiguous)
+ ? ALLOC_CONTIGUOUS : ALLOC_INHERIT);
if (alloc == lv->alloc) {
log_error("Allocation policy of logical volume \"%s\" is "
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index fc28846..9155998 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -559,10 +559,8 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
return_0;
- lp->zero = strcmp(arg_str_value(cmd, zero_ARG,
- (lp->segtype->flags &
- SEG_CANNOT_BE_ZEROED) ?
- "n" : "y"), "n");
+ lp->zero = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
+ ? 0 : arg_int_value(cmd, zero_ARG, 1);
} else if (arg_count(cmd, replace_ARG)) { /* RAID device replacement */
lp->replace_pv_count = arg_count(cmd, replace_ARG);
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index d849f93..5a91627 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -985,13 +985,13 @@ static int _lvcreate_params(struct lvcreate_params *lp,
/*
* Should we zero/wipe signatures on the lv.
*/
- lp->zero = (!(lp->segtype->flags & SEG_CANNOT_BE_ZEROED) &&
- (strcmp(arg_str_value(cmd, zero_ARG, "y"), "y") == 0)) ? 1 : 0;
+ lp->zero = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
+ ? 0 : arg_int_value(cmd, zero_ARG, 1);
if (arg_count(cmd, wipesignatures_ARG)) {
/* If -W/--wipesignatures is given on command line directly, respect it. */
- lp->wipe_signatures =(!(lp->segtype->flags & SEG_CANNOT_BE_ZEROED) &&
- (strcmp(arg_str_value(cmd, wipesignatures_ARG, "y"), "y") == 0)) ? 1 : 0;
+ lp->wipe_signatures = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
+ ? 0 : arg_int_value(cmd, wipesignatures_ARG, 1);
} else {
/*
* If -W/--wipesignatures is not given on command line,
@@ -1047,7 +1047,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
/*
* Allocation parameters
*/
- contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
+ contiguous = arg_int_value(cmd, contiguous_ARG, 0);
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
diff --git a/tools/pvchange.c b/tools/pvchange.c
index c2adc34..76db917 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -22,18 +22,9 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
const char *pv_name = pv_dev_name(pv);
char uuid[64] __attribute__((aligned(8)));
- int allocatable = 0;
- int tagargs = 0;
- int mda_ignore = 0;
-
- tagargs = arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG);
-
- if (arg_count(cmd, allocatable_ARG))
- allocatable = !strcmp(arg_str_value(cmd, allocatable_ARG, "n"),
- "y");
- if (arg_count(cmd, metadataignore_ARG))
- mda_ignore = !strcmp(arg_str_value(cmd, metadataignore_ARG, "n"),
- "y");
+ int allocatable = arg_int_value(cmd, allocatable_ARG, 0);
+ int mda_ignore = arg_int_value(cmd, metadataignore_ARG, 0);
+ int tagargs = arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG);
/* If in a VG, must change using volume group. */
if (!is_orphan(pv)) {
diff --git a/tools/toollib.c b/tools/toollib.c
index f81acca..a33e6c2 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -643,9 +643,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
arg_uint_value(cmd, physicalextentsize_ARG, vp_def->extent_size);
if (arg_count(cmd, clustered_ARG))
- vp_new->clustered =
- !strcmp(arg_str_value(cmd, clustered_ARG,
- vp_def->clustered ? "y":"n"), "y");
+ vp_new->clustered = arg_int_value(cmd, clustered_ARG, vp_def->clustered);
else
/* Default depends on current locking type */
vp_new->clustered = locking_is_clustered();
@@ -866,8 +864,7 @@ int pvcreate_params_validate(struct cmd_context *cmd,
return 0;
}
- if (arg_count(cmd, zero_ARG))
- pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
+ pp->zero = arg_int_value(cmd, zero_ARG, 1);
if (arg_sign_value(cmd, dataalignment_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Physical volume data alignment may not be negative");
@@ -966,7 +963,7 @@ int get_pool_params(struct cmd_context *cmd,
if (segtype_is_thin_pool(segtype) || segtype_is_thin(segtype)) {
if (arg_count(cmd, zero_ARG)) {
*passed_args |= PASS_ARG_ZERO;
- *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
+ *zero = arg_int_value(cmd, zero_ARG, 1);
log_very_verbose("Setting pool zeroing: %u", *zero);
}
@@ -1188,7 +1185,7 @@ int get_and_validate_major_minor(const struct cmd_context *cmd,
const struct format_type *fmt,
int32_t *major, int32_t *minor)
{
- if (strcmp(arg_str_value(cmd, persistent_ARG, "n"), "y")) {
+ if (!arg_int_value(cmd, persistent_ARG, 0)) {
if (arg_is_set(cmd, minor_ARG) || arg_is_set(cmd, major_ARG)) {
log_error("--major and --minor incompatible with -Mn");
return 0;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 9a9fe48..af59f3a 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -278,7 +278,7 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
static int _vgchange_resizeable(struct cmd_context *cmd,
struct volume_group *vg)
{
- int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
+ int resizeable = arg_int_value(cmd, resizeable_ARG, 0);
if (resizeable && vg_is_resizeable(vg)) {
log_error("Volume group \"%s\" is already resizeable",
@@ -303,7 +303,7 @@ static int _vgchange_resizeable(struct cmd_context *cmd,
static int _vgchange_clustered(struct cmd_context *cmd,
struct volume_group *vg)
{
- int clustered = !strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y");
+ int clustered = arg_int_value(cmd, clustered_ARG, 0);
if (clustered && (vg_is_clustered(vg))) {
log_error("Volume group \"%s\" is already clustered",
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5bdf48b489660d1e…
Commit: 5bdf48b489660d1e99631fcb950c2094a9d158c2
Parent: 482e572e5de327ce3b8786215cf33e6d6223c543
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 14:30:33 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
tools: refactor reporter code
Use new libdm macro DM_LIST_HEAD_INIT().
Embeded 'free' segment type (so it's not needed in the list)
Drop assignments of 0,NULL since they are defaults.
---
lib/report/report.c | 10 +++++-----
tools/reporter.c | 46 ++++++++++++++++++----------------------------
2 files changed, 23 insertions(+), 33 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 445f603..ebf3b3f 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1696,17 +1696,17 @@ static int _lvskipactivation_disp(struct dm_report *rh, struct dm_pool *mem,
/* necessary for displaying something for PVs not belonging to VG */
static struct format_instance _dummy_fid = {
- .metadata_areas_in_use = { &(_dummy_fid.metadata_areas_in_use), &(_dummy_fid.metadata_areas_in_use) },
- .metadata_areas_ignored = { &(_dummy_fid.metadata_areas_ignored), &(_dummy_fid.metadata_areas_ignored) },
+ .metadata_areas_in_use = DM_LIST_HEAD_INIT(_dummy_fid.metadata_areas_in_use),
+ .metadata_areas_ignored = DM_LIST_HEAD_INIT(_dummy_fid.metadata_areas_ignored),
};
static struct volume_group _dummy_vg = {
.fid = &_dummy_fid,
.name = "",
.system_id = (char *) "",
- .pvs = { &(_dummy_vg.pvs), &(_dummy_vg.pvs) },
- .lvs = { &(_dummy_vg.lvs), &(_dummy_vg.lvs) },
- .tags = { &(_dummy_vg.tags), &(_dummy_vg.tags) },
+ .pvs = DM_LIST_HEAD_INIT(_dummy_vg.pvs),
+ .lvs = DM_LIST_HEAD_INIT(_dummy_vg.lvs),
+ .tags = DM_LIST_HEAD_INIT(_dummy_vg.tags),
};
static void *_obj_get_vg(void *obj)
diff --git a/tools/reporter.c b/tools/reporter.c
index c55d653..9688151 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -97,52 +97,42 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
{
int ret = ECMD_PROCESSED;
struct lv_segment *seg = pvseg->lvseg;
- struct lvinfo lvinfo;
+ struct lvinfo lvinfo = { .exists = 0 };
+
+ struct segment_type _freeseg_type = {
+ .cmd = cmd,
+ .name = "free",
+ .flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED,
+ };
struct volume_group _free_vg = {
.cmd = cmd,
.name = "",
- .vgmem = NULL,
+ .pvs = DM_LIST_HEAD_INIT(_free_vg.pvs),
+ .lvs = DM_LIST_HEAD_INIT(_free_vg.lvs),
+ .tags = DM_LIST_HEAD_INIT(_free_vg.tags),
};
struct logical_volume _free_logical_volume = {
.vg = vg ?: &_free_vg,
.name = "",
- .snapshot = NULL,
.status = VISIBLE_LV,
.major = -1,
.minor = -1,
+ .tags = DM_LIST_HEAD_INIT(_free_logical_volume.tags),
+ .segments = DM_LIST_HEAD_INIT(_free_logical_volume.segments),
+ .segs_using_this_lv = DM_LIST_HEAD_INIT(_free_logical_volume.segs_using_this_lv),
+ .snapshot_segs = DM_LIST_HEAD_INIT(_free_logical_volume.snapshot_segs),
};
struct lv_segment _free_lv_segment = {
.lv = &_free_logical_volume,
- .le = 0,
- .status = 0,
- .stripe_size = 0,
- .area_count = 0,
- .area_len = 0,
- .origin = NULL,
- .cow = NULL,
- .chunk_size = 0,
- .region_size = 0,
- .extents_copied = 0,
- .log_lv = NULL,
- .areas = NULL,
+ .segtype = &_freeseg_type,
+ .len = pvseg->len,
+ .tags = DM_LIST_HEAD_INIT(_free_lv_segment.tags),
+ .origin_list = DM_LIST_HEAD_INIT(_free_lv_segment.origin_list),
};
- _free_lv_segment.segtype = get_segtype_from_string(cmd, "free");
- _free_lv_segment.len = pvseg->len;
- dm_list_init(&_free_vg.pvs);
- dm_list_init(&_free_vg.lvs);
- dm_list_init(&_free_vg.tags);
- dm_list_init(&_free_lv_segment.tags);
- dm_list_init(&_free_lv_segment.origin_list);
- dm_list_init(&_free_logical_volume.tags);
- dm_list_init(&_free_logical_volume.segments);
- dm_list_init(&_free_logical_volume.segs_using_this_lv);
- dm_list_init(&_free_logical_volume.snapshot_segs);
-
- lvinfo.exists = 0;
if (seg && lv_info_needed)
_get_lv_info_for_report(cmd, seg->lv, &lvinfo);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=482e572e5de327ce…
Commit: 482e572e5de327ce3b8786215cf33e6d6223c543
Parent: a98ea95c4da5afffbacd32c519734e7daef98ea9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 22 14:30:19 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
libdm: add DM_LIST_HEAD_INIT macro
Support to initialize dm_list struct members.
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index d60b35f..5ab34c1 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.91 -
====================================
+ Add DM_LIST_HEAD_INIT macro to libdevmapper.h
Fix dm_is_dm_major to not issue error about missing /proc lines for dm module.
Version 1.02.90 - 1st September 2014
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 31574af..76c4eee 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1200,7 +1200,8 @@ struct dm_str_list {
* Initialise a list before use.
* The list head's next and previous pointers point back to itself.
*/
-#define DM_LIST_INIT(name) struct dm_list name = { &(name), &(name) }
+#define DM_LIST_HEAD_INIT(name) { &(name), &(name) }
+#define DM_LIST_INIT(name) struct dm_list name = DM_LIST_HEAD_INIT(name)
void dm_list_init(struct dm_list *head);
/*
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a98ea95c4da5afff…
Commit: a98ea95c4da5afffbacd32c519734e7daef98ea9
Parent: a2244c37764f8481fedd7d4b5f286665e9d46af2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 15:02:59 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
pool: better error message
---
lib/metadata/pool_manip.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 011d9c0..2fbadea 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -371,8 +371,8 @@ int update_pool_params(const struct segment_type *segtype,
return_0;
if ((uint64_t) *chunk_size > (uint64_t) data_extents * vg->extent_size) {
- log_error("Chunk size %s is bigger then pool data size.",
- display_size(vg->cmd, *chunk_size));
+ log_error("Size of %s data volume cannot be smaller then chunk size %s.",
+ segtype->name, display_size(vg->cmd, *chunk_size));
return 0;
}
@@ -569,6 +569,7 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
return_0;
/* FIXME: Maybe using silent mode ? */
+ log_verbose("Preparing pool metadata spare volume for Volume group %s.", vg->name);
if (!(lv = lv_create_single(vg, &lp)))
return_0;
@@ -656,6 +657,7 @@ int vg_set_pool_metadata_spare(struct logical_volume *lv)
return 0;
}
+ log_verbose("Renaming %s as pool metadata spare volume %s.", lv->name, new_name);
if (!lv_rename_update(vg->cmd, lv, new_name, 0))
return_0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2244c37764f8481…
Commit: a2244c37764f8481fedd7d4b5f286665e9d46af2
Parent: 1c7aae40a1bb1351680ec8c7afa12c2bf8b784a0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 15:03:24 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
pool: fix testmode support with pools
Allow the --test mode to proceed further.
---
WHATS_NEW | 1 +
lib/metadata/pool_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3b52595..b197568 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Better support for --test mode with pool creation.
Query lock holding LV when replacing and converting raid volumes.
Add extra validate for locked lv within validate_lv_cache_create().
Add internal lvseg_name() function.
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 4c0ab72..011d9c0 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -415,7 +415,7 @@ int create_pool(struct logical_volume *pool_lv,
if (!activation())
log_warn("WARNING: Pool %s is created without initialization.",
pool_lv->name);
- else {
+ else if (!test_mode()) {
if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
return_0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1c7aae40a1bb1351…
Commit: 1c7aae40a1bb1351680ec8c7afa12c2bf8b784a0
Parent: e901a87a69bf8573e441790ebca2ca9376aaf8a6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 10:53:56 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
raid: query lock holder
Ask for lock the proper LV.
Use the top-most LV to query for locally exclusive lock.
The rest of operations are then using 'lv_info()'
TODO:
Check all devices are reloaded from proper level.
In general any query on lv_is_active is supposed to be running
ona lv_lock_holder() volume.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 2 +-
tools/lvconvert.c | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8b9cf6f..3b52595 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Query lock holding LV when replacing and converting raid volumes.
Add extra validate for locked lv within validate_lv_cache_create().
Add internal lvseg_name() function.
Skip trying to file lock virtual internal vg name.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 8219984..5237dc9 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1555,7 +1555,7 @@ int lv_raid_replace(struct logical_volume *lv,
if (lv->status & PARTIAL_LV)
lv->vg->cmd->partial_activation = 1;
- if (!lv_is_active_exclusive_locally(lv)) {
+ if (!lv_is_active_exclusive_locally(lv_lock_holder(lv))) {
log_error("%s/%s must be active %sto perform this operation.",
lv->vg->name, lv->name,
vg_is_clustered(lv->vg) ? "exclusive locally " : "");
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index e976880..fc28846 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1902,7 +1902,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return lv_raid_replace(lv, lp->replace_pvh, lp->pvh);
if (arg_count(cmd, repair_ARG)) {
- if (!lv_is_active_exclusive_locally(lv)) {
+ if (!lv_is_active_exclusive_locally(lv_lock_holder(lv))) {
log_error("%s/%s must be active %sto perform this"
" operation.", lv->vg->name, lv->name,
vg_is_clustered(lv->vg) ?
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e901a87a69bf8573…
Commit: e901a87a69bf8573e441790ebca2ca9376aaf8a6
Parent: 6e57dbfcaa3fdc2aabe7c05f95268a35d6b198ca
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 14:53:48 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cache: better error message
---
lib/metadata/cache_manip.c | 4 ++--
tools/lvcreate.c | 21 ++++++++++-----------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 837c651..6aad50d 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -148,8 +148,8 @@ int validate_lv_cache_create(const struct logical_volume *pool_lv,
lv_is_cow(origin_lv) || lv_is_merging_cow(origin_lv) ||
lv_is_external_origin(origin_lv) ||
lv_is_virtual(origin_lv)) {
- log_error("Cache is not supported with origin LV %s type.",
- display_lvname(origin_lv));
+ log_error("Cache is not supported with %s segment type of the original logical volume %s.",
+ first_seg(origin_lv)->segtype->name, display_lvname(origin_lv));
return 0;
}
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 5a4bced..d849f93 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -61,21 +61,21 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (seg_is_cache(lp)) {
/*
- * We allowed somewhat hard to 'parse' syntax
- * (usage of lvcreate to convert LV to a cached LV).
- * So let's try to do our best to avoid wrong steps.
+ * 2 ways of cache usage for lvcreate -H -l1 vg/lv
+ *
+ * vg/lv is existing cache pool:
+ * cached LV is created using this cache pool
+ * vg/lv is not cache pool so it is cache origin
+ * origin is cached with created cache pool
*
* We are looking for the vgname or cache pool or cache origin LV.
*
- * We store the lv name in 'lp->pool', but
- * it must be accessed later (when we can look-up the
- * LV in the VG) whether it is truly the cache pool
- * or whether it is the origin for cached LV.
+ * lv name is stored in origin_name and pool_name and
+ * later with opened VG it's decided what should happen.
*/
if (!argc) {
if (!lp->pool_name) {
- /* Don't advertise we could handle cache origin */
- log_error("Please specify a logical volume to act as the cache pool.");
+ log_error("Please specify a logical volume to act as the cache pool or origin.");
return 0;
}
} else {
@@ -85,7 +85,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (!_set_vg_name(lp, vg_name))
return_0;
} else {
- /* Lets pretend it's cache origin for now */
+ /* Assume it's cache origin for now */
lp->origin_name = vg_name;
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
return_0;
@@ -94,7 +94,6 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (strcmp(lp->pool_name, lp->origin_name)) {
log_error("Unsupported syntax, cannot use cache origin %s and --cachepool %s.",
lp->origin_name, lp->pool_name);
- /* Stop here, only older form remains supported */
return 0;
}
lp->origin_name = NULL;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6e57dbfcaa3fdc2a…
Commit: 6e57dbfcaa3fdc2aabe7c05f95268a35d6b198ca
Parent: d4dab0aa34102527c32d68f69196aaabda5e3711
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 14:58:29 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cache: validate for locked
Add extra safety.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f5b7931..8b9cf6f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Add extra validate for locked lv within validate_lv_cache_create().
Add internal lvseg_name() function.
Skip trying to file lock virtual internal vg name.
Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 0a6daf6..837c651 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -104,6 +104,12 @@ int validate_lv_cache_create(const struct logical_volume *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 (origin_lv == pool_lv) {
log_error("Can't use same LV %s for cache pool and cache volume.",
display_lvname(pool_lv));
@@ -119,6 +125,12 @@ int validate_lv_cache_create(const struct logical_volume *pool_lv,
}
}
+ if (lv_is_locked(origin_lv)) {
+ log_error("Cannot use locked origin volume %s.",
+ display_lvname(origin_lv));
+ return 0;
+ }
+
/* For now we only support conversion of thin pool data volume */
if (!lv_is_visible(origin_lv) && !lv_is_thin_pool_data(origin_lv)) {
log_error("Can't convert internal LV %s.", display_lvname(origin_lv));
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4dab0aa34102527…
Commit: d4dab0aa34102527c32d68f69196aaabda5e3711
Parent: 9411c19b31b391e7be262d95fb2fa5a5162012b2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 20:09:42 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:31 2014 +0200
cleanup: drop default implementation
Now we reference segment name via lvseg_name() and
we can drop default implementation and leave its
function pointer to be NULL.
Default give us 'return seg->segtype->name'.
---
lib/cache_segtype/cache.c | 7 -------
lib/error/errseg.c | 6 ------
lib/freeseg/freeseg.c | 6 ------
lib/mirror/mirrored.c | 6 ------
lib/raid/raid.c | 8 +-------
lib/replicator/replicator.c | 6 ------
lib/snapshot/snapshot.c | 8 +-------
lib/thin/thin.c | 12 ------------
lib/unknown/unknown.c | 7 -------
lib/zero/zero.c | 6 ------
10 files changed, 2 insertions(+), 70 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index ddaf3cf..9927688 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -31,11 +31,6 @@
dm_config_parent_name(sn), seg->lv->name), 0;
-static const char *_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static int _cache_pool_text_import(struct lv_segment *seg,
const struct dm_config_node *sn,
struct dm_hash_table *pv_hash __attribute__((unused)))
@@ -262,7 +257,6 @@ static int _modules_needed(struct dm_pool *mem,
#endif /* DEVMAPPER_SUPPORT */
static struct segtype_handler _cache_pool_ops = {
- .name = _name,
.text_import = _cache_pool_text_import,
.text_import_area_count = _cache_pool_text_import_area_count,
.text_export = _cache_pool_text_export,
@@ -365,7 +359,6 @@ static int _cache_add_target_line(struct dev_manager *dm,
#endif /* DEVMAPPER_SUPPORT */
static struct segtype_handler _cache_ops = {
- .name = _name,
.text_import = _cache_text_import,
.text_import_area_count = _cache_text_import_area_count,
.text_export = _cache_text_export,
diff --git a/lib/error/errseg.c b/lib/error/errseg.c
index f3bf9c9..af19e7d 100644
--- a/lib/error/errseg.c
+++ b/lib/error/errseg.c
@@ -21,11 +21,6 @@
#include "activate.h"
#include "str_list.h"
-static const char *_errseg_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static int _errseg_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
{
seg1->len += seg2->len;
@@ -83,7 +78,6 @@ static void _errseg_destroy(struct segment_type *segtype)
}
static struct segtype_handler _error_ops = {
- .name = _errseg_name,
.merge_segments = _errseg_merge_segments,
#ifdef DEVMAPPER_SUPPORT
.add_target_line = _errseg_add_target_line,
diff --git a/lib/freeseg/freeseg.c b/lib/freeseg/freeseg.c
index 1dce243..b4eba94 100644
--- a/lib/freeseg/freeseg.c
+++ b/lib/freeseg/freeseg.c
@@ -16,18 +16,12 @@
#include "toolcontext.h"
#include "segtype.h"
-static const char *_freeseg_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static void _freeseg_destroy(struct segment_type *segtype)
{
dm_free(segtype);
}
static struct segtype_handler _freeseg_ops = {
- .name = _freeseg_name,
.destroy = _freeseg_destroy,
};
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 411b4d4..46dfe02 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -38,11 +38,6 @@ struct mirror_state {
uint32_t default_region_size;
};
-static const char *_mirrored_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static void _mirrored_display(const struct lv_segment *seg)
{
const char *size;
@@ -592,7 +587,6 @@ static void _mirrored_destroy(struct segment_type *segtype)
}
static struct segtype_handler _mirrored_ops = {
- .name = _mirrored_name,
.display = _mirrored_display,
.text_import_area_count = _mirrored_text_import_area_count,
.text_import = _mirrored_text_import,
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 6628dc8..7cc4301 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -25,11 +25,6 @@
#include "metadata.h"
#include "lv_alloc.h"
-static const char *_raid_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static void _raid_display(const struct lv_segment *seg)
{
unsigned s;
@@ -243,7 +238,7 @@ static int _raid_add_target_line(struct dev_manager *dm __attribute__((unused)),
if (mirror_in_sync())
flags = DM_NOSYNC;
- params.raid_type = _raid_name(seg);
+ params.raid_type = lvseg_name(seg);
if (seg->segtype->parity_devs) {
/* RAID 4/5/6 */
params.mirrors = 1;
@@ -418,7 +413,6 @@ static int _raid_target_unmonitor_events(struct lv_segment *seg, int events)
#endif /* DEVMAPPER_SUPPORT */
static struct segtype_handler _raid_ops = {
- .name = _raid_name,
.display = _raid_display,
.text_import_area_count = _raid_text_import_area_count,
.text_import = _raid_text_import,
diff --git a/lib/replicator/replicator.c b/lib/replicator/replicator.c
index 2e3632a..ae87d7f 100644
--- a/lib/replicator/replicator.c
+++ b/lib/replicator/replicator.c
@@ -39,10 +39,6 @@
/*
* Replicator target
*/
-static const char *_replicator_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
/* FIXME: missing implementation */
static void _replicator_display(const struct lv_segment *seg)
@@ -410,7 +406,6 @@ static void _replicator_destroy(struct segment_type *segtype)
}
static struct segtype_handler _replicator_ops = {
- .name = _replicator_name,
.display = _replicator_display,
.text_import = _replicator_text_import,
.text_export = _replicator_text_export,
@@ -739,7 +734,6 @@ static int _replicator_dev_target_present(struct cmd_context *cmd,
#endif
static struct segtype_handler _replicator_dev_ops = {
- .name = _replicator_name,
.display = _replicator_dev_display,
.text_import = _replicator_dev_text_import,
.text_export = _replicator_dev_text_export,
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 0557f45..18e8111 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -25,18 +25,13 @@
log_error(t " segment %s of logical volume %s.", ## p, \
dm_config_parent_name(sn), seg->lv->name), 0;
-static const char *_snap_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static const char *_snap_target_name(const struct lv_segment *seg,
const struct lv_activate_opts *laopts)
{
if (!laopts->no_merging && (seg->status & MERGING))
return "snapshot-merge";
- return _snap_name(seg);
+ return lvseg_name(seg);
}
static int _snap_text_import(struct lv_segment *seg, const struct dm_config_node *sn,
@@ -234,7 +229,6 @@ static void _snap_destroy(struct segment_type *segtype)
}
static struct segtype_handler _snapshot_ops = {
- .name = _snap_name,
.target_name = _snap_target_name,
.text_import = _snap_text_import,
.text_export = _snap_text_export,
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 6982782..9ae237e 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -36,11 +36,6 @@ static const char _thin_module[] = "thin";
/* TODO: using static field here, maybe should be a part of segment_type */
static unsigned _feature_mask;
-static const char *_thin_pool_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static void _thin_pool_display(const struct lv_segment *seg)
{
log_print(" Chunk size\t\t%s",
@@ -449,11 +444,6 @@ static int _target_unregister_events(struct lv_segment *seg,
# endif /* DMEVENTD */
#endif /* DEVMAPPER_SUPPORT */
-static const char *_thin_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static void _thin_display(const struct lv_segment *seg)
{
log_print(" Device ID\t\t%u", seg->device_id);
@@ -720,7 +710,6 @@ static void _thin_destroy(struct segment_type *segtype)
}
static struct segtype_handler _thin_pool_ops = {
- .name = _thin_pool_name,
.display = _thin_pool_display,
.text_import = _thin_pool_text_import,
.text_import_area_count = _thin_pool_text_import_area_count,
@@ -740,7 +729,6 @@ static struct segtype_handler _thin_pool_ops = {
};
static struct segtype_handler _thin_ops = {
- .name = _thin_name,
.display = _thin_display,
.text_import = _thin_text_import,
.text_export = _thin_text_export,
diff --git a/lib/unknown/unknown.c b/lib/unknown/unknown.c
index 2ce2f9d..760f1c2 100644
--- a/lib/unknown/unknown.c
+++ b/lib/unknown/unknown.c
@@ -18,12 +18,6 @@
#include "text_export.h"
#include "config.h"
-static const char *_unknown_name(const struct lv_segment *seg)
-{
-
- return seg->segtype->name;
-}
-
static int _unknown_text_import(struct lv_segment *seg, const struct dm_config_node *sn,
struct dm_hash_table *pv_hash)
{
@@ -59,7 +53,6 @@ static void _unknown_destroy(struct segment_type *segtype)
}
static struct segtype_handler _unknown_ops = {
- .name = _unknown_name,
.text_import = _unknown_text_import,
.text_export = _unknown_text_export,
.destroy = _unknown_destroy,
diff --git a/lib/zero/zero.c b/lib/zero/zero.c
index 2a1fd0b..9f9d06c 100644
--- a/lib/zero/zero.c
+++ b/lib/zero/zero.c
@@ -19,11 +19,6 @@
#include "str_list.h"
#include "activate.h"
-static const char *_zero_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
-
static int _zero_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
{
seg1->len += seg2->len;
@@ -79,7 +74,6 @@ static void _zero_destroy(struct segment_type *segtype)
}
static struct segtype_handler _zero_ops = {
- .name = _zero_name,
.merge_segments = _zero_merge_segments,
#ifdef DEVMAPPER_SUPPORT
.add_target_line = _zero_add_target_line,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9411c19b31b391e7…
Commit: 9411c19b31b391e7be262d95fb2fa5a5162012b2
Parent: ab940456931ea5a5a6f29f63d1b27057df3fdf75
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 20 18:40:39 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:30 2014 +0200
segments: introduce lvseg_name
Instead of segtype->ops->name() introduce lvseg_name().
This also allows us to leave name() function 'empty' for default
return of segtype->name.
TODO: add functions for rest of ops->
---
WHATS_NEW | 1 +
lib/display/display.c | 2 +-
lib/metadata/lv.c | 12 +++++++++++-
lib/metadata/lv.h | 1 +
lib/metadata/lv_manip.c | 2 +-
lib/metadata/merge.c | 3 +--
lib/metadata/pool_manip.c | 6 +++---
lib/metadata/raid_manip.c | 14 +++++++-------
lib/report/report.c | 2 +-
tools/lvchange.c | 2 +-
tools/lvconvert.c | 9 ++++-----
11 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4d2a6d2..f5b7931 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Add internal lvseg_name() function.
Skip trying to file lock virtual internal vg name.
Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
Fix lv_permissions reporting to display read-only{-override} instead of blank.
diff --git a/lib/display/display.c b/lib/display/display.c
index d12c393..f86b67f 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -667,7 +667,7 @@ int lvdisplay_segments(const struct logical_volume *lv)
lv_is_virtual(lv) ? "Virtual" : "Logical",
seg->le, seg->le + seg->len - 1);
- log_print(" Type\t\t%s", seg->segtype->ops->name(seg));
+ log_print(" Type\t\t%s", lvseg_name(seg));
if (seg->segtype->ops->target_monitored)
log_print(" Monitoring\t\t%s",
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 23f0991..92b38f4 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -120,7 +120,7 @@ char *lvseg_tags_dup(const struct lv_segment *seg)
char *lvseg_segtype_dup(struct dm_pool *mem, const struct lv_segment *seg)
{
- return dm_pool_strdup(mem, seg->segtype->ops->name(seg));
+ return dm_pool_strdup(mem, lvseg_name(seg));
}
char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
@@ -183,6 +183,16 @@ uint64_t lvseg_chunksize(const struct lv_segment *seg)
return size;
}
+const char *lvseg_name(const struct lv_segment *seg)
+{
+ /* Support even segtypes without 'ops' */
+ if (seg->segtype->ops &&
+ seg->segtype->ops->name)
+ return seg->segtype->ops->name(seg);
+
+ return seg->segtype->name;
+}
+
uint64_t lvseg_start(const struct lv_segment *seg)
{
return (uint64_t) seg->le * seg->lv->vg->extent_size;
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index bcd7028..2261913 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -77,6 +77,7 @@ struct logical_volume *lv_parent(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
+const char *lvseg_name(const struct lv_segment *seg);
uint64_t lvseg_start(const struct lv_segment *seg);
uint64_t lvseg_size(const struct lv_segment *seg);
uint64_t lvseg_chunksize(const struct lv_segment *seg);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f14cec0..f60b964 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4617,7 +4617,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
else if (seg_is_raid(first_seg(lv)) &&
(lp->stripes != seg_stripes)) {
log_error("Unable to extend \"%s\" segment type with different number of stripes.",
- first_seg(lv)->segtype->ops->name(first_seg(lv)));
+ lvseg_name(first_seg(lv)));
return 0;
}
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index ad918f1..c8c9543 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -481,8 +481,7 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
if (!seg_can_split(seg)) {
log_error("Unable to split the %s segment at LE %" PRIu32
- " in LV %s", seg->segtype->ops->name(seg),
- le, lv->name);
+ " in LV %s", lvseg_name(seg), le, lv->name);
return 0;
}
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 439b8ed..4c0ab72 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -33,7 +33,7 @@ int attach_pool_metadata_lv(struct lv_segment *pool_seg,
if (!seg_is_pool(pool_seg)) {
log_error(INTERNAL_ERROR
"Unable to attach pool metadata LV to %s segtype.",
- pool_seg->segtype->ops->name(pool_seg));
+ lvseg_name(pool_seg));
return 0;
}
pool_seg->metadata_lv = metadata_lv;
@@ -70,7 +70,7 @@ int attach_pool_data_lv(struct lv_segment *pool_seg,
if (!seg_is_pool(pool_seg)) {
log_error(INTERNAL_ERROR
"Unable to attach pool data LV to %s segtype.",
- pool_seg->segtype->ops->name(pool_seg));
+ lvseg_name(pool_seg));
return 0;
}
@@ -129,7 +129,7 @@ int detach_pool_lv(struct lv_segment *seg)
if (!seg->pool_lv) {
log_error(INTERNAL_ERROR
"No pool associated with %s LV, %s.",
- seg->segtype->ops->name(seg), seg->lv->name);
+ lvseg_name(seg), seg->lv->name);
return 0;
}
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 44272e8..8219984 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -117,7 +117,7 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
if (!seg_is_mirrored(seg)) {
log_error(INTERNAL_ERROR
"Unable to remove RAID layer from segment type %s",
- seg->segtype->ops->name(seg));
+ lvseg_name(seg));
return 0;
}
@@ -579,7 +579,7 @@ static int _raid_add_images(struct logical_volume *lv,
dm_list_add(&meta_lvs, &lvl->list);
} else if (!seg_is_raid(seg)) {
log_error("Unable to add RAID images to %s of segment type %s",
- lv->name, seg->segtype->ops->name(seg));
+ lv->name, lvseg_name(seg));
return 0;
}
@@ -1075,7 +1075,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
if (!seg_is_mirrored(first_seg(lv)) ||
!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID10)) {
log_error("Unable to split logical volume of segment type, %s",
- first_seg(lv)->segtype->ops->name(first_seg(lv)));
+ lvseg_name(first_seg(lv)));
return 0;
}
@@ -1445,7 +1445,7 @@ int lv_raid_reshape(struct logical_volume *lv,
log_error("Converting the segment type for %s/%s from %s to %s"
" is not yet supported.", lv->vg->name, lv->name,
- seg->segtype->ops->name(seg), new_segtype->name);
+ lvseg_name(seg), new_segtype->name);
return 0;
}
@@ -1601,7 +1601,7 @@ int lv_raid_replace(struct logical_volume *lv,
(match_count > raid_seg->segtype->parity_devs)) {
log_error("Unable to replace more than %u PVs from (%s) %s/%s",
raid_seg->segtype->parity_devs,
- raid_seg->segtype->ops->name(raid_seg),
+ lvseg_name(raid_seg),
lv->vg->name, lv->name);
return 0;
} else if (!strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID10)) {
@@ -1790,7 +1790,7 @@ int lv_raid_remove_missing(struct logical_volume *lv)
return_0;
log_debug("Attempting to remove missing devices from %s LV, %s",
- seg->segtype->ops->name(seg), lv->name);
+ lvseg_name(seg), lv->name);
/*
* FIXME: Make sure # of compromised components will not affect RAID
@@ -1870,7 +1870,7 @@ static int _partial_raid_lv_is_redundant(const struct logical_volume *lv)
(failed_components > raid_seg->segtype->parity_devs)) {
log_verbose("More than %u components from %s %s have failed.",
raid_seg->segtype->parity_devs,
- raid_seg->segtype->ops->name(raid_seg),
+ lvseg_name(raid_seg),
display_lvname(lv));
return 0; /* Insufficient redundancy to activate */
}
diff --git a/lib/report/report.c b/lib/report/report.c
index e85c349..445f603 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -366,7 +366,7 @@ static int _segtype_disp(struct dm_report *rh __attribute__((unused)),
char *name;
if (!(name = lvseg_segtype_dup(mem, seg))) {
- log_error("Failed to get segtype.");
+ log_error("Failed to get segtype name.");
return 0;
}
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 114065c..6cb6f15 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -355,7 +355,7 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
vg_is_clustered(lv->vg) ? "clustered " : "",
(seg->log_lv) ? "disk-logged " :
seg_is_raid(seg) ? "" : "core-logged ",
- seg->segtype->ops->name(seg), lv->name);
+ lvseg_name(seg), lv->name);
/*
* If this mirror has a core log (i.e. !seg->log_lv),
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ad4a6c0..e976880 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1850,7 +1850,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (arg_count(cmd, mirrors_ARG) &&
!seg_is_mirrored(seg) && !seg_is_linear(seg)) {
log_error("'--mirrors/-m' is not compatible with %s",
- seg->segtype->ops->name(seg));
+ lvseg_name(seg));
return 0;
}
@@ -1860,7 +1860,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (!_is_valid_raid_conversion(seg->segtype, lp->segtype)) {
log_error("Unable to convert %s/%s from %s to %s",
lv->vg->name, lv->name,
- seg->segtype->ops->name(seg), lp->segtype->name);
+ lvseg_name(seg), lp->segtype->name);
return 0;
}
@@ -2672,7 +2672,7 @@ static int _lvconvert_thin(struct cmd_context *cmd,
lv_is_thin_pool_data(lv) ||
lv_is_thin_pool_metadata(lv)) {
log_error("Can't use %s %s as external origin.",
- first_seg(lv)->segtype->name,
+ lvseg_name(first_seg(lv)),
display_lvname(lv));
return 0;
}
@@ -3294,8 +3294,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, use_policies_ARG))
return ECMD_PROCESSED; /* nothing to be done here */
log_error("Can't repair LV \"%s\" of segtype %s.",
- lv->name,
- first_seg(lv)->segtype->ops->name(first_seg(lv)));
+ lv->name, lvseg_name(first_seg(lv)));
return ECMD_FAILED;
}
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ab940456931ea5a5…
Commit: ab940456931ea5a5a6f29f63d1b27057df3fdf75
Parent: 9351dca86393f862a6b2c270d5869407a4614d8a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 21 14:47:46 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 24 16:39:30 2014 +0200
file-locking: skip locking of VG_SYNC_NAMES
VG_SYNC_NAMES is internal name with different meaning,
there is no point to search it in cache.
---
WHATS_NEW | 1 +
lib/locking/file_locking.c | 9 ++++-----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 38a4d1b..4d2a6d2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Skip trying to file lock virtual internal vg name.
Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
Fix lv_permissions reporting to display read-only{-override} instead of blank.
Fix liblvm2cmd and lvm shell to respect quotes around args in cmd line string.
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 5fd0ed3..0595752 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -60,12 +60,11 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
return_0;
break;
case LCK_VG:
- /* Skip cache refresh for VG_GLOBAL - the caller handles it */
- if (strcmp(resource, VG_GLOBAL))
- lvmcache_drop_metadata(resource, 0);
-
- if (!strcmp(resource, VG_SYNC_NAMES))
+ if (!strcmp(resource, VG_SYNC_NAMES)) {
fs_unlock();
+ } else if (strcmp(resource, VG_GLOBAL))
+ /* Skip cache refresh for VG_GLOBAL - the caller handles it */
+ lvmcache_drop_metadata(resource, 0);
/* LCK_CACHE does not require a real lock */
if (flags & LCK_CACHE)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9351dca86393f862…
Commit: 9351dca86393f862a6b2c270d5869407a4614d8a
Parent: 4b611bb816eef3e363e005b48b881e933c3de9e2
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Oct 23 15:03:04 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Oct 23 15:03:04 2014 +0200
report: fix selection on {vg,lv}_permissions fields to properly match selection criteria
There was a bug in value and their synonym definition for these two fields
causing selections on these fields to not work correctly - nothing matched
against vg/lv_permissions fields even if selection criteria should have
matched.
Scenario:
$ lvs -o name,lv_permissions vg
LV LPerms
lvol0 read-only
lvol1 writeable
Before this patch:
$ lvs -o name,lv_permissions vg -S 'permissions=read-only'
(blank)
$ lvs -o name,lv_permissions vg -S 'permissions=writeable
(blank)
With this patch applied:
$ lvs -o name,lv_permissions vg -S 'permissions=read-only'
LV LPerms
lvol0 read-only
$ lvs -o name,lv_permissions vg -S 'permissions=writeable'
LV LPerms
lvol1 writeable
Also synonyms match correctly now:
$ lvs -o name,lv_permissions vg -S 'permissions=rw'
LV LPerms
lvol1 writeable
---
WHATS_NEW | 1 +
lib/report/report.c | 10 +++++-----
lib/report/values.h | 14 +++++++-------
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2d644c5..38a4d1b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
Fix lv_permissions reporting to display read-only{-override} instead of blank.
Fix liblvm2cmd and lvm shell to respect quotes around args in cmd line string.
Permit extent sizes > 128KB that are not power of 2 with lvm2 format.
diff --git a/lib/report/report.c b/lib/report/report.c
index 3f63e1c..e85c349 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -92,11 +92,11 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
#define FIELD_RESERVED_VALUE(field_id, id, desc, value, ...) \
static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \
- static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, &value};
+ static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, value};
#define FIELD_RESERVED_BINARY_VALUE(field_id, id, desc, ...) \
- FIELD_RESERVED_VALUE(field_id, id ## _y, desc, _one64, __VA_ARGS__, _str_yes) \
- FIELD_RESERVED_VALUE(field_id, id ## _n, desc, _zero64, __VA_ARGS__, _str_no)
+ FIELD_RESERVED_VALUE(field_id, id ## _y, desc, &_one64, __VA_ARGS__, _str_yes) \
+ FIELD_RESERVED_VALUE(field_id, id ## _n, desc, &_zero64, __VA_ARGS__, _str_no)
#include "values.h"
@@ -119,8 +119,8 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
#define FIELD_RESERVED_VALUE(field_id, id, desc, value, ...) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, desc},
#define FIELD_RESERVED_BINARY_VALUE(field_id, id, desc, ...) \
- FIELD_RESERVED_VALUE(field_id, id ## _y, desc, _one64, __VA_ARGS__) \
- FIELD_RESERVED_VALUE(field_id, id ## _n, desc, _zero64, __VA_ARGS__)
+ FIELD_RESERVED_VALUE(field_id, id ## _y, desc, &_one64, __VA_ARGS__) \
+ FIELD_RESERVED_VALUE(field_id, id ## _n, desc, &_zero64, __VA_ARGS__)
static const struct dm_report_reserved_value _report_reserved_values[] = {
#include "values.h"
diff --git a/lib/report/values.h b/lib/report/values.h
index fb368d4..f909ce9 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -54,9 +54,9 @@ FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "", "extendable")
FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "", "exported")
FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "", "partial")
FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "", "clustered")
-FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, "", FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read-write")
-FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, "", FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, "", RESERVED(number_undef_64), "unmanaged")
+FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, "", "writeable", "writeable", "rw", "read-write")
+FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, "", "read-only", "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, "", &RESERVED(number_undef_64), "unmanaged")
/* Reserved values for LV fields */
FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "", "initial image sync", "sync")
@@ -76,9 +76,9 @@ FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "", "inactive
FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "", "open")
FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "", "skip activation", "skip")
FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
-FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, "", RESERVED(number_undef_64), "auto")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", "writeable", "writeable", "rw", "read-write")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", "read-only", "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", "read-only-override", "read-only-override", "ro-override", "r-override", "R")
+FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, "", &RESERVED(number_undef_64), "auto")
/* *INDENT-ON* */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4b611bb816eef3e3…
Commit: 4b611bb816eef3e363e005b48b881e933c3de9e2
Parent: 2c8e7821c31245e3f7c1d56a67eb7f38d4b37001
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Oct 23 10:18:29 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Oct 23 10:18:29 2014 +0200
report: lv_permissions: display read-only/read-only-override instead of blank when LV is not writeable
Before this patch:
$ lvs -o name,lv_attr,lv_permissions
LV Attr LPerms
root -wi-ao---- writeable
swap -wi-ao---- writeable
lvol0 -Ri-a-----
lvol1 -ri-a-----
lvol2 -wi-a----- writeable
lvol3 -ri-------
With this patch applied:
$ lvs -o name,lv_attr,lv_permissions
LV Attr LPerms
root -wi-ao---- writeable
swap -wi-ao---- writeable
lvol0 -Ri-a----- read-only-override
lvol1 -ri-a----- read-only
lvol2 -wi-a----- writeable
lvol3 -ri------- read-only
("read-only-override" is displayed if the "writeable" permission
is overriden based on "activation/read_only_volume_list" lvm.conf
setting)
---
WHATS_NEW | 1 +
lib/report/values.h | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0d4487e..2d644c5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix lv_permissions reporting to display read-only{-override} instead of blank.
Fix liblvm2cmd and lvm shell to respect quotes around args in cmd line string.
Permit extent sizes > 128KB that are not power of 2 with lvm2 format.
Remove workaround for lvm2-monitor.service hang on stop if lvmetad stopped.
diff --git a/lib/report/values.h b/lib/report/values.h
index 7425bc6..fb368d4 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -77,8 +77,8 @@ FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "", "open")
FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "", "skip activation", "skip")
FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", FIRST_NAME(lv_permissions_r), "", "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", FIRST_NAME(lv_permissions_r_override), "", "read-only-override", "ro-override", "r-override", "R")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, "", RESERVED(number_undef_64), "auto")
/* *INDENT-ON* */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2c8e7821c31245e3…
Commit: 2c8e7821c31245e3f7c1d56a67eb7f38d4b37001
Parent: 4988d799a26032bfde4888d55080f5d42f5d55c1
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Oct 22 09:02:17 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Oct 22 09:03:26 2014 +0200
NIX: Fix 32b builds (2G of RAM is 1M too much for 32b QEMU).
---
nix/default.nix | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index 6ef339b..abd3d01 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -13,7 +13,7 @@ let
fullName = "LVM2";
src = jobs.tarball;
diskImage = diskFun { extraPackages = extras; };
- memSize = 2048;
+ memSize = 2047;
# fc16 lcov is broken and el6 has none... be creative
prepareImagePhase = ''
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4988d799a26032bf…
Commit: 4988d799a26032bfde4888d55080f5d42f5d55c1
Parent: a6c294c5d0b989c3a881c8d084291aaf97fa3ac8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 17 13:55:06 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 17 14:03:43 2014 +0200
liblvm2cmd: recognize quotes properly when splitting cmd line string into argv array fields
Fix lvm_split that is called when cmd line string is separated into
argv fields to recognize quote chars ('\'" and '"') properly and
when these quotes are used, consider the text within quotes as one
argument, do not separate it based on space characters inside.
The lvm_split is used during processing lvm shell command line or
when calling lvm commands through cmdlib (e.g. dmeventd plugins).
For example, the lvm shell scenario:
Before this patch:
$lvm
lvm> lvs --config 'global{ suffix=0 }'
Parse error at byte 9 (line 1): unexpected token
Failed to set overridden configuration entries.
With this patch applied:
$lvm
lvm> lvs --config 'global{ suffix=0 }'
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root fedora -wi-ao---- 9.00g
swap fedora -wi-ao---- 512.00m
(Exactly the same problem is hit when calling LVM commands with
quoted arguments via lvm2cmd lib in dmeventd plugins.)
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d7a00fe..0d4487e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix liblvm2cmd and lvm shell to respect quotes around args in cmd line string.
Permit extent sizes > 128KB that are not power of 2 with lvm2 format.
Remove workaround for lvm2-monitor.service hang on stop if lvmetad stopped.
Change vgremove to use process_each_lv_in_vg.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 4697b24..4c61332 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1407,6 +1407,7 @@ int lvm_split(char *str, int *argc, char **argv, int max)
{
char *b = str, *e;
*argc = 0;
+ char quote = 0;
while (*b) {
while (*b && isspace(*b))
@@ -1415,14 +1416,20 @@ int lvm_split(char *str, int *argc, char **argv, int max)
if ((!*b) || (*b == '#'))
break;
+ if (*b == '\'' || *b == '"') {
+ quote = *b;
+ b++;
+ }
+
e = b;
- while (*e && !isspace(*e))
+ while (*e && (quote ? *e != quote : !isspace(*e)))
e++;
argv[(*argc)++] = b;
if (!*e)
break;
*e++ = '\0';
+ quote = 0;
b = e;
if (*argc == max)
break;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a6c294c5d0b989c3…
Commit: a6c294c5d0b989c3a881c8d084291aaf97fa3ac8
Parent: 23a38d242bcc1187aa6ef36383311d789d43c82d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 16 15:15:36 2014 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 16 15:16:52 2014 -0500
toollib: remove unsed variable in process_each_segment_in_pv
Was left unused from the last change to this function.
---
tools/toollib.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index eba9a37..f81acca 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -191,7 +191,6 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
process_single_pvseg_fn_t process_single_pvseg)
{
struct pv_segment *pvseg;
- struct pv_list *pvl;
int ret_max = ECMD_PROCESSED;
int ret;
struct pv_segment _free_pv_segment = { .pv = pv };
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=23a38d242bcc1187…
Commit: 23a38d242bcc1187aa6ef36383311d789d43c82d
Parent: 4461c624bc59ddca60f4bbf1eb447d64c8d4aeb2
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Oct 15 15:45:38 2014 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Oct 15 15:47:45 2014 -0500
toollib: remove dead code
Because of the recent change to process_each_pv(), the vg is always
provided when the pv is in a vg. is_pv(pv) means the pv is in a vg,
which means that the vg arg will not be NULL, which means the removed
block of code is not needed.
---
tools/toollib.c | 34 ++--------------------------------
1 files changed, 2 insertions(+), 32 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 7f656c6..eba9a37 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -192,41 +192,15 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
{
struct pv_segment *pvseg;
struct pv_list *pvl;
- const char *vg_name = NULL;
int ret_max = ECMD_PROCESSED;
int ret;
- struct volume_group *old_vg = vg;
struct pv_segment _free_pv_segment = { .pv = pv };
- if (is_pv(pv) && !vg && !is_orphan(pv)) {
- vg_name = pv_vg_name(pv);
-
- vg = vg_read(cmd, vg_name, NULL, 0);
- if (ignore_vg(vg, vg_name, 0, &ret_max)) {
- release_vg(vg);
- stack;
- return ret_max;
- }
-
- /*
- * Replace possibly incomplete PV structure with new one
- * allocated in vg_read_internal() path.
- */
- if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
- log_error("Unable to find %s in volume group %s",
- pv_dev_name(pv), vg_name);
- unlock_and_release_vg(cmd, vg, vg_name);
- return ECMD_FAILED;
- }
-
- pv = pvl->pv;
- }
-
if (dm_list_empty(&pv->segments)) {
ret = process_single_pvseg(cmd, NULL, &_free_pv_segment, handle);
if (ret > ret_max)
ret_max = ret;
- } else
+ } else {
dm_list_iterate_items(pvseg, &pv->segments) {
if (sigint_caught()) {
ret_max = ECMD_FAILED;
@@ -237,11 +211,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
if (ret > ret_max)
ret_max = ret;
}
-
- if (vg_name)
- unlock_vg(cmd, vg_name);
- if (!old_vg)
- release_vg(vg);
+ }
return ret_max;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4461c624bc59ddca…
Commit: 4461c624bc59ddca60f4bbf1eb447d64c8d4aeb2
Parent: 5e6e2d6b1b984b83929dd23e75c0512e564d184f
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 14 19:06:26 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 14 21:07:00 2014 +0200
NIX: Give the VMs 2G of RAM (for tmpfs) until the new runner is merged.
---
nix/default.nix | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index 228047f..6ef339b 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -13,7 +13,7 @@ let
fullName = "LVM2";
src = jobs.tarball;
diskImage = diskFun { extraPackages = extras; };
- memSize = 768;
+ memSize = 2048;
# fc16 lcov is broken and el6 has none... be creative
prepareImagePhase = ''
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5e6e2d6b1b984b83…
Commit: 5e6e2d6b1b984b83929dd23e75c0512e564d184f
Parent: 02628413ca99648e70e38406384be69e20a2a6ce
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Oct 14 18:12:15 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Oct 14 18:12:15 2014 +0100
vgcreate: Permit non-power-of-2 extent sizes.
Relax validation to permit extent sizes > 128KB that are not powers of 2
with lvm2 format. Existing code was already capable of handling this.
---
WHATS_NEW | 1 +
lib/format1/disk-rep.h | 2 -
lib/format1/format1.c | 21 +------
lib/format_text/format-text.c | 14 +++--
lib/metadata/metadata-exported.h | 2 +
lib/metadata/metadata.h | 2 +
lib/metadata/vg.c | 124 ++++++++++++++++++++++++--------------
lib/metadata/vg.h | 1 +
man/vgchange.8.in | 9 ++-
man/vgcreate.8.in | 9 ++-
tools/vgconvert.c | 3 +
11 files changed, 107 insertions(+), 81 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2a0adf4..d7a00fe 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Permit extent sizes > 128KB that are not power of 2 with lvm2 format.
Remove workaround for lvm2-monitor.service hang on stop if lvmetad stopped.
Change vgremove to use process_each_lv_in_vg.
Introduce WARN_ flags to control some metadata warning messages.
diff --git a/lib/format1/disk-rep.h b/lib/format1/disk-rep.h
index 43e2e57..729601e 100644
--- a/lib/format1/disk-rep.h
+++ b/lib/format1/disk-rep.h
@@ -26,8 +26,6 @@
#define LVM_BLK_MAJOR 58
#define MAX_PV_SIZE ((uint32_t) -1) /* 2TB in sectors - 1 */
-#define MIN_PE_SIZE (8192L >> SECTOR_SHIFT) /* 8 KB in sectors */
-#define MAX_PE_SIZE (16L * 1024L * (1024L >> SECTOR_SHIFT) * 1024L)
#define PE_SIZE_PV_SIZE_REL 5 /* PV size must be at least 5 times PE size */
#define MAX_LE_TOTAL 65534 /* 2^16 - 2 */
#define MAX_PE_TOTAL ((uint32_t) -2)
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 8ee2f48..b0943b1 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -493,25 +493,8 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
if (!vg->max_pv || vg->max_pv >= MAX_PV)
vg->max_pv = MAX_PV - 1;
- if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
- log_error("Extent size must be between %s and %s",
- display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE),
- display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE));
-
- return 0;
- }
-
- if (vg->extent_size % MIN_PE_SIZE) {
- log_error("Extent size must be multiple of %s",
- display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE));
- return 0;
- }
-
- /* Redundant? */
- if (vg->extent_size & (vg->extent_size - 1)) {
- log_error("Extent size must be power of 2");
- return 0;
- }
+ if (!vg_check_new_extent_size(vg->fid->fmt, vg->extent_size))
+ return_0;
return 1;
}
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 9b894fa..c142e1b 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -72,13 +72,14 @@ void rlocn_set_ignored(struct raw_locn *rlocn, unsigned mda_ignored)
* NOTE: Currently there can be only one vg per text file.
*/
-static int _text_vg_setup(struct format_instance *fid __attribute__((unused)),
+/*
+ * Only used by vgcreate.
+ */
+static int _text_vg_setup(struct format_instance *fid,
struct volume_group *vg)
{
- if (vg->extent_size & (vg->extent_size - 1)) {
- log_error("Extent size must be power of 2");
- return 0;
- }
+ if (!vg_check_new_extent_size(vg->fid->fmt, vg->extent_size))
+ return_0;
return 1;
}
@@ -2440,7 +2441,8 @@ struct format_type *create_text_format(struct cmd_context *cmd)
fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_TEXT_NAME);
fmt->features = FMT_SEGMENTS | FMT_MDAS | FMT_TAGS | FMT_PRECOMMIT |
FMT_UNLIMITED_VOLS | FMT_RESIZE_PV |
- FMT_UNLIMITED_STRIPESIZE | FMT_BAS | FMT_CONFIG_PROFILE;
+ FMT_UNLIMITED_STRIPESIZE | FMT_BAS | FMT_CONFIG_PROFILE |
+ FMT_NON_POWER2_EXTENTS;
if (!(mda_lists = dm_malloc(sizeof(struct mda_lists)))) {
log_error("Failed to allocate dir_list");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 0d8db7d..bf6f1c1 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -35,6 +35,7 @@
#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
#define MAX_EXTENT_SIZE ((uint32_t) -1)
+#define MIN_NON_POWER2_EXTENT_SIZE (128U * 2U) /* 128KB in sectors */
/* Layer suffix */
#define MIRROR_SYNC_LAYER "_mimagetmp"
@@ -132,6 +133,7 @@
#define FMT_BAS 0x000000400U /* Supports bootloader areas? */
#define FMT_CONFIG_PROFILE 0x000000800U /* Supports configuration profiles? */
#define FMT_OBSOLETE 0x000001000U /* Obsolete format? */
+#define FMT_NON_POWER2_EXTENTS 0x000002000U /* Non-power-of-2 extent sizes? */
/* Mirror conversion type flags */
#define MIRROR_BY_SEG 0x00000001U /* segment-by-segment mirror */
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index f847ddb..1dd8867 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -33,6 +33,8 @@
//#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
//#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
//#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
+#define MIN_PE_SIZE (8192L >> SECTOR_SHIFT) /* 8 KB in sectors - format1 only */
+#define MAX_PE_SIZE (16L * 1024L * (1024L >> SECTOR_SHIFT) * 1024L) /* format1 only */
#define MIRROR_LOG_OFFSET 2 /* sectors */
#define VG_MEMPOOL_CHUNK 10240 /* in bytes, hint only */
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 7b6cb85..71b894b 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -278,18 +278,18 @@ char *vg_profile_dup(const struct volume_group *vg)
}
static int _recalc_extents(uint32_t *extents, const char *desc1,
- const char *desc2, uint32_t old_size,
- uint32_t new_size)
+ const char *desc2, uint32_t old_extent_size,
+ uint32_t new_extent_size)
{
- uint64_t size = (uint64_t) old_size * (*extents);
+ uint64_t size = (uint64_t) old_extent_size * (*extents);
- if (size % new_size) {
+ if (size % new_extent_size) {
log_error("New size %" PRIu64 " for %s%s not an exact number "
"of new extents.", size, desc1, desc2);
return 0;
}
- size /= new_size;
+ size /= new_extent_size;
if (size > MAX_EXTENT_COUNT) {
log_error("New extent count %" PRIu64 " for %s%s exceeds "
@@ -302,9 +302,48 @@ static int _recalc_extents(uint32_t *extents, const char *desc1,
return 1;
}
-int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
+int vg_check_new_extent_size(const struct format_type *fmt, uint32_t new_extent_size)
{
- uint32_t old_size = vg->extent_size;
+ if (!new_extent_size) {
+ log_error("Physical extent size may not be zero");
+ return 0;
+ }
+
+ if ((fmt->features & FMT_NON_POWER2_EXTENTS)) {
+ if ((new_extent_size & (new_extent_size - 1)) &&
+ (new_extent_size % MIN_NON_POWER2_EXTENT_SIZE)) {
+ log_error("Physical Extent size must be a multiple of %s when not a power of 2.",
+ display_size(fmt->cmd, (uint64_t) MIN_NON_POWER2_EXTENT_SIZE));
+ return 0;
+ }
+ return 1;
+ }
+
+ /* Apply original format1 restrictions */
+ if ((new_extent_size & (new_extent_size - 1))) {
+ log_error("Metadata format only supports Physical Extent sizes that are powers of 2.");
+ return 0;
+ }
+
+ if (new_extent_size > MAX_PE_SIZE || new_extent_size < MIN_PE_SIZE) {
+ log_error("Extent size must be between %s and %s",
+ display_size(fmt->cmd, (uint64_t) MIN_PE_SIZE),
+ display_size(fmt->cmd, (uint64_t) MAX_PE_SIZE));
+ return 0;
+ }
+
+ if (new_extent_size % MIN_PE_SIZE) {
+ log_error("Extent size must be multiple of %s",
+ display_size(fmt->cmd, (uint64_t) MIN_PE_SIZE));
+ return 0;
+ }
+
+ return 1;
+}
+
+int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size)
+{
+ uint32_t old_extent_size = vg->extent_size;
struct pv_list *pvl;
struct lv_list *lvl;
struct physical_volume *pv;
@@ -319,52 +358,45 @@ int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
return 0;
}
- if (!new_size) {
- log_error("Physical extent size may not be zero");
- return 0;
- }
-
- if (new_size == vg->extent_size)
+ if (new_extent_size == vg->extent_size)
return 1;
- if (new_size & (new_size - 1)) {
- log_error("Physical extent size must be a power of 2.");
- return 0;
- }
+ if (!vg_check_new_extent_size(vg->fid->fmt, new_extent_size))
+ return_0;
- if (new_size > vg->extent_size) {
- if ((uint64_t) vg_size(vg) % new_size) {
+ if (new_extent_size > vg->extent_size) {
+ if ((uint64_t) vg_size(vg) % new_extent_size) {
/* FIXME Adjust used PV sizes instead */
log_error("New extent size is not a perfect fit");
return 0;
}
}
- vg->extent_size = new_size;
+ vg->extent_size = new_extent_size;
if (vg->fid->fmt->ops->vg_setup &&
!vg->fid->fmt->ops->vg_setup(vg->fid, vg))
return_0;
- if (!_recalc_extents(&vg->extent_count, vg->name, "", old_size,
- new_size))
+ if (!_recalc_extents(&vg->extent_count, vg->name, "", old_extent_size,
+ new_extent_size))
return_0;
if (!_recalc_extents(&vg->free_count, vg->name, " free space",
- old_size, new_size))
+ old_extent_size, new_extent_size))
return_0;
/* foreach PV */
dm_list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
- pv->pe_size = new_size;
+ pv->pe_size = new_extent_size;
if (!_recalc_extents(&pv->pe_count, pv_dev_name(pv), "",
- old_size, new_size))
+ old_extent_size, new_extent_size))
return_0;
if (!_recalc_extents(&pv->pe_alloc_count, pv_dev_name(pv),
- " allocated space", old_size, new_size))
+ " allocated space", old_extent_size, new_extent_size))
return_0;
/* foreach free PV Segment */
@@ -373,12 +405,12 @@ int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
continue;
if (!_recalc_extents(&pvseg->pe, pv_dev_name(pv),
- " PV segment start", old_size,
- new_size))
+ " PV segment start", old_extent_size,
+ new_extent_size))
return_0;
if (!_recalc_extents(&pvseg->len, pv_dev_name(pv),
- " PV segment length", old_size,
- new_size))
+ " PV segment length", old_extent_size,
+ new_extent_size))
return_0;
}
}
@@ -387,29 +419,29 @@ int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
dm_list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv;
- if (!_recalc_extents(&lv->le_count, lv->name, "", old_size,
- new_size))
+ if (!_recalc_extents(&lv->le_count, lv->name, "", old_extent_size,
+ new_extent_size))
return_0;
dm_list_iterate_items(seg, &lv->segments) {
if (!_recalc_extents(&seg->le, lv->name,
- " segment start", old_size,
- new_size))
+ " segment start", old_extent_size,
+ new_extent_size))
return_0;
if (!_recalc_extents(&seg->len, lv->name,
- " segment length", old_size,
- new_size))
+ " segment length", old_extent_size,
+ new_extent_size))
return_0;
if (!_recalc_extents(&seg->area_len, lv->name,
- " area length", old_size,
- new_size))
+ " area length", old_extent_size,
+ new_extent_size))
return_0;
if (!_recalc_extents(&seg->extents_copied, lv->name,
- " extents moved", old_size,
- new_size))
+ " extents moved", old_extent_size,
+ new_extent_size))
return_0;
/* foreach area */
@@ -419,21 +451,21 @@ int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
if (!_recalc_extents
(&seg_pe(seg, s),
lv->name,
- " pvseg start", old_size,
- new_size))
+ " pvseg start", old_extent_size,
+ new_extent_size))
return_0;
if (!_recalc_extents
(&seg_pvseg(seg, s)->len,
lv->name,
- " pvseg length", old_size,
- new_size))
+ " pvseg length", old_extent_size,
+ new_extent_size))
return_0;
break;
case AREA_LV:
if (!_recalc_extents
(&seg_le(seg, s), lv->name,
- " area start", old_size,
- new_size))
+ " area start", old_extent_size,
+ new_extent_size))
return_0;
break;
case AREA_UNASSIGNED:
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index b3b7e93..fffe9a7 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -147,6 +147,7 @@ int vg_set_clustered(struct volume_group *vg, int clustered);
uint64_t vg_size(const struct volume_group *vg);
uint64_t vg_free(const struct volume_group *vg);
uint64_t vg_extent_size(const struct volume_group *vg);
+int vg_check_new_extent_size(const struct format_type *fmt, uint32_t new_extent_size);
int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
uint64_t vg_extent_count(const struct volume_group *vg);
uint64_t vg_free_count(const struct volume_group *vg);
diff --git a/man/vgchange.8.in b/man/vgchange.8.in
index 150b77d..dcd1faf 100644
--- a/man/vgchange.8.in
+++ b/man/vgchange.8.in
@@ -220,10 +220,11 @@ minimize metadata read and write overhead.
.BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize [ \fIBbBsSkKmMgGtTpPeE ]
Changes the physical extent size on physical volumes of this volume group.
A size suffix (k for kilobytes up to t for terabytes) is optional, megabytes
-is the default if no suffix is present. The value must be at least 1 sector
-for LVM2 format (where the sector size is the largest sector size of the
-PVs currently used in the VG) or 8KiB for LVM1 format and it must be a
-power of 2. The default is 4 MiB.
+is the default if no suffix is present. For LVM2 format, the value must be a
+power of 2 of at least 1 sector (where the sector size is the largest sector
+size of the PVs currently used in the VG) or, if not a power of 2, at least
+128KiB. For the older LVM1 format, it must be a power of 2 of at least 8KiB.
+The default is 4 MiB.
Before increasing the physical extent size, you might need to use lvresize,
pvresize and/or pvmove so that everything fits. For example, every
diff --git a/man/vgcreate.8.in b/man/vgcreate.8.in
index bcfbcfc..d850659 100644
--- a/man/vgcreate.8.in
+++ b/man/vgcreate.8.in
@@ -105,10 +105,11 @@ See \fBlvm.conf\fP(5) for more information about \fBmetadata profiles\fP.
.BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize [ \fIbBsSkKmMgGtTpPeE ]
Sets the physical extent size on physical volumes of this volume group.
A size suffix (k for kilobytes up to t for terabytes) is optional, megabytes
-is the default if no suffix is present. The value must be at least 1 sector
-for LVM2 format (where the sector size is the largest sector size of the
-PVs currently used in the VG) or 8KiB for LVM1 format and it must be a
-power of 2. The default is 4 MiB.
+is the default if no suffix is present. For LVM2 format, the value must be a
+power of 2 of at least 1 sector (where the sector size is the largest sector
+size of the PVs currently used in the VG) or, if not a power of 2, at least
+128KiB. For the older LVM1 format, it must be a power of 2 of at least 8KiB.
+The default is 4 MiB.
Once this value has been set, it is difficult to change it without recreating
the volume group which would involve backing up and restoring data on any
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 86e3097..1089344 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -66,6 +66,9 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
rp.ba_size = arg_uint64_value(cmd, bootloaderareasize_ARG, UINT64_C(0));
}
+ if (!vg_check_new_extent_size(cmd->fmt, vg->extent_size))
+ return_ECMD_FAILED;
+
if (!archive(vg)) {
log_error("Archive of \"%s\" metadata failed.", vg_name);
return ECMD_FAILED;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=02628413ca99648e…
Commit: 02628413ca99648e70e38406384be69e20a2a6ce
Parent: d1bcdd7338148a887aae44149e3ea756c1df17a3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 14 09:56:58 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Oct 14 10:08:23 2014 +0200
systemd: remove workaround for lvm2-monitor.service's ExecStop line
Bug https://bugzilla.redhat.com/show_bug.cgi?id=843587 is handled better
now - the hang does not occur anymore. There are still error messages
issued though during shutdown if someone stops lvm2-lvmetad.service
manually that lvm2-monitor.service depends on (even during shutdown).
These errors are correct though and will point to incorrect
configuration (still having use_lvmetad=1 in lvm.conf and stopping
lvm2-lvmetad.service manually).
The workaround to prevent the hang is not needed now. So the
'--config "global{use_lvmetad=0}"' is now removed from the
lvm2-monitor.service's ExecStop line.
---
WHATS_NEW | 1 +
scripts/lvm2_monitoring_systemd_red_hat.service.in | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8511a45..2a0adf4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Remove workaround for lvm2-monitor.service hang on stop if lvmetad stopped.
Change vgremove to use process_each_lv_in_vg.
Introduce WARN_ flags to control some metadata warning messages.
Use process_each_pv in vgreduce.
diff --git a/scripts/lvm2_monitoring_systemd_red_hat.service.in b/scripts/lvm2_monitoring_systemd_red_hat.service.in
index 05f911b..bb52f0d 100644
--- a/scripts/lvm2_monitoring_systemd_red_hat.service.in
+++ b/scripts/lvm2_monitoring_systemd_red_hat.service.in
@@ -11,8 +11,7 @@ Conflicts=shutdown.target
Type=oneshot
Environment=LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
ExecStart=@sbindir@/lvm vgchange --monitor y --ignoreskippedcluster
-# The lvmetad must be disabled here, it needs https://bugzilla.redhat.com/show_bug.cgi?id=843587 to be resolved first.
-ExecStop=@sbindir@/lvm vgchange --monitor n --config 'global{use_lvmetad=0}' --ignoreskippedcluster
+ExecStop=@sbindir@/lvm vgchange --monitor n --ignoreskippedcluster
RemainAfterExit=yes
[Install]
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d1bcdd7338148a88…
Commit: d1bcdd7338148a887aae44149e3ea756c1df17a3
Parent: 22a6b0e40b302b333f9bd995c0b81b0146e8232a
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Oct 13 18:15:41 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Oct 13 18:15:41 2014 +0100
device: Fix BLKSSZGET definition check.
---
lib/device/dev-io.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 0a75088..122b616 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -154,7 +154,7 @@ int dev_get_block_size(struct device *dev, unsigned int *physical_block_size, un
}
log_debug_devs("%s: physical block size is %u bytes", name, dev->phys_block_size);
}
-#elif BLKSSZGET
+#elif defined (BLKSSZGET)
/* if we can't get physical block size, just use logical block size instead */
if (dev->phys_block_size == -1) {
if (ioctl(dev_fd(dev), BLKSSZGET, &dev->phys_block_size) < 0) {
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22a6b0e40b302b33…
Commit: 22a6b0e40b302b333f9bd995c0b81b0146e8232a
Parent: b59335fb398062d6537e8d4e815dcbf339343967
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 13 16:21:41 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 13 16:21:41 2014 +0200
lvchange: Allow appropriate actions on cache (in addition to thin) pools.
---
test/shell/lvconvert-cache-raid.sh | 4 +++-
tools/lvchange.c | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh
index 0678846..3ac2d0b 100644
--- a/test/shell/lvconvert-cache-raid.sh
+++ b/test/shell/lvconvert-cache-raid.sh
@@ -49,6 +49,9 @@ lvcreate -n cpool -m 1 --type raid1 -l 10 $vg
lvconvert --yes --type cache-pool --poolmetadata $vg/cpool_meta $vg/cpool
lvcreate -n corigin --type cache --cachepool $vg/cpool -l 10
+lvchange --syncaction repair $vg/cpool_cmeta
+lvchange --syncaction repair $vg/cpool_cdata
+
lvconvert --repair -y $vg/cpool_cmeta
lvconvert --repair -y $vg/cpool_cdata
@@ -60,5 +63,4 @@ not lvconvert --splitmirrors 1 --name split_cdata $vg/cpool_cdata "$dev1"
lvconvert --splitmirrors 1 --name split_meta $vg/cpool_cmeta "$dev1"
lvconvert --splitmirrors 1 --name split_data $vg/cpool_cdata "$dev1"
-
vgremove -f $vg
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 3a0e848..114065c 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -857,7 +857,8 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
lv_is_virtual_origin(origin = origin_from_cow(lv)))
lv = origin;
- if ((lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv)) &&
+ if ((lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv) ||
+ lv_is_cache_pool_data(lv) || lv_is_cache_pool_metadata(lv)) &&
!arg_count(cmd, activate_ARG) &&
!arg_count(cmd, permission_ARG) &&
!arg_count(cmd, setactivationskip_ARG))
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b59335fb398062d6…
Commit: b59335fb398062d6537e8d4e815dcbf339343967
Parent: c87e5a308a95e6e7c2d120ce816df14644f8e70a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 8 11:14:33 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 8 11:35:50 2014 +0200
toollib: validate_restricted_lvname_param
Lets make a separate new function to validate names that has
to follow up restriction rules.
---
tools/lvconvert.c | 8 ++++----
tools/lvcreate.c | 5 +----
tools/toollib.c | 19 +++++++++++++++++++
tools/toollib.h | 2 ++
4 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 50410a5..ad4a6c0 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -126,16 +126,16 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
(*pargv)++, (*pargc)--;
}
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_name))
+ if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_name))
return_0;
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_data_name))
+ if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->pool_data_name))
return_0;
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
+ if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
return_0;
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
+ if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
return_0;
if (strchr(lp->lv_name_full, '/') &&
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 41b8ee3..5a4bced 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -51,10 +51,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
const char *vg_name;
lp->lv_name = arg_str_value(cmd, name_ARG, NULL);
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
- return_0;
-
- if (lp->lv_name && !apply_lvname_restrictions(lp->lv_name))
+ if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
return_0;
lp->pool_name = arg_str_value(cmd, thinpool_ARG, NULL)
diff --git a/tools/toollib.c b/tools/toollib.c
index 8b92968..7f656c6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1309,6 +1309,25 @@ int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
return 1;
}
+/*
+ * Validate lvname parameter
+ * This name must follow restriction rules on prefixes and suffixes.
+ *
+ * If it contains vgname, it is extracted from lvname.
+ * If there is passed vgname, it is compared whether its the same name.
+ */
+int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_name,
+ const char **lv_name)
+{
+ if (!validate_lvname_param(cmd, vg_name, lv_name))
+ return_0;
+
+ if (lv_name && *lv_name && !apply_lvname_restrictions(*lv_name))
+ return_0;
+
+ return -1;
+}
+
struct vgnameid_list {
struct dm_list list;
const char *vg_name;
diff --git a/tools/toollib.h b/tools/toollib.h
index 037b7d7..50cc26c 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -132,6 +132,8 @@ int get_and_validate_major_minor(const struct cmd_context *cmd,
int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
const char **lv_name);
+int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_name,
+ const char **lv_name);
int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute__((unused)));
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c87e5a308a95e6e7…
Commit: c87e5a308a95e6e7c2d120ce816df14644f8e70a
Parent: f3bb1c018f7b6e38f0351a9994760bae7d9f00e3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Oct 8 10:57:44 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Oct 8 11:03:08 2014 +0200
filter-usable: filter out blocked and suspended devices firmly when scanning for lvmetad
We can't hang on blocked or suspended devices when the scan is done
for lvmetad update - when the device gets unblocked or resumed, there's
always CHANGE event generated which will fire the udev rule to run
extra pvscan --cache for that device which makes sure that lvmetad
is up-to-date.
---
lib/filters/filter-usable.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/filters/filter-usable.c b/lib/filters/filter-usable.c
index 2a7ef49..a6932b0 100644
--- a/lib/filters/filter-usable.c
+++ b/lib/filters/filter-usable.c
@@ -36,8 +36,15 @@ static int _passes_usable_filter(struct dev_filter *f, struct device *dev)
break;
case FILTER_MODE_PRE_LVMETAD:
ucp.check_empty = 1;
- ucp.check_blocked = 0;
- ucp.check_suspended = ignore_suspended_devices();
+ /*
+ * If we're scanning for lvmetad update,
+ * we don't want to hang on blocked/suspended devices.
+ * When the device is unblocked/resumed, surely,
+ * there's going to be a CHANGE event so the device
+ * gets scanned via udev rule anyway after resume.
+ */
+ ucp.check_blocked = 1;
+ ucp.check_suspended = 1;
ucp.check_error_target = 1;
ucp.check_reserved = 1;
break;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3bb1c018f7b6e38…
Commit: f3bb1c018f7b6e38f0351a9994760bae7d9f00e3
Parent: d623034e62a5fe0ba541e6d1e543f43ae90a834f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Oct 7 16:45:45 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Oct 7 16:45:45 2014 +0100
vgremove: Use process_each_lv_in_vg.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 5 -----
lib/metadata/metadata.c | 16 ----------------
tools/lvremove.c | 17 -----------------
tools/toollib.c | 23 ++++++++++++++++++++++-
tools/toollib.h | 11 ++++++-----
tools/tools.h | 1 +
tools/vgdisplay.c | 2 +-
tools/vgremove.c | 8 ++++++--
9 files changed, 37 insertions(+), 47 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index fa4ff65..8511a45 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Change vgremove to use process_each_lv_in_vg.
Introduce WARN_ flags to control some metadata warning messages.
Use process_each_pv in vgreduce.
Refactor process_each_pv in toollib.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index ae9996d..0d8db7d 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -661,11 +661,6 @@ int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
void add_pvl_to_vgs(struct volume_group *vg, struct pv_list *pvl);
void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl);
-/* FIXME: refactor / unexport when lvremove liblvm refactoring dones */
-int remove_lvs_in_vg(struct cmd_context *cmd,
- struct volume_group *vg,
- force_t force);
-
/*
* free_pv_fid() must be called on every struct physical_volume allocated
* by pv_create, pv_read, find_pv_by_name or to free it when no longer required.
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5c154bd..9308cb7 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -518,22 +518,6 @@ int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
return 1;
}
-int remove_lvs_in_vg(struct cmd_context *cmd,
- struct volume_group *vg,
- force_t force)
-{
- struct dm_list *lst;
- struct lv_list *lvl;
-
- while ((lst = dm_list_first(&vg->lvs))) {
- lvl = dm_list_item(lst, struct lv_list);
- if (!lv_remove_with_dependencies(cmd, lvl->lv, force, 0))
- return_0;
- }
-
- return 1;
-}
-
int vg_remove_check(struct volume_group *vg)
{
unsigned lv_count;
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 7d2fec1..1005218 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -15,23 +15,6 @@
#include "tools.h"
-static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle __attribute__((unused)))
-{
- /*
- * Single force is equivalent to sinle --yes
- * Even multiple --yes are equivalent to single --force
- * When we require -ff it cannot be replaces with -f -y
- */
- force_t force = (force_t) arg_count(cmd, force_ARG)
- ? : (arg_is_set(cmd, yes_ARG) ? DONT_PROMPT : PROMPT);
-
- if (!lv_remove_with_dependencies(cmd, lv, force, 0))
- return_ECMD_FAILED;
-
- return ECMD_PROCESSED;
-}
-
int lvremove(struct cmd_context *cmd, int argc, char **argv)
{
if (!argc) {
diff --git a/tools/toollib.c b/tools/toollib.c
index 3b1b00f..8b92968 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1569,6 +1569,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
struct dm_list *arg_lvnames, const struct dm_list *tags_in,
+ int stop_on_error,
void *handle, process_single_lv_fn_t process_single_lv)
{
int ret_max = ECMD_PROCESSED;
@@ -1640,6 +1641,9 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (ret > ret_max)
ret_max = ret;
+
+ if (stop_on_error && ret != ECMD_PROCESSED)
+ return ret_max;
}
if (lvargs_supplied) {
@@ -1826,7 +1830,7 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
continue;
}
- ret = process_each_lv_in_vg(cmd, vg, &lvnames, tags_arg,
+ ret = process_each_lv_in_vg(cmd, vg, &lvnames, tags_arg, 0,
handle, process_single_lv);
unlock_and_release_vg(cmd, vg, vg_name);
@@ -2254,3 +2258,20 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
return ret_max;
}
+
+int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
+ void *handle __attribute__((unused)))
+{
+ /*
+ * Single force is equivalent to single --yes
+ * Even multiple --yes are equivalent to single --force
+ * When we require -ff it cannot be replaced with -f -y
+ */
+ force_t force = (force_t) arg_count(cmd, force_ARG)
+ ? : (arg_is_set(cmd, yes_ARG) ? DONT_PROMPT : PROMPT);
+
+ if (!lv_remove_with_dependencies(cmd, lv, force, 0))
+ return_ECMD_FAILED;
+
+ return ECMD_PROCESSED;
+}
diff --git a/tools/toollib.h b/tools/toollib.h
index 5b42f28..037b7d7 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -74,11 +74,9 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
void *handle, process_single_pv_fn_t process_single_pv);
-int process_each_lv_in_vg(struct cmd_context *cmd,
- struct volume_group *vg,
- struct dm_list *arg_lvnames,
- const struct dm_list *tagsl,
- void *handle,
+int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
+ struct dm_list *arg_lvnames, const struct dm_list *tagsl,
+ int stop_on_error, void *handle,
process_single_lv_fn_t process_single_lv);
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
@@ -135,4 +133,7 @@ int get_and_validate_major_minor(const struct cmd_context *cmd,
int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
const char **lv_name);
+int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
+ void *handle __attribute__((unused)));
+
#endif
diff --git a/tools/tools.h b/tools/tools.h
index 134e584..5fa1ab6 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -177,4 +177,5 @@ int mirror_remove_missing(struct cmd_context *cmd,
int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
activation_change_t activate);
+
#endif
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index 95a5ebd..6e068aa 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -39,7 +39,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
if (arg_count(cmd, verbose_ARG)) {
vgdisplay_extents(vg);
- process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL,
+ process_each_lv_in_vg(cmd, vg, NULL, NULL, 0, NULL,
(process_single_lv_fn_t)lvdisplay_full);
log_print("--- Physical volumes ---");
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 0bbca76..1dce41f 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -27,6 +27,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
force_t force = (force_t) arg_count(cmd, force_ARG)
? : (arg_is_set(cmd, yes_ARG) ? DONT_PROMPT : PROMPT);
unsigned lv_count, missing;
+ int ret;
if (!vg_check_status(vg, EXPORTED_VG))
return_ECMD_FAILED;
@@ -46,8 +47,11 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
}
- if (!remove_lvs_in_vg(cmd, vg, force))
- return_ECMD_FAILED;
+ if ((ret = process_each_lv_in_vg(cmd, vg, NULL, NULL, 1, NULL,
+ (process_single_lv_fn_t)lvremove_single)) != ECMD_PROCESSED) {
+ stack;
+ return ret;
+ }
}
if (!force && !vg_remove_check(vg))
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d623034e62a5fe0b…
Commit: d623034e62a5fe0ba541e6d1e543f43ae90a834f
Parent: 88959032f7efb9229632c74a3738aae171f0c460
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 7 16:09:43 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 7 16:12:04 2014 +0200
test: Fix lvconvert-raid-allocation's use of lvconvert --repair.
---
test/shell/lvconvert-raid-allocation.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-raid-allocation.sh b/test/shell/lvconvert-raid-allocation.sh
index bd2cab5..a1b1c39 100644
--- a/test/shell/lvconvert-raid-allocation.sh
+++ b/test/shell/lvconvert-raid-allocation.sh
@@ -63,7 +63,7 @@ lvcreate --type raid1 -m 1 -l 3 -n $lv1 $vg \
"$dev1:0-1" "$dev2:0-1" "$dev3:0-1" "$dev4:0-1"
aux wait_for_sync $vg $lv1
aux disable_dev "$dev1"
-lvconvert --repair -y $vg/$lv1 "$dev1" "$dev2" "$dev3" "$dev4"
+lvconvert --repair -y $vg/$lv1 "$dev2" "$dev3" "$dev4"
#FIXME: ensure non-overlapping images (they should not share PVs)
aux enable_dev "$dev1"
lvremove -ff $vg
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88959032f7efb922…
Commit: 88959032f7efb9229632c74a3738aae171f0c460
Parent: 0cbb381e159f0606ec749697a596d2a6cc814283
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 7 16:06:21 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 7 16:11:56 2014 +0200
metadata: Fix find_pv_in_vg for missing PVs/filtered devices.
---
lib/metadata/metadata.c | 35 ++++++++++++-----------------------
1 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 3e5bd5d..5c154bd 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1778,31 +1778,20 @@ struct pv_list *find_pv_in_vg(const struct volume_group *vg,
const char *pv_name)
{
struct pv_list *pvl;
+ struct device *dev = dev_cache_get(pv_name, vg->cmd->filter);
- dm_list_iterate_items(pvl, &vg->pvs) {
- if (!pvl->pv->dev) {
- /*
- * pv_dev can't be NULL here!
- * We have to catch this situation earlier in the
- * code if this internal error is hit. Otherwise,
- * there's a possibility that pv_dev will match
- * cached_dev in case both are NULL.
- *
- * NULL cached_dev may happen in case this device
- * is filtered and NULL pv_dev may happen if the
- * device is missing!
- *
- * If such incorrect match was hit, simply incorrect
- * PV would be processed. This really needs to be
- * handled earlier in the code in that case.
- */
- log_error(INTERNAL_ERROR "find_pv_in_vg: PV that is not "
- "bound to any existing device found.");
- return NULL;
- }
- if (pvl->pv->dev == dev_cache_get(pv_name, vg->cmd->filter))
+ /*
+ * If the device does not exist or is filtered out, don't bother trying
+ * to find it in the list. This also prevents accidentally finding a
+ * non-NULL PV which happens to be missing (i.e. its pv->dev is NULL)
+ * for such devices.
+ */
+ if (!dev)
+ return NULL;
+
+ dm_list_iterate_items(pvl, &vg->pvs)
+ if (pvl->pv->dev == dev)
return pvl;
- }
return NULL;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0cbb381e159f0606…
Commit: 0cbb381e159f0606ec749697a596d2a6cc814283
Parent: 27ff61d012740dcdb8f5cf6421c22f746d056fe1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 7 15:41:54 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 7 15:52:31 2014 +0200
lvcreate: regression fix on lv name limits
When we are given an existing LV name - it needs to be allowed
to pass in even restricted name as the LV could have existed
long before we introduced some new restriction on prefix/suffix.i
Fix the regression on name limits and drop restriction to be applied
on any existing LVs - only the new created LV names have to be
complient with current name restrictions.
FIXME: we are currently using restricted names incorrectly in few
other places - device_is_usable() skips restricted names,
and udev flags are also incorrectly set for restricted names
so these LVs are not getting links properly.
---
lib/metadata/lv_manip.c | 6 ++++++
tools/lvcreate.c | 3 +++
tools/toollib.c | 3 ---
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 892f7ca..f14cec0 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7172,6 +7172,9 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
!(lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool")))
return_NULL;
+ if (lp->pool_name && !apply_lvname_restrictions(lp->pool_name))
+ return_NULL;
+
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
@@ -7188,6 +7191,9 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
"cache-pool")))
return_NULL;
+ if (lp->pool_name && !apply_lvname_restrictions(lp->pool_name))
+ return_NULL;
+
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2fa7918..41b8ee3 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -54,6 +54,9 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
return_0;
+ if (lp->lv_name && !apply_lvname_restrictions(lp->lv_name))
+ return_0;
+
lp->pool_name = arg_str_value(cmd, thinpool_ARG, NULL)
? : arg_str_value(cmd, cachepool_ARG, NULL);
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_name))
diff --git a/tools/toollib.c b/tools/toollib.c
index 1ee8469..3b1b00f 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1300,9 +1300,6 @@ int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
*lv_name = lvname;
}
- if (!apply_lvname_restrictions(*lv_name))
- return_0;
-
if (!validate_name(*lv_name)) {
log_error("Logical volume name \"%s\" is invalid.",
*lv_name);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=27ff61d012740dcd…
Commit: 27ff61d012740dcdb8f5cf6421c22f746d056fe1
Parent: 62802ddae052e9af996a4366bdcd5a9f2ec713d1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 7 10:43:47 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 7 15:51:53 2014 +0200
cleanup: rename _name, _lv and _size
Use some standard names for lv char * names, logical_volume * lv
and sizes internally.
---
lib/metadata/lv_manip.c | 120 +++++++++++++++++-----------------
lib/metadata/metadata-exported.h | 10 ++--
liblvm/lvm_lv.c | 32 +++++-----
tools/lvconvert.c | 52 +++++++-------
tools/lvcreate.c | 134 +++++++++++++++++++-------------------
5 files changed, 174 insertions(+), 174 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 0aa6521..892f7ca 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6555,7 +6555,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
struct cmd_context *cmd = vg->cmd;
uint32_t size_rest;
uint64_t status = UINT64_C(0);
- struct logical_volume *lv, *org = NULL;
+ struct logical_volume *lv, *origin_lv = NULL;
struct logical_volume *pool_lv;
struct logical_volume *tmp_lv;
const char *thin_name = NULL;
@@ -6639,14 +6639,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
status |= lp->permission | VISIBLE_LV;
if (seg_is_cache(lp)) {
- if (!lp->pool) {
+ if (!lp->pool_name) {
log_error(INTERNAL_ERROR "Cannot create cached volume without cache pool.");
return NULL;
}
/* We have the cache_pool, create the origin with cache */
- if (!(pool_lv = find_lv(vg, lp->pool))) {
+ if (!(pool_lv = find_lv(vg, lp->pool_name))) {
log_error("Couldn't find cache pool volume %s in "
- "volume group %s.", lp->pool, vg->name);
+ "volume group %s.", lp->pool_name, vg->name);
return NULL;
}
@@ -6663,22 +6663,22 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "striped")))
return_0;
} else if (seg_is_thin(lp) && lp->snapshot) {
- if (!lp->origin) {
+ if (!lp->origin_name) {
log_error(INTERNAL_ERROR "Origin LV is not defined.");
return 0;
}
- if (!(org = find_lv(vg, lp->origin))) {
+ if (!(origin_lv = find_lv(vg, lp->origin_name))) {
log_error("Couldn't find origin volume '%s'.",
- lp->origin);
+ lp->origin_name);
return NULL;
}
- if (lv_is_locked(org)) {
+ if (lv_is_locked(origin_lv)) {
log_error("Snapshots of locked devices are not supported.");
return NULL;
}
- lp->voriginextents = org->le_count;
+ lp->voriginextents = origin_lv->le_count;
} else if (lp->snapshot) {
if (!activation()) {
log_error("Can't create snapshot without using "
@@ -6691,51 +6691,51 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!lp->voriginsize) {
- if (!(org = find_lv(vg, lp->origin))) {
+ if (!(origin_lv = find_lv(vg, lp->origin_name))) {
log_error("Couldn't find origin volume '%s'.",
- lp->origin);
+ lp->origin_name);
return NULL;
}
- if (lv_is_virtual_origin(org)) {
+ if (lv_is_virtual_origin(origin_lv)) {
log_error("Can't share virtual origins. "
"Use --virtualsize.");
return NULL;
}
- if (lv_is_cow(org)) {
+ if (lv_is_cow(origin_lv)) {
log_error("Snapshots of snapshots are not "
"supported yet.");
return NULL;
}
- if (lv_is_locked(org)) {
+ if (lv_is_locked(origin_lv)) {
log_error("Snapshots of locked devices are not "
"supported yet");
return NULL;
}
- if (lv_is_merging_origin(org)) {
+ if (lv_is_merging_origin(origin_lv)) {
log_error("Snapshots of an origin that has a "
"merging snapshot is not supported");
return NULL;
}
- if (lv_is_thin_type(org) && !lv_is_thin_volume(org)) {
+ if (lv_is_thin_type(origin_lv) && !lv_is_thin_volume(origin_lv)) {
log_error("Snapshots of thin pool %sdevices "
"are not supported.",
- lv_is_thin_pool_data(org) ? "data " :
- lv_is_thin_pool_metadata(org) ?
+ lv_is_thin_pool_data(origin_lv) ? "data " :
+ lv_is_thin_pool_metadata(origin_lv) ?
"metadata " : "");
return NULL;
}
- if (lv_is_mirror_type(org)) {
+ if (lv_is_mirror_type(origin_lv)) {
log_warn("WARNING: Snapshots of mirrors can deadlock under rare device failures.");
log_warn("WARNING: Consider using the raid1 mirror type to avoid this.");
log_warn("WARNING: See global/mirror_segtype_default in lvm.conf.");
}
- if (vg_is_clustered(vg) && lv_is_active(org) &&
- !lv_is_active_exclusive_locally(org)) {
+ if (vg_is_clustered(vg) && lv_is_active(origin_lv) &&
+ !lv_is_active_exclusive_locally(origin_lv)) {
log_error("%s must be active exclusively to"
- " create snapshot", org->name);
+ " create snapshot", origin_lv->name);
return NULL;
}
}
@@ -6807,14 +6807,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (seg_is_thin_volume(lp)) {
/* Ensure all stacked messages are submitted */
- if (!lp->pool) {
+ if (!lp->pool_name) {
log_error(INTERNAL_ERROR "Undefined pool for thin volume segment.");
return NULL;
}
- if (!(pool_lv = find_lv(vg, lp->pool))) {
+ if (!(pool_lv = find_lv(vg, lp->pool_name))) {
log_error("Unable to find existing pool LV %s in VG %s.",
- lp->pool, vg->name);
+ lp->pool_name, vg->name);
return NULL;
}
@@ -6823,11 +6823,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
/* For thin snapshot we must have matching pool */
- if (org && lv_is_thin_volume(org) && (!lp->pool ||
- (strcmp(first_seg(org)->pool_lv->name, lp->pool) == 0)))
- thin_name = org->name;
+ if (origin_lv && lv_is_thin_volume(origin_lv) && (!lp->pool_name ||
+ (strcmp(first_seg(origin_lv)->pool_lv->name, lp->pool_name) == 0)))
+ thin_name = origin_lv->name;
else
- thin_name = lp->pool;
+ thin_name = lp->pool_name;
}
if (segtype_is_mirrored(lp->segtype) || segtype_is_raid(lp->segtype)) {
@@ -6867,7 +6867,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!lv_extend(lv, lp->segtype,
lp->stripes, lp->stripe_size,
lp->mirrors,
- seg_is_pool(lp) ? lp->poolmetadataextents : lp->region_size,
+ seg_is_pool(lp) ? lp->pool_metadata_extents : lp->region_size,
seg_is_thin_volume(lp) ? lp->voriginextents : lp->extents,
thin_name, lp->pvh, lp->alloc, lp->approx_alloc))
return_NULL;
@@ -6900,18 +6900,18 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* Check if using 'external origin' or the 'normal' snapshot
* within the same thin pool
*/
- if (lp->snapshot && (first_seg(org)->pool_lv != pool_lv)) {
- if (!pool_supports_external_origin(first_seg(pool_lv), org))
+ if (lp->snapshot && (first_seg(origin_lv)->pool_lv != pool_lv)) {
+ if (!pool_supports_external_origin(first_seg(pool_lv), origin_lv))
return_0;
- if (org->status & LVM_WRITE) {
+ if (origin_lv->status & LVM_WRITE) {
log_error("Cannot use writable LV as the external origin.");
return 0; // TODO conversion for inactive
}
- if (lv_is_active(org) && !lv_is_external_origin(org)) {
+ if (lv_is_active(origin_lv) && !lv_is_external_origin(origin_lv)) {
log_error("Cannot use active LV for the external origin.");
return 0; // We can't be sure device is read-only
}
- if (!attach_thin_external_origin(first_seg(lv), org))
+ if (!attach_thin_external_origin(first_seg(lv), origin_lv))
return_NULL;
}
@@ -6953,18 +6953,18 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* Either we have origin or pool and created cache origin LV
*/
if (lp->cache &&
- (lp->origin || (lp->pool && !lv_is_cache_pool(lv)))) {
- if (lp->origin) {
- if (!(org = find_lv(vg, lp->origin)))
+ (lp->origin_name || (lp->pool_name && !lv_is_cache_pool(lv)))) {
+ if (lp->origin_name) {
+ if (!(origin_lv = find_lv(vg, lp->origin_name)))
goto deactivate_and_revert_new_lv;
pool_lv = lv; /* Cache pool is created */
- } else if (lp->pool) {
- if (!(pool_lv = find_lv(vg, lp->pool)))
+ } else if (lp->pool_name) {
+ if (!(pool_lv = find_lv(vg, lp->pool_name)))
goto deactivate_and_revert_new_lv;
- org = lv; /* Cached origin is created */
+ origin_lv = lv; /* Cached origin is created */
}
- if (!(tmp_lv = lv_cache_create(pool_lv, org)))
+ if (!(tmp_lv = lv_cache_create(pool_lv, origin_lv)))
goto deactivate_and_revert_new_lv;
/* From here we cannot deactive_and_revert! */
@@ -6976,7 +6976,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* There is no such problem with cache pool
* since it cannot be activated.
*/
- if (lp->origin && lv_is_active(lv)) {
+ if (lp->origin_name && lv_is_active(lv)) {
if (!is_change_activating(lp->activate)) {
/* User requested to create inactive cached volume */
if (deactivate_lv(cmd, lv)) {
@@ -7023,19 +7023,19 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (lv_is_thin_volume(lv)) {
/* For snapshot, suspend active thin origin first */
- if (org && lv_is_active(org) && lv_is_thin_volume(org)) {
- if (!suspend_lv_origin(cmd, org)) {
+ if (origin_lv && lv_is_active(origin_lv) && lv_is_thin_volume(origin_lv)) {
+ if (!suspend_lv_origin(cmd, origin_lv)) {
log_error("Failed to suspend thin snapshot origin %s/%s.",
- org->vg->name, org->name);
+ origin_lv->vg->name, origin_lv->name);
goto revert_new_lv;
}
- if (!resume_lv_origin(cmd, org)) { /* deptree updates thin-pool */
+ if (!resume_lv_origin(cmd, origin_lv)) { /* deptree updates thin-pool */
log_error("Failed to resume thin snapshot origin %s/%s.",
- org->vg->name, org->name);
+ origin_lv->vg->name, origin_lv->name);
goto revert_new_lv;
}
/* At this point remove pool messages, snapshot is active */
- if (!update_pool_lv(first_seg(org)->pool_lv, 0)) {
+ if (!update_pool_lv(first_seg(origin_lv)->pool_lv, 0)) {
stack;
goto revert_new_lv;
}
@@ -7104,7 +7104,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* if origin is real (not virtual) inactive device.
*/
if ((vg_is_clustered(vg) ||
- (!lp->voriginsize && !lv_is_active(org))) &&
+ (!lp->voriginsize && !lv_is_active(origin_lv))) &&
!deactivate_lv(cmd, lv)) {
log_error("Aborting. Couldn't deactivate snapshot "
"COW area. Manual intervention required.");
@@ -7113,13 +7113,13 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* A virtual origin must be activated explicitly. */
if (lp->voriginsize &&
- (!(org = _create_virtual_origin(cmd, vg, lv->name,
+ (!(origin_lv = _create_virtual_origin(cmd, vg, lv->name,
lp->permission,
lp->voriginextents)) ||
- !activate_lv_excl(cmd, org))) {
+ !activate_lv_excl(cmd, origin_lv))) {
log_error("Couldn't create virtual origin for LV %s",
lv->name);
- if (org && !lv_remove(org))
+ if (origin_lv && !lv_remove(origin_lv))
stack;
goto deactivate_and_revert_new_lv;
}
@@ -7128,14 +7128,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* COW LV is activated via implicit activation of origin LV
* Only the snapshot origin holds the LV lock in cluster
*/
- if (!vg_add_snapshot(org, lv, NULL,
- org->le_count, lp->chunk_size)) {
+ if (!vg_add_snapshot(origin_lv, lv, NULL,
+ origin_lv->le_count, lp->chunk_size)) {
log_error("Couldn't create snapshot.");
goto deactivate_and_revert_new_lv;
}
/* store vg on disk(s) */
- if (!lv_update_and_reload(org))
+ if (!lv_update_and_reload(origin_lv))
return_0;
}
@@ -7172,13 +7172,13 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
!(lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool")))
return_NULL;
- if (!(lv = _lv_create_an_lv(vg, lp, lp->pool)))
+ if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
if (!lp->thin && !lp->snapshot)
goto out;
- lp->pool = lv->name;
+ lp->pool_name = lv->name;
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
return_NULL;
@@ -7188,7 +7188,7 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
"cache-pool")))
return_NULL;
- if (!(lv = _lv_create_an_lv(vg, lp, lp->pool)))
+ if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
if (lv_is_cache(lv)) {
@@ -7201,7 +7201,7 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
if (!lp->cache)
goto out;
- lp->pool = lv->name;
+ lp->pool_name = lv->name;
log_error("Creation of cache pool and cached volume in one command is not yet supported.");
return NULL;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 4ab7672..ae9996d 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -811,7 +811,7 @@ struct lvcreate_params {
int32_t minor; /* all */
int log_count; /* mirror */
int nosync; /* mirror */
- int poolmetadataspare; /* thin pool */
+ int pool_metadata_spare; /* pools */
int temporary; /* temporary LV */
#define ACTIVATION_SKIP_SET 0x01 /* request to set LV activation skip flag state */
#define ACTIVATION_SKIP_SET_ENABLED 0x02 /* set the LV activation skip flag state to 'enabled' */
@@ -823,10 +823,10 @@ struct lvcreate_params {
#define THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE 0x02
int thin_chunk_size_calc_policy;
- const char *origin; /* snap */
- const char *pool; /* thin */
const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name; /* all */
+ const char *origin_name; /* snap */
+ const char *pool_name; /* thin */
/* Keep args given by the user on command line */
/* FIXME: create some more universal solution here */
@@ -855,8 +855,8 @@ struct lvcreate_params {
uint32_t extents; /* all */
uint32_t voriginextents; /* snapshot */
uint64_t voriginsize; /* snapshot */
- uint32_t poolmetadataextents; /* thin pool */
- uint64_t poolmetadatasize; /* thin pool */
+ uint32_t pool_metadata_extents; /* pools */
+ uint64_t pool_metadata_size; /* pools */
struct dm_list *pvh; /* all */
uint32_t permission; /* all */
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 3af1f62..76a3164 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -496,35 +496,35 @@ lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name,
/* Set defaults for thin pool specific LV parameters */
static int _lv_set_pool_params(struct lvcreate_params *lp,
- vg_t vg, const char *pool,
+ vg_t vg, const char *pool_name,
uint64_t extents, uint64_t meta_size)
{
_lv_set_default_params(lp, vg, NULL, extents);
- lp->pool = pool;
+ lp->pool_name = pool_name;
lp->create_pool = 1;
lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool");
lp->stripes = 1;
if (!meta_size) {
- lp->poolmetadatasize = extents * vg->extent_size /
+ lp->pool_metadata_size = extents * vg->extent_size /
(lp->chunk_size * (SECTOR_SIZE / 64));
- while ((lp->poolmetadatasize >
+ while ((lp->pool_metadata_size >
(2 * DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) &&
lp->chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE) {
lp->chunk_size <<= 1;
- lp->poolmetadatasize >>= 1;
+ lp->pool_metadata_size >>= 1;
}
} else
- lp->poolmetadatasize = meta_size;
+ lp->pool_metadata_size = meta_size;
- if (lp->poolmetadatasize % vg->extent_size)
- lp->poolmetadatasize +=
- vg->extent_size - lp->poolmetadatasize % vg->extent_size;
+ if (lp->pool_metadata_size % vg->extent_size)
+ lp->pool_metadata_size +=
+ vg->extent_size - lp->pool_metadata_size % vg->extent_size;
- if (!(lp->poolmetadataextents =
- extents_from_size(vg->cmd, lp->poolmetadatasize / SECTOR_SIZE,
+ if (!(lp->pool_metadata_extents =
+ extents_from_size(vg->cmd, lp->pool_metadata_size / SECTOR_SIZE,
vg->extent_size)))
return_0;
@@ -605,14 +605,14 @@ lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
/* Set defaults for thin LV specific parameters */
static int _lv_set_thin_params(struct lvcreate_params *lp,
- vg_t vg, const char *pool,
+ vg_t vg, const char *pool_name,
const char *lvname,
uint64_t extents)
{
_lv_set_default_params(lp, vg, lvname, extents);
lp->thin = 1;
- lp->pool = pool;
+ lp->pool_name = pool_name;
lp->segtype = get_segtype_from_string(vg->cmd, "thin");
lp->voriginsize = extents * vg->extent_size;
@@ -674,11 +674,11 @@ static lv_create_params_t _lvm_lv_params_create_snapshot(const lv_t lv,
return NULL;
}
- lvcp->lvp.pool = first_seg(lv)->pool_lv->name;
+ lvcp->lvp.pool_name = first_seg(lv)->pool_lv->name;
}
lvcp->lvp.stripes = 1;
- lvcp->lvp.origin = lv->name;
+ lvcp->lvp.origin_name = lv->name;
lvcp->magic = LV_CREATE_PARAMS_MAGIC;
}
@@ -797,7 +797,7 @@ static lv_t _lvm_lv_create(lv_create_params_t params)
* pool is.
*/
if (!(lvl = find_lv_in_vg(params->vg,
- (params->lvp.lv_name) ? params->lvp.lv_name : params->lvp.pool)))
+ (params->lvp.lv_name) ? params->lvp.lv_name : params->lvp.pool_name)))
return_NULL;
return (lv_t) lvl->lv;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index fc22823..50410a5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -67,10 +67,10 @@ struct lvconvert_params {
int passed_args;
uint64_t pool_metadata_size;
- const char *origin_lv_name;
- const char *pool_data_lv_name;
+ const char *origin_name;
+ const char *pool_data_name;
struct logical_volume *pool_data_lv;
- const char *pool_metadata_lv_name;
+ const char *pool_metadata_name;
struct logical_volume *pool_metadata_lv;
thin_discards_t discards;
};
@@ -126,13 +126,13 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
(*pargv)++, (*pargc)--;
}
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_lv_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_name))
return_0;
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_data_lv_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_data_name))
return_0;
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_lv_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
return_0;
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
@@ -188,7 +188,7 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
log_error("Too many arguments provided with --uncache.");
return 0;
}
- if (lp->pool_data_lv_name && lp->pool_metadata_lv_name) {
+ if (lp->pool_data_name && lp->pool_metadata_name) {
log_error("Too many arguments provided for pool.");
return 0;
}
@@ -236,7 +236,7 @@ static int _read_pool_params(struct lvconvert_params *lp, struct cmd_context *cm
int cachepool = 0;
int thinpool = 0;
- if ((lp->pool_data_lv_name = arg_str_value(cmd, cachepool_ARG, NULL))) {
+ if ((lp->pool_data_name = arg_str_value(cmd, cachepool_ARG, NULL))) {
if (type_str[0] &&
strcmp(type_str, "cache") &&
strcmp(type_str, "cache-pool")) {
@@ -248,7 +248,7 @@ static int _read_pool_params(struct lvconvert_params *lp, struct cmd_context *cm
type_str = "cache-pool";
} else if (!strcmp(type_str, "cache-pool"))
cachepool = 1;
- else if ((lp->pool_data_lv_name = arg_str_value(cmd, thinpool_ARG, NULL))) {
+ else if ((lp->pool_data_name = arg_str_value(cmd, thinpool_ARG, NULL))) {
if (type_str[0] &&
strcmp(type_str, "thin") &&
strcmp(type_str, "thin-pool")) {
@@ -280,7 +280,7 @@ static int _read_pool_params(struct lvconvert_params *lp, struct cmd_context *cm
if (thinpool) {
lp->discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, THIN_DISCARDS_PASSDOWN);
- lp->origin_lv_name = arg_str_value(cmd, originname_ARG, NULL);
+ lp->origin_name = arg_str_value(cmd, originname_ARG, NULL);
} else {
if (arg_from_list_is_set(cmd, "is valid only with thin pools",
discards_ARG, originname_ARG, thinpool_ARG,
@@ -308,23 +308,23 @@ static int _read_pool_params(struct lvconvert_params *lp, struct cmd_context *cm
&lp->zero))
return_0;
- if ((lp->pool_metadata_lv_name = arg_str_value(cmd, poolmetadata_ARG, NULL)) &&
+ if ((lp->pool_metadata_name = arg_str_value(cmd, poolmetadata_ARG, NULL)) &&
arg_from_list_is_set(cmd, "is invalid with --poolmetadata",
stripesize_ARG, stripes_long_ARG,
readahead_ARG, -1))
return_0;
- if (!lp->pool_data_lv_name) {
+ if (!lp->pool_data_name) {
if (!*pargc) {
log_error("Please specify the pool data LV.");
return 0;
}
- lp->pool_data_lv_name = (*pargv)[0];
+ lp->pool_data_name = (*pargv)[0];
(*pargv)++, (*pargc)--;
}
if (!lp->thin && !lp->cache)
- lp->lv_name_full = lp->pool_data_lv_name;
+ lp->lv_name_full = lp->pool_data_name;
/* Hmm _read_activation_params */
lp->read_ahead = arg_uint_value(cmd, readahead_ARG,
@@ -528,7 +528,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
log_error("Please provide logical volume path for snapshot origin.");
return 0;
}
- lp->origin_lv_name = argv[0];
+ lp->origin_name = argv[0];
argv++, argc--;
if (arg_count(cmd, regionsize_ARG)) {
@@ -2164,9 +2164,9 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
return 0;
}
- if (!(org = find_lv(lv->vg, lp->origin_lv_name))) {
+ if (!(org = find_lv(lv->vg, lp->origin_name))) {
log_error("Couldn't find origin volume %s in Volume group %s.",
- lp->origin_lv_name, lv->vg->name);
+ lp->origin_name, lv->vg->name);
return 0;
}
@@ -2648,11 +2648,11 @@ static int _lvconvert_thin(struct cmd_context *cmd,
struct lvcreate_params lvc = {
.activate = CHANGE_AEY,
.alloc = ALLOC_INHERIT,
- .lv_name = lp->origin_lv_name,
+ .lv_name = lp->origin_name,
.major = -1,
.minor = -1,
.permission = LVM_READ,
- .pool = pool_lv->name,
+ .pool_name = pool_lv->name,
.pvh = &vg->pvs,
.read_ahead = DM_READ_AHEAD_AUTO,
.stripes = 1,
@@ -2792,9 +2792,9 @@ static int _lvconvert_pool(struct cmd_context *cmd,
char metadata_name[NAME_LEN], data_name[NAME_LEN];
int activate_pool;
- if (lp->pool_data_lv_name &&
- !(pool_lv = find_lv(vg, lp->pool_data_lv_name))) {
- log_error("Unknown pool data LV %s.", lp->pool_data_lv_name);
+ if (lp->pool_data_name &&
+ !(pool_lv = find_lv(vg, lp->pool_data_name))) {
+ log_error("Unknown pool data LV %s.", lp->pool_data_name);
return 0;
}
@@ -2845,9 +2845,9 @@ static int _lvconvert_pool(struct cmd_context *cmd,
return 0;
}
- if (lp->pool_metadata_lv_name) {
- if (!(lp->pool_metadata_lv = find_lv(vg, lp->pool_metadata_lv_name))) {
- log_error("Unknown pool metadata LV %s.", lp->pool_metadata_lv_name);
+ if (lp->pool_metadata_name) {
+ if (!(lp->pool_metadata_lv = find_lv(vg, lp->pool_metadata_name))) {
+ log_error("Unknown pool metadata LV %s.", lp->pool_metadata_name);
return 0;
}
lp->pool_metadata_size = lp->pool_metadata_lv->size;
@@ -3127,7 +3127,7 @@ mda_write:
/* Rename deactivated metadata LV to have _tmeta suffix */
/* Implicit checks if metadata_lv is visible */
- if (lp->pool_metadata_lv_name &&
+ if (lp->pool_metadata_name &&
!lv_rename_update(cmd, metadata_lv, metadata_name, 0))
return_0;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 0dc3699..2fa7918 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -54,9 +54,9 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
return_0;
- lp->pool = arg_str_value(cmd, thinpool_ARG, NULL)
+ lp->pool_name = arg_str_value(cmd, thinpool_ARG, NULL)
? : arg_str_value(cmd, cachepool_ARG, NULL);
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_name))
return_0;
if (seg_is_cache(lp)) {
@@ -73,7 +73,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
* or whether it is the origin for cached LV.
*/
if (!argc) {
- if (!lp->pool) {
+ if (!lp->pool_name) {
/* Don't advertise we could handle cache origin */
log_error("Please specify a logical volume to act as the cache pool.");
return 0;
@@ -86,25 +86,25 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
return_0;
} else {
/* Lets pretend it's cache origin for now */
- lp->origin = vg_name;
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin))
+ lp->origin_name = vg_name;
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
return_0;
- if (lp->pool) {
- if (strcmp(lp->pool, lp->origin)) {
+ if (lp->pool_name) {
+ if (strcmp(lp->pool_name, lp->origin_name)) {
log_error("Unsupported syntax, cannot use cache origin %s and --cachepool %s.",
- lp->origin, lp->pool);
+ lp->origin_name, lp->pool_name);
/* Stop here, only older form remains supported */
return 0;
}
- lp->origin = NULL;
+ lp->origin_name = NULL;
} else {
/*
* Gambling here, could be cache pool or cache origin,
* detection is possible after openning vg,
* yet we need to parse pool args
*/
- lp->pool = lp->origin;
+ lp->pool_name = lp->origin_name;
lp->create_pool = 1;
}
}
@@ -121,7 +121,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
return 0;
}
- if (!lp->pool) {
+ if (!lp->pool_name) {
log_error("Creation of cached volume and cache pool "
"in one command is not yet supported.");
return 0;
@@ -136,8 +136,8 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
return 0;
}
- lp->origin = argv[0];
- if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin))
+ lp->origin_name = argv[0];
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
return_0;
if (!lp->vg_name &&
@@ -162,13 +162,13 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
if (!validate_lvname_param(cmd, &lp->vg_name, &vg_name))
return_0;
- if (lp->pool &&
- (strcmp(vg_name, lp->pool) != 0)) {
+ if (lp->pool_name &&
+ (strcmp(vg_name, lp->pool_name) != 0)) {
log_error("Ambiguous %s name specified, %s and %s.",
- lp->segtype->name, vg_name, lp->pool);
+ lp->segtype->name, vg_name, lp->pool_name);
return 0;
}
- lp->pool = vg_name;
+ lp->pool_name = vg_name;
if (!lp->vg_name &&
!_set_vg_name(lp, extract_vgname(cmd, NULL)))
@@ -207,16 +207,16 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
/* support --name & --type {thin|cache}-pool */
if (seg_is_pool(lp) && lp->lv_name) {
- if (lp->pool && (strcmp(lp->lv_name, lp->pool) != 0)) {
+ if (lp->pool_name && (strcmp(lp->lv_name, lp->pool_name) != 0)) {
log_error("Ambiguous %s name specified, %s and %s.",
- lp->segtype->name, lp->lv_name, lp->pool);
+ lp->segtype->name, lp->lv_name, lp->pool_name);
return 0;
}
- lp->pool = lp->lv_name;
+ lp->pool_name = lp->lv_name;
lp->lv_name = NULL;
}
- if (lp->pool && lp->lv_name && !strcmp(lp->pool, lp->lv_name)) {
+ if (lp->pool_name && lp->lv_name && !strcmp(lp->pool_name, lp->lv_name)) {
log_error("Logical volume name %s and pool name must be different.",
lp->lv_name);
return 0;
@@ -239,9 +239,9 @@ static int _determine_snapshot_type(struct volume_group *vg,
{
struct logical_volume *lv, *pool_lv = NULL;
- if (!(lv = find_lv(vg, lp->origin))) {
+ if (!(lv = find_lv(vg, lp->origin_name))) {
log_error("Snapshot origin LV %s not found in Volume group %s.",
- lp->origin, vg->name);
+ lp->origin_name, vg->name);
return 0;
}
@@ -250,10 +250,10 @@ static int _determine_snapshot_type(struct volume_group *vg,
return 0;
}
- if (lp->pool) {
- if (!(pool_lv = find_lv(vg, lp->pool))) {
+ if (lp->pool_name) {
+ if (!(pool_lv = find_lv(vg, lp->pool_name))) {
log_error("Thin pool volume %s not found in Volume group %s.",
- lp->pool, vg->name);
+ lp->pool_name, vg->name);
return 0;
}
@@ -265,10 +265,10 @@ static int _determine_snapshot_type(struct volume_group *vg,
}
if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
- if (lv_is_thin_volume(lv) && !lp->pool)
- lp->pool = first_seg(lv)->pool_lv->name;
+ if (lv_is_thin_volume(lv) && !lp->pool_name)
+ lp->pool_name = first_seg(lv)->pool_lv->name;
- if (seg_is_thin(lp) || lp->pool) {
+ if (seg_is_thin(lp) || lp->pool_name) {
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
return_0;
return 1;
@@ -276,7 +276,7 @@ static int _determine_snapshot_type(struct volume_group *vg,
log_error("Please specify either size or extents with snapshots.");
return 0;
- } else if (lp->pool) {
+ } else if (lp->pool_name) {
log_error("Cannot specify size with thin pool snapshot.");
return 0;
}
@@ -289,7 +289,7 @@ static int _lvcreate_update_pool_params(struct volume_group *vg,
{
return update_pool_params(lp->segtype, vg, lp->target_attr,
lp->passed_args, lp->extents,
- &lp->poolmetadatasize,
+ &lp->pool_metadata_size,
&lp->thin_chunk_size_calc_policy, &lp->chunk_size,
&lp->discards, &lp->zero);
}
@@ -316,23 +316,23 @@ static int _determine_cache_argument(struct volume_group *vg,
return 0;
}
- if (!lp->pool) {
- lp->pool = lp->lv_name;
- } else if (lp->pool == lp->origin) {
- if (!(lv = find_lv(vg, lp->pool))) {
+ if (!lp->pool_name) {
+ lp->pool_name = lp->lv_name;
+ } else if (lp->pool_name == lp->origin_name) {
+ if (!(lv = find_lv(vg, lp->pool_name))) {
/* Cache pool nor origin volume exists */
lp->cache = 0;
- lp->origin = NULL;
+ lp->origin_name = NULL;
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "cache-pool")))
return_0;
} else if (!lv_is_cache_pool(lv)) {
/* Name arg in this case is for pool name */
- lp->pool = lp->lv_name;
+ lp->pool_name = lp->lv_name;
/* We were given origin for caching */
} else {
/* FIXME error on pool args */
lp->create_pool = 0;
- lp->origin = NULL;
+ lp->origin_name = NULL;
}
}
@@ -350,7 +350,7 @@ static int _update_extents_params(struct volume_group *vg,
struct lvcreate_cmdline_params *lcp)
{
uint32_t pv_extent_count;
- struct logical_volume *origin = NULL;
+ struct logical_volume *origin_lv = NULL;
uint32_t size_rest;
uint32_t stripesize_extents;
uint32_t extents;
@@ -395,19 +395,19 @@ static int _update_extents_params(struct volume_group *vg,
"or %%FREE.", (lp->snapshot) ? "%ORIGIN, " : "");
return 0;
case PERCENT_ORIGIN:
- if (lp->snapshot && lp->origin &&
- !(origin = find_lv(vg, lp->origin))) {
+ if (lp->snapshot && lp->origin_name &&
+ !(origin_lv = find_lv(vg, lp->origin_name))) {
log_error("Couldn't find origin volume '%s'.",
- lp->origin);
+ lp->origin_name);
return 0;
}
- if (!origin) {
+ if (!origin_lv) {
log_error(INTERNAL_ERROR "Couldn't find origin volume.");
return 0;
}
/* Add whole metadata size estimation */
- extents = cow_max_extents(origin, lp->chunk_size) - origin->le_count +
- percent_of_extents(lp->extents, origin->le_count, 1);
+ extents = cow_max_extents(origin_lv, lp->chunk_size) - origin_lv->le_count +
+ percent_of_extents(lp->extents, origin_lv->le_count, 1);
break;
case PERCENT_NONE:
extents = lp->extents;
@@ -424,19 +424,19 @@ static int _update_extents_params(struct volume_group *vg,
lp->extents = extents;
}
- if (lp->snapshot && lp->origin && lp->extents) {
+ if (lp->snapshot && lp->origin_name && lp->extents) {
if (!lp->chunk_size) {
log_error(INTERNAL_ERROR "Missing snapshot chunk size.");
return 0;
}
- if (!origin && !(origin = find_lv(vg, lp->origin))) {
+ if (!origin_lv && !(origin_lv = find_lv(vg, lp->origin_name))) {
log_error("Couldn't find origin volume '%s'.",
- lp->origin);
+ lp->origin_name);
return 0;
}
- extents = cow_max_extents(origin, lp->chunk_size);
+ extents = cow_max_extents(origin_lv, lp->chunk_size);
if (extents < lp->extents) {
log_print_unless_silent("Reducing COW size %s down to maximum usable size %s.",
@@ -462,16 +462,16 @@ static int _update_extents_params(struct volume_group *vg,
if (!_lvcreate_update_pool_params(vg, lp))
return_0;
- if (!(lp->poolmetadataextents =
- extents_from_size(vg->cmd, lp->poolmetadatasize, vg->extent_size)))
+ if (!(lp->pool_metadata_extents =
+ extents_from_size(vg->cmd, lp->pool_metadata_size, vg->extent_size)))
return_0;
if (lcp->percent == PERCENT_FREE) {
- if (lp->extents <= (2 * lp->poolmetadataextents)) {
+ if (lp->extents <= (2 * lp->pool_metadata_extents)) {
log_error("Not enough space for thin pool creation.");
return 0;
}
/* FIXME: persistent hidden space in VG wanted */
- lp->extents -= (2 * lp->poolmetadataextents);
+ lp->extents -= (2 * lp->pool_metadata_extents);
}
}
@@ -1016,7 +1016,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
(lp->create_pool &&
!get_pool_params(cmd, lp->segtype, &lp->passed_args,
- &lp->poolmetadatasize, &lp->poolmetadataspare,
+ &lp->pool_metadata_size, &lp->pool_metadata_spare,
&lp->chunk_size, &lp->discards, &lp->zero)) ||
!_read_mirror_params(lp, cmd) ||
!_read_raid_params(lp, cmd) ||
@@ -1095,8 +1095,8 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
return 0;
}
- if (lp->pool)
- pool_lv = find_lv(vg, lp->pool);
+ if (lp->pool_name)
+ pool_lv = find_lv(vg, lp->pool_name);
if (!lp->create_pool) {
if (arg_from_list_is_set(vg->cmd, "is only available with thin pool creation",
@@ -1117,13 +1117,13 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
return 0;
}
- if (!lp->pool) {
+ if (!lp->pool_name) {
log_error("Please specify name of existing thin pool.");
return 0;
}
if (!pool_lv) {
- log_error("Thin pool %s not found in Volume group %s.", lp->pool, vg->name);
+ log_error("Thin pool %s not found in Volume group %s.", lp->pool_name, vg->name);
return 0;
}
@@ -1132,7 +1132,7 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
return 0;
}
} else if (pool_lv) {
- log_error("Logical volume %s already exists in Volume group %s.", lp->pool, vg->name);
+ log_error("Logical volume %s already exists in Volume group %s.", lp->pool_name, vg->name);
return 0;
}
@@ -1213,12 +1213,12 @@ static int _validate_internal_thin_processing(const struct lvcreate_params *lp)
1 0 1 1 y - create thin snapshot of existing thin LV
*/
- if (!lp->create_pool && !lp->pool) {
+ if (!lp->create_pool && !lp->pool_name) {
log_error(INTERNAL_ERROR "--thinpool not identified.");
r = 0;
}
- if ((lp->snapshot && !lp->origin) || (!lp->snapshot && lp->origin)) {
+ if ((lp->snapshot && !lp->origin_name) || (!lp->snapshot && lp->origin_name)) {
log_error(INTERNAL_ERROR "Inconsistent snapshot and origin parameters identified.");
r = 0;
}
@@ -1256,7 +1256,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
}
- if (lp.snapshot && lp.origin && !_determine_snapshot_type(vg, &lp))
+ if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp))
goto_out;
if (seg_is_thin(&lp) && !_check_thin_parameters(vg, &lp, &lcp))
@@ -1282,20 +1282,20 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
goto_out;
if (lp.create_pool) {
- if (!handle_pool_metadata_spare(vg, lp.poolmetadataextents,
- lp.pvh, lp.poolmetadataspare))
+ if (!handle_pool_metadata_spare(vg, lp.pool_metadata_extents,
+ lp.pvh, lp.pool_metadata_spare))
goto_out;
log_verbose("Making pool %s in VG %s using segtype %s",
- lp.pool ? : "with generated name", lp.vg_name, lp.segtype->name);
+ lp.pool_name ? : "with generated name", lp.vg_name, lp.segtype->name);
}
if (lp.thin)
log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s",
lp.lv_name ? : "with generated name",
- lp.pool ? : "with generated name", lp.vg_name,
+ lp.pool_name ? : "with generated name", lp.vg_name,
lp.snapshot ? " as snapshot of " : "",
- lp.snapshot ? lp.origin : "", lp.segtype->name);
+ lp.snapshot ? lp.origin_name : "", lp.segtype->name);
if (!lv_create_single(vg, &lp))
goto_out;