Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e02e5b0c5bb3b61a21f4f…
Commit: e02e5b0c5bb3b61a21f4fe2be7f35d2f30054a10
Parent: 9bd7615fef1e4526bcc2c9fea67d2d038db6d917
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 11 12:41:28 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 11 14:24:28 2017 +0200
activation: fix activation lock
Activation lock has a primary purpose to serialize locking of individual
LV in case there is no other protecting mechanism for parallel
execution.
However in the case an activated LV is composed from several other LVs,
noone should be able to manipulate with those LVs as well.
This patch add a very 'naive' global VG activation locking in this case.
In the future we may introduce smarter function detecting minimal closed
graph components if this will appear as bottleneck
Patch checks if the VG Write lock is held - in this case we do not
need any more locking - command has exclusive access to VG.
In case we have clustered VG and we are activating an LV which does not
need other LVs - we also do not need any more locks.
In all other cases take respective lock - for single LV - use lvid,
for complex LVs use vgname.
---
WHATS_NEW | 1 +
lib/locking/locking.h | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5345f7c..e392722 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Improve selection of resource name for activation lock.
Avoid cutting 1st. character of resource name for activation lock.
Support for encrypted devices in fsadm.
Improve thin pool overprovisioning and repair warning messages.
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 18bce2d..10c26b2 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -174,14 +174,20 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
/*
* Activation locks are wrapped around activation commands that have to
* be processed atomically one-at-a-time.
- * If a VG WRITE lock is held, an activation lock is redundant.
+ * If a VG WRITE lock is held or clustered activation activates simple LV
+ * an activation lock is redundant.
*
- * FIXME Test and support this for thin and cache types.
- * FIXME Add cluster support.
+ * Some LV types do require taking a lock common for whole group of LVs.
+ * TODO: For simplicity reasons ATM take a VG activation global lock and
+ * later more fine-grained component detection algorithm can be added
*/
-#define lv_supports_activation_locking(lv) (!vg_is_clustered((lv)->vg) && !lv_is_thin_type(lv) && !lv_is_cache_type(lv))
-#define lock_activation(cmd, lv) (vg_write_lock_held() && lv_supports_activation_locking(lv) ? 1 : lock_vol(cmd, (lv)->lvid.s, LCK_ACTIVATE_LOCK, lv))
-#define unlock_activation(cmd, lv) (vg_write_lock_held() && lv_supports_activation_locking(lv) ? 1 : lock_vol(cmd, (lv)->lvid.s, LCK_ACTIVATE_UNLOCK, lv))
+
+#define lv_type_requires_activation_lock(lv) ((lv_is_thin_type(lv) || lv_is_cache_type(lv) || lv_is_mirror_type(lv) || lv_is_raid_type(lv) || lv_is_origin(lv) || lv_is_snapshot(lv)) ? 1 : 0)
+#define lv_activation_lock_name(lv) (lv_type_requires_activation_lock(lv) ? (lv)->vg->name : (lv)->lvid.s)
+#define lv_requires_activation_lock_now(lv) ((!vg_write_lock_held() && (!vg_is_clustered((lv)->vg) || !lv_type_requires_activation_lock(lv))) ? 1 : 0)
+
+#define lock_activation(cmd, lv) (lv_requires_activation_lock_now(lv) ? lock_vol(cmd, lv_activation_lock_name(lv), LCK_ACTIVATE_LOCK, lv) : 1)
+#define unlock_activation(cmd, lv) (lv_requires_activation_lock_now(lv) ? lock_vol(cmd, lv_activation_lock_name(lv), LCK_ACTIVATE_UNLOCK, lv) : 1)
/*
* Place temporary exclusive 'activation' lock around an LV locking operation
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=22789563dec6d470a48e7…
Commit: 22789563dec6d470a48e728305e6e0a92ff92a9f
Parent: 3a639d81445a00974c5ccfd877a197adf5607b22
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Oct 9 19:48:00 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Oct 9 19:48:00 2017 +0100
thin: Improve overprovisioning and repair warnings.
---
WHATS_NEW | 1 +
lib/metadata/thin_manip.c | 9 ++++++---
tools/lvconvert.c | 9 +++++----
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7899365..4314c69 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Improve thin pool overprovisioning and repair warning messages.
Version 2.02.175 - 6th October 2017
===================================
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index bd2d2c3..3dfbcc1 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -365,16 +365,19 @@ int pool_check_overprovisioning(const struct logical_volume *lv)
if (sz != UINT64_C(~0)) {
log_warn("WARNING: Sum of all thin volume sizes (%s) exceeds the "
- "size of thin pool%s%s%s (%s)!",
+ "size of thin pool%s%s%s (%s).",
display_size(cmd, thinsum),
more_pools ? "" : " ",
more_pools ? "s" : display_lvname(pool_lv),
txt,
(sz > 0) ? display_size(cmd, sz) : "no free space in volume group");
+ if (max_threshold > 99 || !min_percent)
+ log_print_unless_silent("WARNING: You have not turned on protection against thin pools running out of space.");
if (max_threshold > 99)
- log_print_unless_silent("For thin pool auto extension activation/thin_pool_autoextend_threshold should be below 100.");
+ log_print_unless_silent("WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.");
if (!min_percent)
- log_print_unless_silent("For thin pool auto extension activation/thin_pool_autoextend_percent should be above 0.");
+ log_print_unless_silent("WARNING: Set activation/thin_pool_autoextend_percent above 0 to specify by how much to extend thin pools reaching the threshold.");
+ /* FIXME Also warn if there isn't sufficient free space for one pool extension to occur? */
}
return 1;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 77d9174..28909dd 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2272,7 +2272,7 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
argv[++args] = NULL;
if (pool_is_active(pool_lv)) {
- log_error("Only inactive pool can be repaired.");
+ log_error("Active pools cannot be repaired. Use lvchange -an first.");
return 0;
}
@@ -2377,11 +2377,12 @@ deactivate_pmslv:
if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
return_0;
- log_warn("WARNING: If everything works, remove %s volume.",
+ log_warn("WARNING: LV %s holds a backup of the unrepaired metadata. Use lvremove when no longer required.",
display_lvname(mlv));
- log_warn("WARNING: Use pvmove command to move %s on the best fitting PV.",
- display_lvname(first_seg(pool_lv)->metadata_lv));
+ if (dm_list_size(&pool_lv->vg->pvs) > 1)
+ log_warn("WARNING: New metadata LV %s might use different PVs. Move it with pvmove if required.",
+ display_lvname(first_seg(pool_lv)->metadata_lv));
return 1;
}