master - Update WHATS_NEW
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=94d3878efb7cec34468...
Commit: 94d3878efb7cec344681bf4a2b28774ffebda3ba
Parent: b8caca46527cd5e858b0218734ba9a1f24200d6e
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Thu Nov 30 13:30:28 2017 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Thu Nov 30 13:30:28 2017 +0100
Update WHATS_NEW
---
WHATS_NEW | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4ff8dcb..32ed3c9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -8,7 +8,13 @@ Version 2.02.177 -
Make a pvmove LV locking holder.
Do not change critical section counter on resume path without real resume.
Enhance activation code to automatically suspend pvmove participants.
+ Prevent conversion of thin volumes to snapshot origin when lvmlockd is used.
+ Correct the steps to change lock type in lvmlockd man page.
+ Retry lock acquisition on recognized sanlock errors.
+ Fix lock manager error codes in lvmlockd.
Remove unnecessary single read from lvmdiskscan.
+ Check raid reshape flags in vg_validate().
+ Add support for pvmove of cache and snapshot origins.
Avoid using precommitted metadata for suspending pvmove tree.
Ehnance pvmove locking.
Deactivate activated LVs on error path when pvmove activation fails.
5 years, 10 months
master - tests: Fix common_dev_ argument handling
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b8caca46527cd5e858b...
Commit: b8caca46527cd5e858b0218734ba9a1f24200d6e
Parent: a9812ec9d3469edbe24a2d08ccb1dda209cf66a5
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Tue Nov 28 12:03:35 2017 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Nov 28 12:03:35 2017 +0100
tests: Fix common_dev_ argument handling
from[:[len]] arguments with missing colon assigned from to len, instead
of till_the_end_of_device.
---
test/lib/aux.sh | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index b8a0cc0..de63167 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -912,6 +912,10 @@ common_dev_() {
for fromlen in "${@-0:}"; do
from=${fromlen%%:*}
len=${fromlen##*:}
+ if test "$len" = "$fromlen"; then
+ # Missing the colon at the end: empty len
+ len=
+ fi
test -n "$len" || len=$(( size - from ))
diff=$(( from - pos ))
if test $diff -gt 0 ; then
@@ -937,7 +941,7 @@ common_dev_() {
# Replace linear PV device with its 'delayed' version
# Could be used to more deterministicaly hit some problems.
-# Parameters: {device path} [read delay ms] [write delay ms] [offset:size]...
+# Parameters: {device path} [read delay ms] [write delay ms] [offset[:[size]]]...
# Original device is restored when both delay params are 0 (or missing).
# If the size is missing, the remaing portion of device is taken
# i.e. delay_dev "$dev1" 0 200 256:
5 years, 10 months
master - tests: Die on bad argument
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7665304604bad894afe...
Commit: 7665304604bad894afed5e372263e48b309927d7
Parent: 591ac0828af73ac9a134660a643ef234ff57c02e
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Tue Nov 28 09:05:02 2017 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Nov 28 09:21:05 2017 +0100
tests: Die on bad argument
---
test/lib/aux.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index b8a0cc0..97111c7 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -911,6 +911,7 @@ common_dev_() {
for fromlen in "${@-0:}"; do
from=${fromlen%%:*}
+ test "$from" = "$fromlen" || die "Bad argument: Missing ':' in FROM:[LEN] argument"
len=${fromlen##*:}
test -n "$len" || len=$(( size - from ))
diff=$(( from - pos ))
5 years, 10 months
master - tests: Fix aux delay_dev calls
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=591ac0828af73ac9a13...
Commit: 591ac0828af73ac9a134660a643ef234ff57c02e
Parent: a9812ec9d3469edbe24a2d08ccb1dda209cf66a5
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Tue Nov 28 08:51:12 2017 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Nov 28 08:51:12 2017 +0100
tests: Fix aux delay_dev calls
All these cases were supposed to create delay device till the end of
underlying device.
---
test/shell/lvchange-raid1-writemostly.sh | 2 +-
test/shell/lvchange-rebuild-raid.sh | 2 +-
test/shell/lvconvert-repair-raid.sh | 2 +-
test/shell/lvcreate-large-raid.sh | 2 +-
test/shell/lvcreate-raid-nosync.sh | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/shell/lvchange-raid1-writemostly.sh b/test/shell/lvchange-raid1-writemostly.sh
index 6e508c4..32829f9 100644
--- a/test/shell/lvchange-raid1-writemostly.sh
+++ b/test/shell/lvchange-raid1-writemostly.sh
@@ -23,7 +23,7 @@ get_devs
for d in "$dev1" "$dev2" "$dev3" "$dev4"
do
- aux delay_dev "$d" 0 20 "$(get first_extent_sector "$d")"
+ aux delay_dev "$d" 0 20 "$(get first_extent_sector "$d"):"
done
#
diff --git a/test/shell/lvchange-rebuild-raid.sh b/test/shell/lvchange-rebuild-raid.sh
index 5579106..4b67f7a 100644
--- a/test/shell/lvchange-rebuild-raid.sh
+++ b/test/shell/lvchange-rebuild-raid.sh
@@ -35,7 +35,7 @@ _sync() {
# Delay legs so that rebuilding status characters can be read
for d in "${DEVICES[@]}"
do
- aux delay_dev "$d" 0 50 "$(get first_extent_sector "$d")"
+ aux delay_dev "$d" 0 50 "$(get first_extent_sector "$d"):"
done
# rhbz 1064592
diff --git a/test/shell/lvconvert-repair-raid.sh b/test/shell/lvconvert-repair-raid.sh
index c866455..e76a113 100644
--- a/test/shell/lvconvert-repair-raid.sh
+++ b/test/shell/lvconvert-repair-raid.sh
@@ -28,7 +28,7 @@ get_devs
function delay
{
for d in "${DEVICES[@]}"; do
- aux delay_dev "$d" 0 $1 "$(get first_extent_sector "$d")"
+ aux delay_dev "$d" 0 $1 "$(get first_extent_sector "$d"):"
done
}
diff --git a/test/shell/lvcreate-large-raid.sh b/test/shell/lvcreate-large-raid.sh
index 3488db4..8b2b395 100644
--- a/test/shell/lvcreate-large-raid.sh
+++ b/test/shell/lvcreate-large-raid.sh
@@ -38,7 +38,7 @@ aux lvmconf 'devices/issue_discards = 1'
# Delay PVs so that resynchronization doesn't fill too much space
for device in "${DEVICES[@]}"
do
- aux delay_dev "$device" 0 10 "$(get first_extent_sector "$device")"
+ aux delay_dev "$device" 0 10 "$(get first_extent_sector "$device"):"
done
# bz837927 START
diff --git a/test/shell/lvcreate-raid-nosync.sh b/test/shell/lvcreate-raid-nosync.sh
index c0e23bb..ce61cf7 100644
--- a/test/shell/lvcreate-raid-nosync.sh
+++ b/test/shell/lvcreate-raid-nosync.sh
@@ -36,7 +36,7 @@ _sync() {
# Delay 1st leg so that rebuilding status characters
# can be read before resync finished too quick.
-aux delay_dev "$dev1" 0 100 "$(get first_extent_sector "$dev1")"
+aux delay_dev "$dev1" 0 100 "$(get first_extent_sector "$dev1"):"
# raid0/raid0_meta don't support resynchronization
for r in raid0 raid0_meta
5 years, 10 months
master - label: Remove unused verify functions.
by Alasdair Kergon
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a9812ec9d3469edbe24...
Commit: a9812ec9d3469edbe24a2d08ccb1dda209cf66a5
Parent: 02e934c444d2e292123fa3caff3197b84671d340
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 28 01:36:55 2017 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 28 01:36:55 2017 +0000
label: Remove unused verify functions.
label_verify has never been used so remove it.
---
WHATS_NEW | 1 +
lib/format1/lvm1-label.c | 1 -
lib/format_pool/pool_label.c | 1 -
lib/format_text/text_label.c | 1 -
lib/label/label.c | 27 ---------------------------
lib/label/label.h | 6 ------
6 files changed, 1 insertions(+), 36 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5937bad..4ff8dcb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Remove label_verify that has never been used.
Ensure very large numbers used as arguments are not casted to lower values.
Enhance reading and validation of options stripes and stripes_size.
Fix printing of default stripe size when user is not using stripes.
diff --git a/lib/format1/lvm1-label.c b/lib/format1/lvm1-label.c
index f5ce1e8..3b8a655 100644
--- a/lib/format1/lvm1-label.c
+++ b/lib/format1/lvm1-label.c
@@ -109,7 +109,6 @@ struct label_ops _lvm1_ops = {
.can_handle = _lvm1_can_handle,
.write = _lvm1_write,
.read = _lvm1_read,
- .verify = _lvm1_can_handle,
.initialise_label = _lvm1_initialise_label,
.destroy_label = _lvm1_destroy_label,
.destroy = _lvm1_destroy,
diff --git a/lib/format_pool/pool_label.c b/lib/format_pool/pool_label.c
index 0f1d1f7..2e30a7b 100644
--- a/lib/format_pool/pool_label.c
+++ b/lib/format_pool/pool_label.c
@@ -83,7 +83,6 @@ struct label_ops _pool_ops = {
.can_handle = _pool_can_handle,
.write = _pool_write,
.read = _pool_read,
- .verify = _pool_can_handle,
.initialise_label = _pool_initialise_label,
.destroy_label = _pool_destroy_label,
.destroy = _label_pool_destroy,
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index ad323b6..6d9cfbd 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -464,7 +464,6 @@ struct label_ops _text_ops = {
.can_handle = _text_can_handle,
.write = _text_write,
.read = _text_read,
- .verify = _text_can_handle,
.initialise_label = _text_initialise_label,
.destroy_label = _text_destroy_label,
.destroy = _fmt_text_destroy,
diff --git a/lib/label/label.c b/lib/label/label.c
index 0e99517..7a7c500 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -353,33 +353,6 @@ int label_write(struct device *dev, struct label *label)
return r;
}
-/* Unused */
-int label_verify(struct device *dev)
-{
- struct labeller *l;
- char buf[LABEL_SIZE] __attribute__((aligned(8)));
- uint64_t sector;
- struct lvmcache_info *info;
- int r = 0;
-
- if (!dev_open_readonly(dev)) {
- if ((info = lvmcache_info_from_pvid(dev->pvid, dev, 0)))
- _update_lvmcache_orphan(info);
- return_0;
- }
-
- if (!(l = _find_labeller(dev, buf, §or, UINT64_C(0))))
- goto out;
-
- r = l->ops->verify ? l->ops->verify(l, buf, sector) : 1;
-
- out:
- if (!dev_close(dev))
- stack;
-
- return r;
-}
-
void label_destroy(struct label *label)
{
label->labeller->ops->destroy_label(label->labeller, label);
diff --git a/lib/label/label.h b/lib/label/label.h
index cd6e5b7..ea11290 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -66,11 +66,6 @@ struct label_ops {
void *buf, struct label ** label);
/*
- * Additional consistency checks for the paranoid.
- */
- int (*verify) (struct labeller * l, void *buf, uint64_t sector);
-
- /*
* Populate label_type etc.
*/
int (*initialise_label) (struct labeller * l, struct label * label);
@@ -102,7 +97,6 @@ int label_remove(struct device *dev);
int label_read(struct device *dev, struct label **result,
uint64_t scan_sector);
int label_write(struct device *dev, struct label *label);
-int label_verify(struct device *dev);
struct label *label_create(struct labeller *labeller);
void label_destroy(struct label *label);
5 years, 10 months
master - cleanup: reuse existing macro
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=02e934c444d2e292123...
Commit: 02e934c444d2e292123fa3caff3197b84671d340
Parent: efa17cae24190d1178a9dac1473b8757c412292c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 27 10:20:24 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 27 10:34:30 2017 +0100
cleanup: reuse existing macro
Use existing macro to detect striped raid segment.
---
lib/metadata/segtype.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index c00cee6..61a6580 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -163,7 +163,7 @@ struct dev_manager;
((segtype_is_striped(segtype) || segtype_is_mirror(segtype) || \
segtype_is_cache(segtype) || segtype_is_cache_pool(segtype) || \
segtype_is_thin(segtype) || segtype_is_snapshot(segtype) || \
- (segtype_is_raid(segtype) && !segtype_is_raid1(segtype))) ? 1 : 0)
+ (segtype_is_striped_raid(segtype))) ? 1 : 0)
#define seg_is_striped_target(seg) segtype_is_striped_target((seg)->segtype)
#define seg_is_cache(seg) segtype_is_cache((seg)->segtype)
5 years, 10 months
master - cmdline: avoid overrun on very large numbers.
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=efa17cae24190d1178a...
Commit: efa17cae24190d1178a9dac1473b8757c412292c
Parent: 34eb082bbcd57deb954ff4221c9320126c2096f3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 27 10:21:21 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 27 10:34:30 2017 +0100
cmdline: avoid overrun on very large numbers.
When large size number (>2^31) is given on command line it could be
misdetected and in certain cases lead to wrongly casted number.
So make sure all cases always do set _MAX number in case the value would
not fit within the supported range instead of getting some random value
within the range.
In most cases this was not a problem to detect, but i.e. stripesize
parameter might have been fooled by certain large numbers.
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 17 +++++++++--------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9b9e7a8..5937bad 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Ensure very large numbers used as arguments are not casted to lower values.
Enhance reading and validation of options stripes and stripes_size.
Fix printing of default stripe size when user is not using stripes.
Activation code for pvmove automatically discovers holding LVs for resume.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 22f1c60..b693722 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -508,10 +508,10 @@ static int _get_int_arg(struct arg_values *av, char **ptr)
if (*ptr == val || errno)
return 0;
- av->i_value = (int32_t) v;
- av->ui_value = (uint32_t) v;
- av->i64_value = (int64_t) v;
- av->ui64_value = (uint64_t) v;
+ av->i_value = (v < INT32_MAX) ? (int32_t) v : INT32_MAX;
+ av->ui_value = (v < UINT32_MAX) ? (uint32_t) v : UINT32_MAX;
+ av->i64_value = (v < INT64_MAX) ? (int64_t) v : INT64_MAX;
+ av->ui64_value = (v < UINT64_MAX) ? (uint64_t) v : UINT64_MAX;
return 1;
}
@@ -641,10 +641,11 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
log_error("Size is too big (>=16EiB).");
return 0;
}
- av->i_value = (int32_t) v;
- av->ui_value = (uint32_t) v;
- av->i64_value = (int64_t) v;
- av->ui64_value = (uint64_t) v;
+
+ av->i_value = (v < INT32_MAX) ? (int32_t) v : INT32_MAX;
+ av->ui_value = (v < UINT32_MAX) ? (uint32_t) v : UINT32_MAX;
+ av->i64_value = (v < INT64_MAX) ? (int64_t) v : INT64_MAX;
+ av->ui64_value = (v < UINT64_MAX) ? (uint64_t) v : UINT64_MAX;
return 1;
}
5 years, 10 months
master - toollib: improve stripes args reading
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=34eb082bbcd57deb954...
Commit: 34eb082bbcd57deb954ff4221c9320126c2096f3
Parent: f70404addb0f46b7dd281c2e7e0f944aa7f27ae5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 27 10:26:35 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 27 10:34:30 2017 +0100
toollib: improve stripes args reading
Rewrite validation of stripes and stripe_size args into more readable
sequential code.
Extend reading of stripes & stripes_size args so it better knows
defaults for types like striped raid.
TODO: this should really be a value obtained for segtype structure and
all the weird conditions and modification of stripes and stripe_size
around lvm2 code should be dropped.
---
WHATS_NEW | 1 +
tools/toollib.c | 66 ++++++++++++++++++++++++++++++++----------------------
2 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f78b6c2..9b9e7a8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Enhance reading and validation of options stripes and stripes_size.
Fix printing of default stripe size when user is not using stripes.
Activation code for pvmove automatically discovers holding LVs for resume.
Make a pvmove LV locking holder.
diff --git a/tools/toollib.c b/tools/toollib.c
index ffd9a4d..f60014c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1266,39 +1266,41 @@ int get_pool_params(struct cmd_context *cmd,
static int _validate_stripe_params(struct cmd_context *cmd, const struct segment_type *segtype,
uint32_t *stripes, uint32_t *stripe_size)
{
- int stripe_size_required = segtype_supports_stripe_size(segtype);
+ if (*stripes < 1 || *stripes > MAX_STRIPES) {
+ log_error("Number of stripes (%d) must be between %d and %d.",
+ *stripes, 1, MAX_STRIPES);
+ return 0;
+ }
- if (!stripe_size_required && *stripe_size) {
- log_print_unless_silent("Ignoring stripesize argument for %s devices.", segtype->name);
- *stripe_size = 0;
- } else if (*stripes == 1 && stripe_size_required) {
- stripe_size_required = 0;
+ if (!segtype_supports_stripe_size(segtype)) {
+ if (*stripe_size) {
+ log_print_unless_silent("Ignoring stripesize argument for %s devices.",
+ segtype->name);
+ *stripe_size = 0;
+ }
+ } else if (*stripes == 1) {
if (*stripe_size) {
log_print_unless_silent("Ignoring stripesize argument with single stripe.");
*stripe_size = 0;
}
- }
-
- if (stripe_size_required) {
+ } else {
if (!*stripe_size) {
*stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
log_print_unless_silent("Using default stripesize %s.",
display_size(cmd, (uint64_t) *stripe_size));
}
- if (*stripe_size < STRIPE_SIZE_MIN || !is_power_of_2(*stripe_size)) {
+ if (*stripe_size > STRIPE_SIZE_LIMIT * 2) {
+ log_error("Stripe size cannot be larger than %s.",
+ display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
+ return 0;
+ } else if (*stripe_size < STRIPE_SIZE_MIN || !is_power_of_2(*stripe_size)) {
log_error("Invalid stripe size %s.",
display_size(cmd, (uint64_t) *stripe_size));
return 0;
}
}
- if (*stripes < 1 || *stripes > MAX_STRIPES) {
- log_error("Number of stripes (%d) must be between %d and %d.",
- *stripes, 1, MAX_STRIPES);
- return 0;
- }
-
return 1;
}
@@ -1314,23 +1316,33 @@ int get_stripe_params(struct cmd_context *cmd, const struct segment_type *segtyp
{
/* stripes_long_ARG takes precedence (for lvconvert) */
/* FIXME Cope with relative +/- changes for lvconvert. */
- *stripes = arg_uint_value(cmd, arg_is_set(cmd, stripes_long_ARG) ? stripes_long_ARG : stripes_ARG, 1);
- *stripes_supplied = arg_is_set(cmd, stripes_long_ARG) ? : arg_is_set(cmd, stripes_ARG);
+ if (arg_is_set(cmd, stripes_long_ARG)) {
+ *stripes = arg_uint_value(cmd, stripes_long_ARG, 0);
+ *stripes_supplied = 1;
+ } else if (arg_is_set(cmd, stripes_ARG)) {
+ *stripes = arg_uint_value(cmd, stripes_ARG, 0);
+ *stripes_supplied = 1;
+ } else {
+ /*
+ * FIXME add segtype parameter for min_stripes and remove logic for this
+ * from all other places
+ */
+ if (segtype_is_any_raid6(segtype))
+ *stripes = 3;
+ else if (segtype_is_striped_raid(segtype))
+ *stripes = 2;
+ else
+ *stripes = 1;
+ *stripes_supplied = 0;
+ }
- *stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
- *stripe_size_supplied = arg_is_set(cmd, stripesize_ARG);
- if (*stripe_size) {
+ if ((*stripe_size = arg_uint_value(cmd, stripesize_ARG, 0))) {
if (arg_sign_value(cmd, stripesize_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Negative stripesize is invalid.");
return 0;
}
-
- if (arg_uint64_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) {
- log_error("Stripe size cannot be larger than %s.",
- display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
- return 0;
- }
}
+ *stripe_size_supplied = arg_is_set(cmd, stripesize_ARG);
return _validate_stripe_params(cmd, segtype, stripes, stripe_size);
}
5 years, 10 months
master - pvmove: enhance delayed_resume logic
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f70404addb0f46b7dd2...
Commit: f70404addb0f46b7dd281c2e7e0f944aa7f27ae5
Parent: 8c6fd0933fa4ee9b79ae5edbb90afe6a3d893b18
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 26 00:28:33 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Nov 26 00:36:48 2017 +0100
pvmove: enhance delayed_resume logic
ATM we want to support delayed resume purely in pvmove case.
So have libdm logic internal to recognize difference beween
pvmove and other targets that do use delayed resume.
This fixes problem introduced with commit aa68b898ff9c51dcb
for mirror-on-mirror or snapshot-on-mirror problem.
TODO: likely added new API call and let libdm user select
delayed nodes explicitely.
---
lib/mirror/mirrored.c | 2 +-
libdm/libdm-deptree.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 4891fb7..602c30a 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -303,7 +303,7 @@ static int _add_log(struct dm_pool *mem, struct lv_segment *seg,
}
} else {
/* If core log, use mirror's UUID and set DM_CORELOG flag */
- if (!(log_dlid = build_dm_uuid(mem, seg->lv, NULL))) {
+ if (!(log_dlid = build_dm_uuid(mem, seg->lv, lv_is_pvmove(seg->lv) ? "pvmove" : NULL))) {
log_error("Failed to build uuid for mirror LV %s.",
seg->lv->name);
return 0;
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 547904f..d460ce1 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2963,8 +2963,8 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
/* Preload children first */
while ((child = dm_tree_next_child(&handle, dnode, 0))) {
/* Propagate delay of resume from parent node */
- if (dnode->props.delay_resume_if_new)
- child->props.delay_resume_if_new = 1;
+ if (dnode->props.delay_resume_if_new > 1)
+ child->props.delay_resume_if_new = dnode->props.delay_resume_if_new;
/* Skip existing non-device-mapper devices */
if (!child->info.exists && child->info.major)
@@ -3342,7 +3342,8 @@ int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
}
if ((flags & DM_CORELOG))
/* For pvmove: immediate resume (for size validation) isn't needed. */
- node->props.delay_resume_if_new = 1;
+ /* pvmove flag passed via unused UUID and its suffix */
+ node->props.delay_resume_if_new = strstr(log_uuid, "pvmove") ? 2 : 1;
else {
if (!(log_node = dm_tree_find_node_by_uuid(node->dtree, log_uuid))) {
log_error("Couldn't find mirror log uuid %s.", log_uuid);
5 years, 10 months
master - activation: enhance holders detection
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8c6fd0933fa4ee9b79a...
Commit: 8c6fd0933fa4ee9b79ae5edbb90afe6a3d893b18
Parent: ce83162d7c7eae008935989a26dbf23dfb08d0f9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 24 20:59:38 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Nov 26 00:31:26 2017 +0100
activation: enhance holders detection
Use code which detectes handlers in a way, which is more
backward-compatible friendly.
Replace read of 'sysfs' uuid entry with dm ioctl call.
Use /sys/block/dm-X/holders path instead of
new path /sys/dev/block/major:minor/holders.
TODO:
There are few more occurencies of this logic around the code
so some abstract interface should be considered.
---
lib/activate/dev_manager.c | 128 ++++++++++++++++++++++++--------------------
1 files changed, 69 insertions(+), 59 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 76fc546..429f4f6 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1720,81 +1720,52 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, const struct logical_vol
static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
const struct logical_volume *lv, int origin_only);
-/*
- * Add exiting devices which holds given LV device open.
- * This is used in case when metadata already do not contain information
- * i.e. PVMOVE is being finished and final table is going to be resumed.
- */
-static int _add_holders_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
- const struct logical_volume *lv, struct dm_info *info)
+
+static int _check_holder(struct dev_manager *dm, struct dm_tree *dtree,
+ const struct logical_volume *lv, uint32_t major,
+ const char *d_name)
{
const char *default_uuid_prefix = dm_uuid_prefix();
const size_t default_uuid_prefix_len = strlen(default_uuid_prefix);
- const char *sysfs_dir = dm_sysfs_dir();
- char sysfs_path[PATH_MAX];
- char uuid_path[PATH_MAX];
- char uuid_buf[DM_UUID_LEN + 1];
- char *uuid;
- struct dirent *dirent;
- DIR *d;
- FILE *fp;
+ const char *name;
+ const char *uuid;
+ struct dm_info info;
+ struct dm_task *dmt;
struct logical_volume *lv_det;
- int r = 0;
+ union lvid id;
+ int dev, r = 0;
- /* Sysfs path of holders */
- if (dm_snprintf(sysfs_path, sizeof(sysfs_path), "%sdev/block/" FMTu32
- ":" FMTu32 "/holders", sysfs_dir, info->major, info->minor) < 0) {
- log_error("sysfs_path dm_snprintf failed.");
- return 0;
- }
-
- if (!(d = opendir(sysfs_path))) {
- if (errno != ENOENT)
- log_sys_error("opendir", sysfs_path);
+ errno = 0;
+ dev = strtoll(d_name + 3, NULL, 10);
+ if (errno) {
+ log_error("Failed to parse dm device minor number from %s.", d_name);
return 0;
}
- while ((dirent = readdir(d))) {
- if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, ".."))
- continue;
-
- /* Determine path where sysfs holds UUID for holding dm device */
- if (dm_snprintf(uuid_path, sizeof(uuid_path), "%s/%s/dm/uuid",
- sysfs_path, dirent->d_name) < 0) {
- log_error("uuid_path dm_snprintf failed.");
- goto out;
- }
-
- if (!(fp = fopen(uuid_path, "r"))) {
- log_sys_error("fopen", uuid_path);
- goto out;
- }
-
- if (!fgets(uuid_buf, sizeof(uuid_buf), fp)) {
- log_sys_error("fgets", uuid_path);
- fclose(fp);
- goto out;
- }
+ if (!(dmt = _setup_task_run(DM_DEVICE_INFO, &info, NULL, NULL, NULL,
+ major, dev, 0, 0, 0)))
+ return_0;
- if (fclose(fp))
- log_sys_debug("fclose", uuid_path);
+ if (info.exists) {
+ uuid = dm_task_get_uuid(dmt);
+ name = dm_task_get_name(dmt);
- uuid = uuid_buf;
- log_debug_activation("Checking holder of LV %s with uuid %s.",
- display_lvname(lv), uuid);
+ log_debug_activation("Checking holder of %s %s (" FMTu32 ":" FMTu32 ") %s.",
+ display_lvname(lv), uuid, info.major, info.minor,
+ name);
- /* Skip common uuid LVM prefix */
+ /* Skip common uuid prefix */
if (!strncmp(default_uuid_prefix, uuid, default_uuid_prefix_len))
uuid += default_uuid_prefix_len;
- /* Check holder comes from processed VG and is not yet in dmtree */
if (!strncmp(uuid, (char*)&lv->vg->id, sizeof(lv->vg->id)) &&
!dm_tree_find_node_by_uuid(dtree, uuid)) {
- uuid[2 * sizeof(struct id)] = 0; /* Cut any suffix */
+ dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1);
+
/* If UUID is not yet in dtree, look for matching LV */
- if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, (union lvid*)uuid))) {
- log_error("Cannot find holding uuid %s in VG %s.",
- uuid, lv->vg->name);
+ if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, &id))) {
+ log_error("Cannot find holder with device name %s in VG %s.",
+ name, lv->vg->name);
goto out;
}
@@ -1808,10 +1779,49 @@ static int _add_holders_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
}
}
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
+/*
+ * Add exiting devices which holds given LV device open.
+ * This is used in case when metadata already do not contain information
+ * i.e. PVMOVE is being finished and final table is going to be resumed.
+ */
+static int _add_holders_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
+ const struct logical_volume *lv, struct dm_info *info)
+{
+ const char *sysfs_dir = dm_sysfs_dir();
+ char sysfs_path[PATH_MAX];
+ struct dirent *dirent;
+ DIR *d;
+ int r = 0;
+
+ /* Sysfs path of holders */
+ if (dm_snprintf(sysfs_path, sizeof(sysfs_path), "%sblock/dm-" FMTu32
+ "/holders", sysfs_dir, info->minor) < 0) {
+ log_error("sysfs_path dm_snprintf failed.");
+ return 0;
+ }
+
+ if (!(d = opendir(sysfs_path))) {
+ log_sys_error("opendir", sysfs_path);
+ return 0;
+ }
+
+ while ((dirent = readdir(d)))
+ /* Expects minor is added to 'dm-' prefix */
+ if (!strncmp(dirent->d_name, "dm-", 3) &&
+ !_check_holder(dm, dtree, lv, info->major, dirent->d_name))
+ goto_out;
+
r = 1;
out:
if (closedir(d))
- log_sys_error("closedir", "holders");
+ log_sys_debug("closedir", "holders");
return r;
}
5 years, 10 months