Skip to contentSkip to conversation

master - cache: fix lock usage for cache conversion

PATCH Zdenek Kabelac 1 participant 1 message Mar 8, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ee37838b1149f3f8d5c34dc2d459421f8e085bbb
Commit:        ee37838b1149f3f8d5c34dc2d459421f8e085bbb
Parent:        7421252edccead6ce395cabc361ed175236bcb5c
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Mar 8 10:30:46 2018 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Mar 8 10:39:47 2018 +0100

cache: fix lock usage for cache conversion

Just like with lvcreate, this lvconvert case also need to properly check which LV actually holds lock for cached origin - as it might be i.e. thin-pool tdata subLV.

---
 lib/metadata/lv_manip.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
lib/metadata/lv_manip.c +4 -2
index bde2a00..9566f3e 100644
@@ -7384,6 +7384,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
 	struct logical_volume *lv, *origin_lv = NULL;
 	struct logical_volume *pool_lv = NULL;
 	struct logical_volume *tmp_lv;
+	const struct logical_volume *lock_lv;
 	struct lv_segment *seg, *pool_seg;
 	int thin_pool_was_active = -1; /* not scanned, inactive, active */
 	int historical;
@@ -7547,11 +7548,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
 		}
 
 		/* Validate cache origin is exclusively active */
+		lock_lv = lv_lock_holder(origin_lv);
 		if (vg_is_clustered(origin_lv->vg) &&
 		    locking_is_clustered() &&
 		    locking_supports_remote_queries() &&
-		    lv_is_active(origin_lv) &&
-		    !lv_is_active_exclusive(origin_lv)) {
+		    lv_is_active(lock_lv) &&
+		    !lv_is_active_exclusive(lock_lv)) {
 			log_error("Cannot cache not exclusively active origin volume %s.",
 				  display_lvname(origin_lv));
 			return NULL;