Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a30adc062b30ef4…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0e8449a5b921e60e…
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;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c2c2721d0082d79f…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=776d5a25b4ab0361…
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))
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9c8c8fb63abd1a36…
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)))