master - debug: mention origin_only in message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a029123679e183...
Commit: a029123679e183d410189dd90e17d6f5b590a35b
Parent: b3b8834724f445706723b1f1b19ec9bde33faa24
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 19 13:48:54 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
debug: mention origin_only in message
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1ad85ed..e714f0b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6174,8 +6174,8 @@ static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
int do_backup = 0, r = 0;
const struct logical_volume *lock_lv = lv_lock_holder(lv);
- log_very_verbose("Updating logical volume %s on disk(s).",
- display_lvname(lock_lv));
+ log_very_verbose("Updating logical volume %s on disk(s)%s.",
+ display_lvname(lock_lv), origin_only ? " (origin only)": "");
if (!vg_write(vg))
return_0;
6 years, 6 months
master - tests: enhance lvchange of thin pool tests
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b3b8834724f445...
Commit: b3b8834724f445706723b1f1b19ec9bde33faa24
Parent: 1a30adc062b30ef434857eb6d8345d8b66af120a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 19 13:49:32 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
tests: enhance lvchange of thin pool tests
Validate also content of dmtable.
Check operations with unused thin-pool as well.
---
test/shell/lvchange-thin.sh | 50 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvchange-thin.sh b/test/shell/lvchange-thin.sh
index 96c4b30..f2b33b7 100644
--- a/test/shell/lvchange-thin.sh
+++ b/test/shell/lvchange-thin.sh
@@ -23,7 +23,40 @@ aux prepare_pvs 3
vgcreate -s 128k $vg "$dev1" "$dev2"
vgcreate -s 128k $vg2 "$dev3"
-lvcreate -V10M -L10M -T $vg/pool -n $lv1
+lvcreate -L10M -T $vg/pool
+
+#
+# Check change operations on a thin-pool without any thin LV
+#
+# discards_ARG (default is passdown)
+check grep_dmsetup status $vg-pool " discard_passdown"
+lvchange -vvvv --discards nopassdown $vg/pool
+check grep_dmsetup table $vg-pool " no_discard_passdown"
+check grep_dmsetup status $vg-pool " no_discard_passdown"
+
+lvchange --discards passdown $vg/pool
+check grep_dmsetup table $vg-pool -v "passdown"
+check grep_dmsetup status $vg-pool " discard_passdown"
+
+# zero_ARG (default is 'yes')
+check grep_dmsetup table $vg-pool -v "zeroing"
+lvchange --zero n $vg/pool
+check grep_dmsetup table $vg-pool " skip_block_zeroing"
+lvchange --zero y $vg/pool
+check grep_dmsetup table $vg-pool -v "zeroing"
+
+# errorwhenfull_ARG (default is 'no')
+check grep_dmsetup status $vg-pool "queue_if_no_space"
+lvchange --errorwhenfull y $vg/pool
+check grep_dmsetup status $vg-pool "error_if_no_space"
+check grep_dmsetup table $vg-pool "error_if_no_space"
+lvchange --errorwhenfull n $vg/pool
+check grep_dmsetup status $vg-pool "queue_if_no_space"
+check grep_dmsetup table $vg-pool -v "error_if_no_space"
+
+
+# Attach thin volume
+lvcreate -V10M -n $lv1 $vg/pool
lvcreate -L10M -n $lv2 $vg
lvchange -an $vg/$lv1
@@ -73,11 +106,26 @@ lvchange --deltag foo $vg/pool
# discards_ARG
lvchange --discards nopassdown $vg/pool
+check grep_dmsetup table $vg-pool-tpool " no_discard_passdown"
+check grep_dmsetup status $vg-pool-tpool " no_discard_passdown"
lvchange --discards passdown $vg/pool
+check grep_dmsetup table $vg-pool-tpool -v "passdown"
+check grep_dmsetup status $vg-pool-tpool " discard_passdown"
# zero_ARG
lvchange --zero n $vg/pool
+check grep_dmsetup table $vg-pool-tpool " skip_block_zeroing"
lvchange --zero y $vg/pool
+check grep_dmsetup table $vg-pool-tpool -v "zeroing"
+
+
+lvchange --errorwhenfull y $vg/pool
+check grep_dmsetup status $vg-pool-tpool "error_if_no_space"
+check grep_dmsetup table $vg-pool-tpool "error_if_no_space"
+lvchange --errorwhenfull n $vg/pool
+check grep_dmsetup status $vg-pool-tpool "queue_if_no_space"
+check grep_dmsetup table $vg-pool-tpool -v "error_if_no_space"
+
#
# Test for disallowed metadata changes
6 years, 6 months
master - tests: check for metadata test working properly
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a30adc062b30e...
Commit: 1a30adc062b30ef434857eb6d8345d8b66af120a
Parent: 561f773bb47f11d495701e15d234c85cf746e285
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 16 21:55:04 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
tests: check for metadata test working properly
Add more tests to check they guard minimum free space in metadata
for new thin volume creation.
---
test/shell/lvextend-thin-metadata-dmeventd.sh | 68 +++++++++++++++++++++++--
1 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh
index a892bd4..6d27600 100644
--- a/test/shell/lvextend-thin-metadata-dmeventd.sh
+++ b/test/shell/lvextend-thin-metadata-dmeventd.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014-2016 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -60,13 +60,73 @@ aux have_thin 1 10 0 || skip
aux prepare_dmeventd
-aux lvmconf "activation/thin_pool_autoextend_percent = 10" \
- "activation/thin_pool_autoextend_threshold = 70"
-
aux prepare_pvs 3 256
vgcreate -s 1M $vg $(cat DEVICES)
+# Testing dmeventd does NOT autoresize when default threshold 100% is left
+lvcreate -L200M -V50M -n thin -T $vg/pool
+lvcreate -V2M -n thin2 $vg/pool
+lvcreate -L2M -n $lv1 $vg
+lvcreate -L32M -n $lv2 $vg
+lvcreate -L32M -n $lv3 $vg
+lvchange -an $vg/thin $vg/thin2 $vg/pool
+
+# Filling 2M metadata volume
+# (Test for less then 25% free space in metadata)
+fake_metadata_ 400 2 >data
+"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
+
+# Swap volume with restored fake metadata
+lvconvert -y --chunksize 64k --thinpool $vg/pool --poolmetadata $vg/$lv1
+
+# Not alllowed when thin-pool metadata free space is <75% for 2M meta
+fail lvcreate -V20 $vg/pool
+
+
+lvchange -an $vg/pool
+
+# Consume more then (100% - 4MiB) out of 32MiB metadata volume (>87.5%)
+# (Test for less then 4MiB free space in metadata, which is less then 25%)
+fake_metadata_ 7400 2 >data
+"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv2"
+# Swap volume with restored fake metadata
+lvconvert -y --chunksize 64k --thinpool $vg/pool --poolmetadata $vg/$lv2
+lvchange -ay $vg/pool
+# Check generated metadata consume more then 88%
+test "$(meta_percent_)" -gt "88"
+lvchange -an $vg/pool
+
+# Creation of thin LV is prohibited when metadata are above this value
+fail lvcreate -V20 $vg/pool 2>&1 | tee out
+grep "free space" out
+lvs -a $vg
+
+
+# Check that even with 99% threshold policy - metadata will go below 88%
+lvextend --use-policies --config "\
+activation/thin_pool_autoextend_percent=1 \
+activation/thin_pool_autoextend_threshold=99" $vg/pool
+test "$(meta_percent_)" -lt "88"
+
+# After such operatoin creation of thin LV has to pass
+lvcreate -V20 $vg/pool
+
+# Let's revalidate pool metadata (thin_check upon deactivation/activation)
+lvchange -an $vg
+lvchange -ay $vg/pool
+
+lvremove -f $vg
+
+
+
+#########################################################
+# Test automatic resize with help of dmeventd DOES work #
+#########################################################
+
+aux lvmconf "activation/thin_pool_autoextend_percent = 10" \
+ "activation/thin_pool_autoextend_threshold = 70"
+
# Testing dmeventd autoresize
lvcreate -L200M -V500M -n thin -T $vg/pool 2>&1 | tee out
not grep "WARNING: Sum" out
6 years, 6 months
master - tests: add check grep_dmsetup
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=561f773bb47f11...
Commit: 561f773bb47f11d495701e15d234c85cf746e285
Parent: 0e8449a5b921e60e6952ac5ff33e81a40abcd23a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 19 13:46:42 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
tests: add check grep_dmsetup
Add simple helper/wrapper check function to check result
of dmsetup call i.e.:
check grep_dmsetup table vg-lv "grep_expected"
check grep_dmsetup status vg-lv -v "grep_unexpected"
---
test/lib/check.sh | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 9dd8635..916d2df 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -400,6 +400,11 @@ raid_leg_status() {
die "$1-$2 status $val != $3 ($st)"
}
+grep_dmsetup() {
+ dmsetup $1 $2 | tee out
+ grep "${@:3}" out || die "Expected output from dmsetup $1 not found!"
+}
+
#set -x
unset LVM_VALGRIND
"$@"
6 years, 6 months
master - thin: fix lvchange of discards and zero flag
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0e8449a5b921e6...
Commit: 0e8449a5b921e60e6952ac5ff33e81a40abcd23a
Parent: c2c2721d0082d79fab98875dd20f03d6abf72bea
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Apr 23 21:09:09 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
thin: fix lvchange of discards and zero flag
Reload of thin-pool origin_only is designed to only post messages
to a thin-pool. It's not intended to be used for reload of thin-pool
table. Fix it by using standard call 'lv_update_and_reload()'.
---
WHATS_NEW | 1 +
tools/lvchange.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ba14c6d..ebb9c8c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.166 -
=====================================
+ Fix lvchange --discard|--zero for active thin-pool.
Enforce 4MiB or 25% metadata free space for thin pool operations.
Fix lock-holder device for thin pool with inactive thin volumes.
Use --alloc normal for mirror logs even if the mimages were stricter.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 4810392..250d720 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -136,7 +136,7 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
if (!update)
return 0;
- if (!lv_update_and_reload_origin(lv))
+ if (!lv_update_and_reload(lv))
return_0;
return 1;
6 years, 6 months
master - thin: enforce there is some free space in thin pool metadata
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c2c2721d0082d7...
Commit: c2c2721d0082d79fab98875dd20f03d6abf72bea
Parent: 776d5a25b4ab036103ec99291cb0056fa61490fa
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 16 21:50:14 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
thin: enforce there is some free space in thin pool metadata
Unconditionally guard there is at least 1/4 of metadata volume
free (<16Mib) or 4MiB - whichever value is smaller.
In case there is not enough free space do not let operation proceed and
recommend thin-pool metadata resize (in case user has not
enabled autoresize, manual 'lvextend --poolmetadatasize' is needed).
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 6 +++++-
lib/metadata/metadata.h | 1 +
lib/metadata/thin_manip.c | 34 +++++++++++++++++++++++++++++++++-
man/lvcreate.8.in | 3 +++
5 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 649607b..ba14c6d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.166 -
=====================================
+ Enforce 4MiB or 25% metadata free space for thin pool operations.
Fix lock-holder device for thin pool with inactive thin volumes.
Use --alloc normal for mirror logs even if the mimages were stricter.
Use O_DIRECT to gather metadata in lvmdump.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d6869e1..1ad85ed 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4515,6 +4515,7 @@ static int _lvresize_adjust_policy(const struct logical_volume *lv,
{
struct cmd_context *cmd = lv->vg->cmd;
dm_percent_t percent;
+ dm_percent_t min_threshold;
int policy_threshold, policy_amount;
*amount = *meta_amount = 0;
@@ -4562,7 +4563,10 @@ static int _lvresize_adjust_policy(const struct logical_volume *lv,
if (!lv_thin_pool_percent(lv, 1, &percent))
return_0;
- *meta_amount = _adjust_amount(percent, policy_threshold, policy_amount);
+ /* Resize below the minimal usable value */
+ min_threshold = pool_metadata_min_threshold(first_seg(lv)) / DM_PERCENT_1;
+ *meta_amount = _adjust_amount(percent, (min_threshold < policy_threshold) ?
+ min_threshold : policy_threshold, policy_amount);
if (!lv_thin_pool_percent(lv, 0, &percent))
return_0;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index e6dc14a..a9eceaa 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -501,6 +501,7 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
int lv_is_merging_thin_snapshot(const struct logical_volume *lv);
int pool_has_message(const struct lv_segment *seg,
const struct logical_volume *lv, uint32_t device_id);
+int pool_metadata_min_threshold(const struct lv_segment *pool_seg);
int pool_below_threshold(const struct lv_segment *pool_seg);
int pool_check_overprovisioning(const struct logical_volume *lv);
int create_pool(struct logical_volume *lv, const struct segment_type *segtype,
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 3b92909..a02a7e6 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -215,9 +215,29 @@ int thin_pool_feature_supported(const struct logical_volume *lv, int feature)
return (attr & feature) ? 1 : 0;
}
+int pool_metadata_min_threshold(const struct lv_segment *pool_seg)
+{
+ /*
+ * Hardcoded minimal requirment for thin pool target.
+ *
+ * In the metadata LV there should be minimum from either 4MiB of free space
+ * or at least 25% of free space, which applies when the size of thin pool's
+ * metadata is less then 16MiB.
+ */
+ const dm_percent_t meta_min = DM_PERCENT_1 * 25;
+ dm_percent_t meta_free = dm_make_percent(((4096 * 1024) >> SECTOR_SHIFT),
+ pool_seg->metadata_lv->size);
+
+ if (meta_min < meta_free)
+ meta_free = meta_min;
+
+ return DM_PERCENT_100 - meta_free;
+}
+
int pool_below_threshold(const struct lv_segment *pool_seg)
{
dm_percent_t percent;
+ dm_percent_t min_threshold = pool_metadata_min_threshold(pool_seg);
dm_percent_t threshold = DM_PERCENT_1 *
find_config_tree_int(pool_seg->lv->vg->cmd, activation_thin_pool_autoextend_threshold_CFG,
lv_config_profile(pool_seg->lv));
@@ -226,7 +246,7 @@ int pool_below_threshold(const struct lv_segment *pool_seg)
if (!lv_thin_pool_percent(pool_seg->lv, 0, &percent))
return_0;
- if (percent > threshold) {
+ if (percent > threshold || percent >= DM_PERCENT_100) {
log_debug("Threshold configured for free data space in "
"thin pool %s has been reached (%.2f%% >= %.2f%%).",
display_lvname(pool_seg->lv),
@@ -239,6 +259,18 @@ int pool_below_threshold(const struct lv_segment *pool_seg)
if (!lv_thin_pool_percent(pool_seg->lv, 1, &percent))
return_0;
+
+ if (percent >= min_threshold) {
+ log_warn("WARNING: Remaining free space in metadata of thin pool %s "
+ "is too low (%.2f%% >= %.2f%%). "
+ "Resize is recommended.",
+ display_lvname(pool_seg->lv),
+ dm_percent_to_float(percent),
+ dm_percent_to_float(min_threshold));
+ return 0;
+ }
+
+
if (percent > threshold) {
log_debug("Threshold configured for free metadata space in "
"thin pool %s has been reached (%.2f%% > %.2f%%).",
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index bf3c33f..84afbda 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -501,6 +501,9 @@ 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).
+To work with a thin pool, there should be at least 25% of free space
+when the size of metadata is smaller then 16MiB,
+or at least 4MiB of free space otherwise.
Default unit is megabytes.
.
.HP
6 years, 6 months
master - thin: report pool as holder when no active thin volume
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=776d5a25b4ab03...
Commit: 776d5a25b4ab036103ec99291cb0056fa61490fa
Parent: c26cd4853668f1da94eb98e18d7a52c93fd21197
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 16 21:47:57 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 19 14:00:56 2016 +0200
thin: report pool as holder when no active thin volume
In the case there is no active thin volume, report thin pool
as lock holder. This fixed function like lvextend
which either expecte lock holder LV is some active thin
or 'possibly' inactive thin pool.
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9c6ba3b..649607b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.166 -
=====================================
+ Fix lock-holder device for thin pool with inactive thin volumes.
Use --alloc normal for mirror logs even if the mimages were stricter.
Use O_DIRECT to gather metadata in lvmdump.
Fix possible NULL pointer derefence when checking for monitoring.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 33129e3..188a255 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -1547,7 +1547,7 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv)
if (lv_is_cow(lv))
return lv_lock_holder(origin_from_cow(lv));
- if (lv_is_thin_pool(lv))
+ if (lv_is_thin_pool(lv)) {
/* Find any active LV from the pool */
dm_list_iterate_items(sl, &lv->segs_using_this_lv)
if (lv_is_active(sl->seg->lv)) {
@@ -1555,6 +1555,8 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv)
display_lvname(lv));
return sl->seg->lv;
}
+ return lv;
+ }
/* RAID changes visibility of splitted LVs but references them still as leg/meta */
if ((lv_is_raid_image(lv) || lv_is_raid_metadata(lv)) && lv_is_visible(lv))
6 years, 6 months
master - libdm: fix end-of-groups test in _stats_walk_end()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c26cd4853668f1...
Commit: c26cd4853668f1da94eb98e18d7a52c93fd21197
Parent: 9c8c8fb63abd1a36b9c448450c9cccfac4c0299e
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Sep 16 13:08:30 2016 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Sep 16 13:09:22 2016 +0100
libdm: fix end-of-groups test in _stats_walk_end()
---
libdm/libdm-stats.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 6932b28..ffd349c 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1543,7 +1543,7 @@ static int _stats_walk_end(const struct dm_stats *dms, uint64_t *flags,
}
if (*flags & DM_STATS_WALK_GROUP) {
- if (*cur_g < dms->max_region)
+ if (*cur_g <= dms->max_region)
goto out;
*flags &= ~DM_STATS_WALK_GROUP;
}
6 years, 6 months
master - alloc: Use --alloc normal for mirror logs.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9c8c8fb63abd1a...
Commit: 9c8c8fb63abd1a36b9c448450c9cccfac4c0299e
Parent: 5da35d879ad073d9fb0d7ec8bfabe9ae39ac5bc1
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Sep 16 02:11:58 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Sep 16 02:11:58 2016 +0100
alloc: Use --alloc normal for mirror logs.
The existing code doesn't understand that mirror logs should cling to
parallel LVs (like extending them) instead of avoiding them.
As a quick workaround to avoid lvcreate failures, hard-code
--alloc normal for mirror logs even if the rest of the allocation
used a stricter policy.
https://bugzilla.redhat.com/show_bug.cgi?id=1376532
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1ef3dc6..9c6ba3b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.166 -
=====================================
+ Use --alloc normal for mirror logs even if the mimages were stricter.
Use O_DIRECT to gather metadata in lvmdump.
Fix possible NULL pointer derefence when checking for monitoring.
Add lvmreport(7) man page.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index dcc8d86..d6869e1 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3085,6 +3085,15 @@ static int _allocate(struct alloc_handle *ah,
if (!_find_max_parallel_space_for_one_policy(ah, &alloc_parms, pvms, &alloc_state))
goto_out;
+ /* As a workaround, if only the log is missing now, fall through and try later policies up to normal. */
+ /* FIXME Change the core algorithm so the log extents cling to parallel LVs instead of avoiding them. */
+ if (alloc_state.allocated == ah->new_extents &&
+ alloc_state.log_area_count_still_needed &&
+ ah->alloc < ALLOC_NORMAL) {
+ ah->alloc = ALLOC_NORMAL;
+ continue;
+ }
+
if ((alloc_state.allocated == ah->new_extents &&
!alloc_state.log_area_count_still_needed) ||
(!can_split && (alloc_state.allocated != old_allocated)))
6 years, 6 months
master - lvmdump: Use O_DIRECT to gather metadata.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5da35d879ad073...
Commit: 5da35d879ad073d9fb0d7ec8bfabe9ae39ac5bc1
Parent: d455300d7baff341f1c7fe5776d975369dd3a23a
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Sep 15 13:59:52 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 15 14:00:39 2016 +0100
lvmdump: Use O_DIRECT to gather metadata.
---
WHATS_NEW | 1 +
configure | 5 +-
configure.in | 2 +
scripts/lvmdump.sh | 356 ------------------------------------------------
scripts/lvmdump.sh.in | 362 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 369 insertions(+), 357 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ba394a4..1ef3dc6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.166 -
=====================================
+ Use O_DIRECT to gather metadata in lvmdump.
Fix possible NULL pointer derefence when checking for monitoring.
Add lvmreport(7) man page.
Don't install lvmraid(7) man page when raid excluded. (2.02.165)
diff --git a/configure b/configure
index 8253bfc..c82a19b 100755
--- a/configure
+++ b/configure
@@ -676,6 +676,7 @@ PTHREAD_LIBS
M_LIBS
POOL
PKGCONFIG
+ODIRECT
OCFDIR
OCF
MIRRORS
@@ -15341,8 +15342,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/lvmdbusd/Makefile daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.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 include/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile lib
daemon/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/com.redhat.lvmdbus1.service 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_lvmdbusd_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_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlock
ing_systemd_red_hat.service 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"
+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/lvmdbusd/Makefile daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.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 include/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile lib
daemon/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/com.redhat.lvmdbus1.service 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_lvmdbusd_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_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlock
ing_systemd_red_hat.service 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/lvmdump.sh 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"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -16109,6 +16111,7 @@ do
"scripts/lvm2_monitoring_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_systemd_red_hat.service" ;;
"scripts/lvm2_pvscan_systemd_red_hat@.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_pvscan_systemd_red_hat@.service" ;;
"scripts/lvm2_tmpfiles_red_hat.conf") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_tmpfiles_red_hat.conf" ;;
+ "scripts/lvmdump.sh") CONFIG_FILES="$CONFIG_FILES scripts/lvmdump.sh" ;;
"scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
"test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
"test/api/Makefile") CONFIG_FILES="$CONFIG_FILES test/api/Makefile" ;;
diff --git a/configure.in b/configure.in
index 33b5c76..cc77aab 100644
--- a/configure.in
+++ b/configure.in
@@ -2068,6 +2068,7 @@ AC_SUBST(MIRRORS)
AC_SUBST(MSGFMT)
AC_SUBST(OCF)
AC_SUBST(OCFDIR)
+AC_SUBST(ODIRECT)
AC_SUBST(PKGCONFIG)
AC_SUBST(POOL)
AC_SUBST(M_LIBS)
@@ -2213,6 +2214,7 @@ 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/lvmdump.sh
scripts/Makefile
test/Makefile
test/api/Makefile
diff --git a/scripts/lvmdump.sh b/scripts/lvmdump.sh
deleted file mode 100755
index 85f8e5c..0000000
--- a/scripts/lvmdump.sh
+++ /dev/null
@@ -1,356 +0,0 @@
-#!/bin/bash
-# We use some bash-isms (getopts?)
-
-# Copyright (C) 2007-2015 Red Hat, Inc. All rights reserved.
-#
-# This file is part of LVM2.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-# lvm_dump: This script is used to collect pertinent information for
-# the debugging of lvm issues.
-
-# following external commands are used throughout the script
-# echo and test are internal in bash at least
-MKDIR=mkdir # need -p
-TAR=tar # need czf
-RM=rm # need -rf
-CP=cp
-TAIL=tail # we need -n
-LS=ls # need -la
-PS=ps # need alx
-SED=sed
-DD=dd
-CUT=cut
-GREP=grep
-DATE=date
-BASENAME=basename
-UDEVADM=udevadm
-UNAME=uname
-TR=tr
-SOCAT=socat # either socat or nc is needed for dumping lvmetad state
-NC=nc
-
-# user may override lvm and dmsetup location by setting LVM_BINARY
-# and DMSETUP_BINARY respectively
-LVM=${LVM_BINARY-lvm}
-DMSETUP=${DMSETUP_BINARY-dmsetup}
-LVMETAD_SOCKET=${LVM_LVMETAD_SOCKET-/var/run/lvm/lvmetad.socket}
-LVMPOLLD_SOCKET=${LVM_LVMPOLLD_SOCKET-/var/run/lvm/lvmpolld.socket}
-
-die() {
- code=$1; shift
- echo "$@" 1>&2
- exit $code
-}
-
-"$LVM" version >& /dev/null || die 2 "Could not run lvm binary '$LVM'"
-"$DMSETUP" version >& /dev/null || DMSETUP=:
-
-function usage {
- echo "$0 [options]"
- echo " -h print this message"
- echo " -a advanced collection - warning: if lvm is already hung,"
- echo " then this script may hang as well if -a is used"
- echo " -c if running clvmd, gather cluster data as well"
- echo " -d <directory> dump into a directory instead of tarball"
- echo " -l gather lvmetad state if running"
- echo " -p gather lvmpolld state if running"
- echo " -m gather LVM metadata from the PVs"
- echo " -s gather system info and context"
- echo " -u gather udev info and context"
- echo ""
-
- exit 1
-}
-
-advanced=0
-clustered=0
-metadata=0
-sysreport=0
-udev=0
-while getopts :acd:hlpmus opt; do
- case $opt in
- a) advanced=1 ;;
- c) clustered=1 ;;
- d) userdir=$OPTARG ;;
- h) usage ;;
- l) lvmetad=1 ;;
- p) lvmpolld=1 ;;
- m) metadata=1 ;;
- s) sysreport=1 ;;
- u) udev=1 ;;
- :) echo "$0: $OPTARG requires a value:"; usage ;;
- \?) echo "$0: unknown option $OPTARG"; usage ;;
- *) usage ;;
- esac
-done
-
-NOW=`$DATE -u +%G%m%d%k%M%S | $TR -d ' '`
-if test -n "$userdir"; then
- dir="$userdir"
-else
- dirbase="lvmdump-$HOSTNAME-$NOW"
- dir="$HOME/$dirbase"
-fi
-
-if test -d $dir ; then
- (shopt -s nullglob dotglob; test -r $dir -a -w $dir -a -x $dir && cd $dir && files=(*) && ((! ${#files[@]}))) || \
- die 5 "Fatal: directory $dir already exists and is not empty or inaccessible"
-else
- test -e $dir && die 3 "Fatal: $dir already exists"
- $MKDIR -p $dir || die 4 "Fatal: could not create $dir"
-fi
-
-log="$dir/lvmdump.log"
-
-myecho() {
- echo "$@"
- echo "$@" >> "$log"
-}
-
-log() {
- echo "$@" >> "$log"
- eval "$@"
-}
-
-warnings() {
- if test "$UID" != "0" && test "$EUID" != "0"; then
- myecho "WARNING! Running as non-privileged user, dump is likely incomplete!"
- elif test "$DMSETUP" = ":"; then
- myecho "WARNING! Could not run dmsetup, dump is likely incomplete."
- fi
-}
-
-warnings
-
-myecho "Creating dump directory: $dir"
-echo " "
-
-if (( $advanced )); then
- myecho "Gathering LVM volume info..."
-
- myecho " vgscan..."
- log "\"$LVM\" vgscan -vvvv >> \"$dir/vgscan\" 2>&1"
-
- myecho " pvscan..."
- log "\"$LVM\" pvscan -v >> \"$dir/pvscan\" 2>> \"$log\""
-
- myecho " lvs..."
- log "\"$LVM\" lvs -a -H -o +devices,kernel_major,kernel_minor >> \"$dir/lvs\" 2>> \"$log\""
-
- myecho " pvs..."
- log "\"$LVM\" pvs -a -o +major,minor -v >> \"$dir/pvs\" 2>> \"$log\""
-
- myecho " vgs..."
- log "\"$LVM\" vgs -v >> \"$dir/vgs\" 2>> \"$log\""
-fi
-
-if (( $clustered )); then
- myecho "Gathering cluster info..."
-
- {
- for i in nodes status services; do
- cap_i=$(echo $i|tr a-z A-Z)
- printf "$cap_i:\n----------------------------------\n"
- log "cman_tool $i 2>> \"$log\""
- echo
- done
-
- echo "LOCKS:"
- echo "----------------------------------"
- if [ -f /proc/cluster/dlm_locks ]
- then
- echo clvmd > /proc/cluster/dlm_locks
- cat /proc/cluster/dlm_locks
- echo
- echo "RESOURCE DIR:"
- cat /proc/cluster/dlm_dir
- echo
- echo "DEBUG LOG:"
- cat /proc/cluster/dlm_debug
- echo
- fi
- if [ -f /debug/dlm/clvmd ]
- then
- cat /debug/dlm/clvmd
- echo
- echo "WAITERS:"
- cat /debug/dlm/clvmd_waiters
- echo
- echo "MASTER:"
- cat /debug/dlm/clvmd_master
- fi
- } >> $dir/cluster_info
-fi
-
-myecho "Gathering LVM & device-mapper version info..."
-echo "LVM VERSION:" >> "$dir/versions"
-"$LVM" lvs --version >> "$dir/versions" 2>> "$log"
-echo "DEVICE MAPPER VERSION:" >> "$dir/versions"
-"$DMSETUP" --version >> "$dir/versions" 2>> "$log"
-echo "KERNEL VERSION:" >> "$dir/versions"
-"$UNAME" -a >> "$dir/versions" 2>> "$log"
-echo "DM TARGETS VERSIONS:" >> "$dir/versions"
-"$DMSETUP" targets >> "$dir/versions" 2>> "$log"
-
-myecho "Gathering dmsetup info..."
-log "\"$DMSETUP\" info -c >> \"$dir/dmsetup_info\" 2>> \"$log\""
-log "\"$DMSETUP\" table >> \"$dir/dmsetup_table\" 2>> \"$log\""
-log "\"$DMSETUP\" status >> \"$dir/dmsetup_status\" 2>> \"$log\""
-
-# cat as workaround to avoid tty ioctl (selinux)
-log "\"$DMSETUP\" ls --tree 2>> \"$log\" | cat >> \"$dir/dmsetup_ls_tree\""
-
-myecho "Gathering process info..."
-log "$PS alx >> \"$dir/ps_info\" 2>> \"$log\""
-
-myecho "Gathering console messages..."
-log "$TAIL -n 75 /var/log/messages >> \"$dir/messages\" 2>> \"$log\""
-
-myecho "Gathering /etc/lvm info..."
-log "$LS -laR /etc/lvm >> \"$dir/etc_lvm_listing\" 2>> \"$log\""
-log "$CP -RL --preserve=all /etc/lvm \"$dir/lvm\" 2>> \"$log\""
-log "$LVM dumpconfig --type diff --file \"$dir/config_diff\" 2>> \"$log\""
-log "$LVM dumpconfig --type missing --file \"$dir/config_missing\" 2>> \"$log\""
-
-myecho "Gathering /dev listing..."
-log "$LS -laR /dev >> \"$dir/dev_listing\" 2>> \"$log\""
-
-myecho "Gathering /sys/block listing..."
-log "$LS -laR /sys/block >> \"$dir/sysblock_listing\" 2>> \"$log\""
-log "$LS -laR /sys/devices/virtual/block >> \"$dir/sysblock_listing\" 2>> \"$log\""
-
-if (( $metadata )); then
- myecho "Gathering LVM metadata from Physical Volumes..."
-
- log "$MKDIR -p \"$dir/metadata\""
-
- pvs="$("$LVM" pvs --separator , --noheadings --units s --nosuffix -o \
- name,pe_start 2>> "$log" | $SED -e 's/^ *//')"
- for line in $pvs
- do
- test -z "$line" && continue
- pv="$(echo $line | $CUT -d, -f1)"
- pe_start="$(echo $line | $CUT -d, -f2)"
- name="$($BASENAME "$pv")"
- myecho " $pv"
- log "$DD if=$pv \"of=$dir/metadata/$name\" bs=512 count=$pe_start 2>> \"$log\""
- done
-fi
-
-if (( $sysreport )); then
- myecho "Gathering system info..."
-
- sysreport_dir="$dir/sysreport"
- log_lines=10000
-
- SYSTEMCTL=$(which systemctl 2>> $log)
- JOURNALCTL=$(which journalctl 2>> $log)
- LSBLK=$(which lsblk 2>> $log)
-
- log "$MKDIR -p \"$sysreport_dir\""
-
- if test -z "LSBLK"; then
- myecho "WARNING: lsblk not found"
- else
- if $LSBLK --help | $GREP -- --output-all >/dev/null; then
- log "$LSBLK -O >> \"$sysreport_dir/lsblk_O\""
- else
- log "$LSBLK >> \"$sysreport_dir/lsblk\""
- fi
- if $LSBLK --help | $GREP -- --inverse >/dev/null; then
- log "$LSBLK -s >> \"$sysreport_dir/lsblk_s\""
- fi
- fi
-
- if test -z "$SYSTEMCTL"; then
- myecho "WARNING: systemctl not found"
- elif test -z "$JOURNALCTL"; then
- myecho "WARNING: journalctl not found"
- else
- log "$JOURNALCTL -b --no-pager -o short-precise > \"$sysreport_dir/journal_content\" 2>> \"$log\""
- log "$SYSTEMCTL status -l --no-pager -n $log_lines -o short-precise dm-event.socket dm-event.service \
- lvm2-monitor.service \
- lvm2-lvmetad.socket lvm2-lvmetad.service \
- lvm2-lvmpolld.socket lvm2-lvmpolld.service \
- lvm2-cluster-activation.service \
- lvm2-clvmd.service \
- lvm2-cmirrord.service \
- lvm2-activation-early.service \
- lvm2-activation.service \
- lvm2-activation-net.service \
- > \"$sysreport_dir/systemd_lvm2_services_status\" 2>> \"$log\""
- log "$SYSTEMCTL list-units -l -a --no-legend --no-pager > \"$sysreport_dir/systemd_unit_list\" 2>> \"$log\""
- for unit in $(cat $sysreport_dir/systemd_unit_list | $GREP lvm2-pvscan | cut -d " " -f 1); do
- log "$SYSTEMCTL status -l --no-pager -n $log_lines -o short-precise $unit >> \"$sysreport_dir/systemd_lvm2_pvscan_service_status\""
- done
- fi
-fi
-
-if (( $udev )); then
- myecho "Gathering udev info..."
-
- udev_dir="$dir/udev"
-
- log "$MKDIR -p \"$udev_dir\""
- log "$UDEVADM info --version >> \"$udev_dir/version\" 2>> \"$log\""
- log "$UDEVADM info --export-db >> \"$udev_dir/db\" 2>> \"$log\""
- log "$CP -a /etc/udev/udev.conf \"$udev_dir/conf\" 2>> \"$log\""
- log "$LS -la /lib/udev >> \"$udev_dir/lib_dir\" 2>> \"$log\""
- log "$CP -RL --preserve=all /etc/udev/rules.d \"$udev_dir/rules_etc\" 2>> \"$log\""
- log "$CP -RL --preserve=all /lib/udev/rules.d \"$udev_dir/rules_lib\" 2>> \"$log\""
-fi
-
-if (( $lvmetad )); then
- (echo 'request="dump"'; echo '##') | {
- if type -p $SOCAT >& /dev/null; then
- echo "$SOCAT unix-connect:$LVMETAD_SOCKET -" >> "$log"
- $SOCAT "unix-connect:$LVMETAD_SOCKET" - 2>> "$log"
- elif echo | $NC -U "$LVMETAD_SOCKET"; then
- echo "$NC -U $LVMETAD_SOCKET" >> "$log"
- $NC -U "$LVMETAD_SOCKET" 2>> "$log"
- else
- myecho "WARNING: Neither socat nor nc -U seems to be available." 1>&2
- echo "# DUMP FAILED"
- return 1
- fi
- } > "$dir/lvmetad.txt"
-fi
-
-if (( $lvmpolld )); then
- (echo 'request="dump"'; echo '##') | {
- if type -p $SOCAT >& /dev/null; then
- echo "$SOCAT unix-connect:$LVMPOLLD_SOCKET -" >> "$log"
- $SOCAT "unix-connect:$LVMPOLLD_SOCKET" - 2>> "$log"
- elif echo | $NC -U "$LVMPOLLD_SOCKET"; then
- echo "$NC -U $LVMPOLLD_SOCKET" >> "$log"
- $NC -U "$LVMPOLLD_SOCKET" 2>> "$log"
- else
- myecho "WARNING: Neither socat nor nc -U seems to be available." 1>&2
- echo "# DUMP FAILED"
- return 1
- fi
- } > "$dir/lvmpolld.txt"
-fi
-
-if test -z "$userdir"; then
- lvm_dump="$dirbase.tgz"
- myecho "Creating report tarball in $HOME/$lvm_dump..."
-fi
-
-warnings
-
-if test -z "$userdir"; then
- cd "$HOME"
- "$TAR" czf "$lvm_dump" "$dirbase" 2>/dev/null
- "$RM" -rf "$dir"
-fi
-
-exit 0
diff --git a/scripts/lvmdump.sh.in b/scripts/lvmdump.sh.in
new file mode 100644
index 0000000..6467863
--- /dev/null
+++ b/scripts/lvmdump.sh.in
@@ -0,0 +1,362 @@
+#!/bin/bash
+# We use some bash-isms (getopts?)
+
+# Copyright (C) 2007-2015 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# lvm_dump: This script is used to collect pertinent information for
+# the debugging of lvm issues.
+
+# following external commands are used throughout the script
+# echo and test are internal in bash at least
+MKDIR=mkdir # need -p
+TAR=tar # need czf
+RM=rm # need -rf
+CP=cp
+TAIL=tail # we need -n
+LS=ls # need -la
+PS=ps # need alx
+SED=sed
+DD=dd
+CUT=cut
+GREP=grep
+DATE=date
+BASENAME=basename
+UDEVADM=udevadm
+UNAME=uname
+TR=tr
+SOCAT=socat # either socat or nc is needed for dumping lvmetad state
+NC=nc
+
+if test "@ODIRECT@" = yes; then
+ DDFLAGS='iflag=direct oflag=direct'
+else
+ DDFLAGS=
+fi
+
+# user may override lvm and dmsetup location by setting LVM_BINARY
+# and DMSETUP_BINARY respectively
+LVM=${LVM_BINARY-lvm}
+DMSETUP=${DMSETUP_BINARY-dmsetup}
+LVMETAD_SOCKET=${LVM_LVMETAD_SOCKET-/var/run/lvm/lvmetad.socket}
+LVMPOLLD_SOCKET=${LVM_LVMPOLLD_SOCKET-/var/run/lvm/lvmpolld.socket}
+
+die() {
+ code=$1; shift
+ echo "$@" 1>&2
+ exit $code
+}
+
+"$LVM" version >& /dev/null || die 2 "Could not run lvm binary '$LVM'"
+"$DMSETUP" version >& /dev/null || DMSETUP=:
+
+function usage {
+ echo "$0 [options]"
+ echo " -h print this message"
+ echo " -a advanced collection - warning: if lvm is already hung,"
+ echo " then this script may hang as well if -a is used"
+ echo " -c if running clvmd, gather cluster data as well"
+ echo " -d <directory> dump into a directory instead of tarball"
+ echo " -l gather lvmetad state if running"
+ echo " -p gather lvmpolld state if running"
+ echo " -m gather LVM metadata from the PVs"
+ echo " -s gather system info and context"
+ echo " -u gather udev info and context"
+ echo ""
+
+ exit 1
+}
+
+advanced=0
+clustered=0
+metadata=0
+sysreport=0
+udev=0
+while getopts :acd:hlpmus opt; do
+ case $opt in
+ a) advanced=1 ;;
+ c) clustered=1 ;;
+ d) userdir=$OPTARG ;;
+ h) usage ;;
+ l) lvmetad=1 ;;
+ p) lvmpolld=1 ;;
+ m) metadata=1 ;;
+ s) sysreport=1 ;;
+ u) udev=1 ;;
+ :) echo "$0: $OPTARG requires a value:"; usage ;;
+ \?) echo "$0: unknown option $OPTARG"; usage ;;
+ *) usage ;;
+ esac
+done
+
+NOW=`$DATE -u +%G%m%d%k%M%S | $TR -d ' '`
+if test -n "$userdir"; then
+ dir="$userdir"
+else
+ dirbase="lvmdump-$HOSTNAME-$NOW"
+ dir="$HOME/$dirbase"
+fi
+
+if test -d $dir ; then
+ (shopt -s nullglob dotglob; test -r $dir -a -w $dir -a -x $dir && cd $dir && files=(*) && ((! ${#files[@]}))) || \
+ die 5 "Fatal: directory $dir already exists and is not empty or inaccessible"
+else
+ test -e $dir && die 3 "Fatal: $dir already exists"
+ $MKDIR -p $dir || die 4 "Fatal: could not create $dir"
+fi
+
+log="$dir/lvmdump.log"
+
+myecho() {
+ echo "$@"
+ echo "$@" >> "$log"
+}
+
+log() {
+ echo "$@" >> "$log"
+ eval "$@"
+}
+
+warnings() {
+ if test "$UID" != "0" && test "$EUID" != "0"; then
+ myecho "WARNING! Running as non-privileged user, dump is likely incomplete!"
+ elif test "$DMSETUP" = ":"; then
+ myecho "WARNING! Could not run dmsetup, dump is likely incomplete."
+ fi
+}
+
+warnings
+
+myecho "Creating dump directory: $dir"
+echo " "
+
+if (( $advanced )); then
+ myecho "Gathering LVM volume info..."
+
+ myecho " vgscan..."
+ log "\"$LVM\" vgscan -vvvv >> \"$dir/vgscan\" 2>&1"
+
+ myecho " pvscan..."
+ log "\"$LVM\" pvscan -v >> \"$dir/pvscan\" 2>> \"$log\""
+
+ myecho " lvs..."
+ log "\"$LVM\" lvs -a -H -o +devices,kernel_major,kernel_minor >> \"$dir/lvs\" 2>> \"$log\""
+
+ myecho " pvs..."
+ log "\"$LVM\" pvs -a -o +major,minor -v >> \"$dir/pvs\" 2>> \"$log\""
+
+ myecho " vgs..."
+ log "\"$LVM\" vgs -v >> \"$dir/vgs\" 2>> \"$log\""
+fi
+
+if (( $clustered )); then
+ myecho "Gathering cluster info..."
+
+ {
+ for i in nodes status services; do
+ cap_i=$(echo $i|tr a-z A-Z)
+ printf "$cap_i:\n----------------------------------\n"
+ log "cman_tool $i 2>> \"$log\""
+ echo
+ done
+
+ echo "LOCKS:"
+ echo "----------------------------------"
+ if [ -f /proc/cluster/dlm_locks ]
+ then
+ echo clvmd > /proc/cluster/dlm_locks
+ cat /proc/cluster/dlm_locks
+ echo
+ echo "RESOURCE DIR:"
+ cat /proc/cluster/dlm_dir
+ echo
+ echo "DEBUG LOG:"
+ cat /proc/cluster/dlm_debug
+ echo
+ fi
+ if [ -f /debug/dlm/clvmd ]
+ then
+ cat /debug/dlm/clvmd
+ echo
+ echo "WAITERS:"
+ cat /debug/dlm/clvmd_waiters
+ echo
+ echo "MASTER:"
+ cat /debug/dlm/clvmd_master
+ fi
+ } >> $dir/cluster_info
+fi
+
+myecho "Gathering LVM & device-mapper version info..."
+echo "LVM VERSION:" >> "$dir/versions"
+"$LVM" lvs --version >> "$dir/versions" 2>> "$log"
+echo "DEVICE MAPPER VERSION:" >> "$dir/versions"
+"$DMSETUP" --version >> "$dir/versions" 2>> "$log"
+echo "KERNEL VERSION:" >> "$dir/versions"
+"$UNAME" -a >> "$dir/versions" 2>> "$log"
+echo "DM TARGETS VERSIONS:" >> "$dir/versions"
+"$DMSETUP" targets >> "$dir/versions" 2>> "$log"
+
+myecho "Gathering dmsetup info..."
+log "\"$DMSETUP\" info -c >> \"$dir/dmsetup_info\" 2>> \"$log\""
+log "\"$DMSETUP\" table >> \"$dir/dmsetup_table\" 2>> \"$log\""
+log "\"$DMSETUP\" status >> \"$dir/dmsetup_status\" 2>> \"$log\""
+
+# cat as workaround to avoid tty ioctl (selinux)
+log "\"$DMSETUP\" ls --tree 2>> \"$log\" | cat >> \"$dir/dmsetup_ls_tree\""
+
+myecho "Gathering process info..."
+log "$PS alx >> \"$dir/ps_info\" 2>> \"$log\""
+
+myecho "Gathering console messages..."
+log "$TAIL -n 75 /var/log/messages >> \"$dir/messages\" 2>> \"$log\""
+
+myecho "Gathering /etc/lvm info..."
+log "$LS -laR /etc/lvm >> \"$dir/etc_lvm_listing\" 2>> \"$log\""
+log "$CP -RL --preserve=all /etc/lvm \"$dir/lvm\" 2>> \"$log\""
+log "$LVM dumpconfig --type diff --file \"$dir/config_diff\" 2>> \"$log\""
+log "$LVM dumpconfig --type missing --file \"$dir/config_missing\" 2>> \"$log\""
+
+myecho "Gathering /dev listing..."
+log "$LS -laR /dev >> \"$dir/dev_listing\" 2>> \"$log\""
+
+myecho "Gathering /sys/block listing..."
+log "$LS -laR /sys/block >> \"$dir/sysblock_listing\" 2>> \"$log\""
+log "$LS -laR /sys/devices/virtual/block >> \"$dir/sysblock_listing\" 2>> \"$log\""
+
+if (( $metadata )); then
+ myecho "Gathering LVM metadata from Physical Volumes..."
+
+ log "$MKDIR -p \"$dir/metadata\""
+
+ pvs="$("$LVM" pvs --separator , --noheadings --units s --nosuffix -o \
+ name,pe_start 2>> "$log" | $SED -e 's/^ *//')"
+ for line in $pvs
+ do
+ test -z "$line" && continue
+ pv="$(echo $line | $CUT -d, -f1)"
+ pe_start="$(echo $line | $CUT -d, -f2)"
+ name="$($BASENAME "$pv")"
+ myecho " $pv"
+ log "$DD if=$pv \"of=$dir/metadata/$name\" $DDFLAGS bs=512 count=$pe_start 2>> \"$log\""
+ done
+fi
+
+if (( $sysreport )); then
+ myecho "Gathering system info..."
+
+ sysreport_dir="$dir/sysreport"
+ log_lines=10000
+
+ SYSTEMCTL=$(which systemctl 2>> $log)
+ JOURNALCTL=$(which journalctl 2>> $log)
+ LSBLK=$(which lsblk 2>> $log)
+
+ log "$MKDIR -p \"$sysreport_dir\""
+
+ if test -z "LSBLK"; then
+ myecho "WARNING: lsblk not found"
+ else
+ if $LSBLK --help | $GREP -- --output-all >/dev/null; then
+ log "$LSBLK -O >> \"$sysreport_dir/lsblk_O\""
+ else
+ log "$LSBLK >> \"$sysreport_dir/lsblk\""
+ fi
+ if $LSBLK --help | $GREP -- --inverse >/dev/null; then
+ log "$LSBLK -s >> \"$sysreport_dir/lsblk_s\""
+ fi
+ fi
+
+ if test -z "$SYSTEMCTL"; then
+ myecho "WARNING: systemctl not found"
+ elif test -z "$JOURNALCTL"; then
+ myecho "WARNING: journalctl not found"
+ else
+ log "$JOURNALCTL -b --no-pager -o short-precise > \"$sysreport_dir/journal_content\" 2>> \"$log\""
+ log "$SYSTEMCTL status -l --no-pager -n $log_lines -o short-precise dm-event.socket dm-event.service \
+ lvm2-monitor.service \
+ lvm2-lvmetad.socket lvm2-lvmetad.service \
+ lvm2-lvmpolld.socket lvm2-lvmpolld.service \
+ lvm2-cluster-activation.service \
+ lvm2-clvmd.service \
+ lvm2-cmirrord.service \
+ lvm2-activation-early.service \
+ lvm2-activation.service \
+ lvm2-activation-net.service \
+ > \"$sysreport_dir/systemd_lvm2_services_status\" 2>> \"$log\""
+ log "$SYSTEMCTL list-units -l -a --no-legend --no-pager > \"$sysreport_dir/systemd_unit_list\" 2>> \"$log\""
+ for unit in $(cat $sysreport_dir/systemd_unit_list | $GREP lvm2-pvscan | cut -d " " -f 1); do
+ log "$SYSTEMCTL status -l --no-pager -n $log_lines -o short-precise $unit >> \"$sysreport_dir/systemd_lvm2_pvscan_service_status\""
+ done
+ fi
+fi
+
+if (( $udev )); then
+ myecho "Gathering udev info..."
+
+ udev_dir="$dir/udev"
+
+ log "$MKDIR -p \"$udev_dir\""
+ log "$UDEVADM info --version >> \"$udev_dir/version\" 2>> \"$log\""
+ log "$UDEVADM info --export-db >> \"$udev_dir/db\" 2>> \"$log\""
+ log "$CP -a /etc/udev/udev.conf \"$udev_dir/conf\" 2>> \"$log\""
+ log "$LS -la /lib/udev >> \"$udev_dir/lib_dir\" 2>> \"$log\""
+ log "$CP -RL --preserve=all /etc/udev/rules.d \"$udev_dir/rules_etc\" 2>> \"$log\""
+ log "$CP -RL --preserve=all /lib/udev/rules.d \"$udev_dir/rules_lib\" 2>> \"$log\""
+fi
+
+if (( $lvmetad )); then
+ (echo 'request="dump"'; echo '##') | {
+ if type -p $SOCAT >& /dev/null; then
+ echo "$SOCAT unix-connect:$LVMETAD_SOCKET -" >> "$log"
+ $SOCAT "unix-connect:$LVMETAD_SOCKET" - 2>> "$log"
+ elif echo | $NC -U "$LVMETAD_SOCKET"; then
+ echo "$NC -U $LVMETAD_SOCKET" >> "$log"
+ $NC -U "$LVMETAD_SOCKET" 2>> "$log"
+ else
+ myecho "WARNING: Neither socat nor nc -U seems to be available." 1>&2
+ echo "# DUMP FAILED"
+ return 1
+ fi
+ } > "$dir/lvmetad.txt"
+fi
+
+if (( $lvmpolld )); then
+ (echo 'request="dump"'; echo '##') | {
+ if type -p $SOCAT >& /dev/null; then
+ echo "$SOCAT unix-connect:$LVMPOLLD_SOCKET -" >> "$log"
+ $SOCAT "unix-connect:$LVMPOLLD_SOCKET" - 2>> "$log"
+ elif echo | $NC -U "$LVMPOLLD_SOCKET"; then
+ echo "$NC -U $LVMPOLLD_SOCKET" >> "$log"
+ $NC -U "$LVMPOLLD_SOCKET" 2>> "$log"
+ else
+ myecho "WARNING: Neither socat nor nc -U seems to be available." 1>&2
+ echo "# DUMP FAILED"
+ return 1
+ fi
+ } > "$dir/lvmpolld.txt"
+fi
+
+if test -z "$userdir"; then
+ lvm_dump="$dirbase.tgz"
+ myecho "Creating report tarball in $HOME/$lvm_dump..."
+fi
+
+warnings
+
+if test -z "$userdir"; then
+ cd "$HOME"
+ "$TAR" czf "$lvm_dump" "$dirbase" 2>/dev/null
+ "$RM" -rf "$dir"
+fi
+
+exit 0
6 years, 6 months