mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_09-writecache-working-real-dm-uuid-suffix-for-wcorig-lv.patch

22b171
 lib/activate/dev_manager.c      |  4 ++++
22b171
 lib/metadata/lv.c               |  2 +-
22b171
 lib/metadata/writecache_manip.c | 16 ++++++++--------
22b171
 lib/misc/lvm-string.c           |  1 +
22b171
 lib/writecache/writecache.c     |  2 +-
22b171
 tools/lvconvert.c               |  2 ++
22b171
 6 files changed, 17 insertions(+), 10 deletions(-)
22b171
22b171
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
22b171
index c8a22fb..3b99131 100644
22b171
--- a/lib/activate/dev_manager.c
22b171
+++ b/lib/activate/dev_manager.c
22b171
@@ -3316,6 +3316,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
22b171
 	if (!layer && lv_is_new_thin_pool(lv))
22b171
 		layer = lv_layer(lv);
22b171
 
22b171
+	/* Adds -real to the dm uuid of wcorig LV. */
22b171
+	if (!layer && lv_is_writecache_origin(lv))
22b171
+		layer = lv_layer(lv); /* "real" */
22b171
+
22b171
 	if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
22b171
 		return_0;
22b171
 
22b171
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
22b171
index ab26b8d..17d4907 100644
22b171
--- a/lib/metadata/lv.c
22b171
+++ b/lib/metadata/lv.c
22b171
@@ -830,7 +830,7 @@ const char *lv_layer(const struct logical_volume *lv)
22b171
 	if (lv_is_vdo_pool(lv))
22b171
 		return "vpool";
22b171
 
22b171
-	if (lv_is_origin(lv) || lv_is_external_origin(lv))
22b171
+	if (lv_is_origin(lv) || lv_is_external_origin(lv) || lv_is_writecache_origin(lv))
22b171
 		return "real";
22b171
 
22b171
 	return NULL;
22b171
diff --git a/lib/metadata/writecache_manip.c b/lib/metadata/writecache_manip.c
22b171
index 0122025..31d069e 100644
22b171
--- a/lib/metadata/writecache_manip.c
22b171
+++ b/lib/metadata/writecache_manip.c
22b171
@@ -24,15 +24,15 @@
22b171
 
22b171
 int lv_is_writecache_origin(const struct logical_volume *lv)
22b171
 {
22b171
-	struct seg_list *sl;
22b171
+	struct lv_segment *seg;
22b171
 
22b171
-	dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
22b171
-		if (!sl->seg || !sl->seg->lv || !sl->seg->origin)
22b171
-			continue;
22b171
-		if (lv_is_writecache(sl->seg->lv) && (sl->seg->origin == lv))
22b171
-			return 1;
22b171
-	}
22b171
-	return 0;
22b171
+	/* Make sure there's exactly one segment in segs_using_this_lv! */
22b171
+	if (dm_list_empty(&lv->segs_using_this_lv) ||
22b171
+	    (dm_list_size(&lv->segs_using_this_lv) > 1))
22b171
+		return 0;
22b171
+
22b171
+	seg = get_only_segment_using_this_lv(lv);
22b171
+	return seg && lv_is_writecache(seg->lv) && !lv_is_pending_delete(seg->lv) && (seg_lv(seg, 0) == lv);
22b171
 }
22b171
 
22b171
 int lv_is_writecache_cachevol(const struct logical_volume *lv)
22b171
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c
22b171
index d8b27cb..0ee3403 100644
22b171
--- a/lib/misc/lvm-string.c
22b171
+++ b/lib/misc/lvm-string.c
22b171
@@ -251,6 +251,7 @@ char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,
22b171
 		 */
22b171
 		/* Suffixes used here MUST match lib/activate/dev_manager.c */
22b171
 		layer = lv_is_cache_origin(lv) ? "real" :
22b171
+			lv_is_writecache_origin(lv) ? "real" :
22b171
 			(lv_is_cache(lv) && lv_is_pending_delete(lv)) ? "real" :
22b171
 			lv_is_cache_pool_data(lv) ? "cdata" :
22b171
 			lv_is_cache_pool_metadata(lv) ? "cmeta" :
22b171
diff --git a/lib/writecache/writecache.c b/lib/writecache/writecache.c
22b171
index 08a306e..130922a 100644
22b171
--- a/lib/writecache/writecache.c
22b171
+++ b/lib/writecache/writecache.c
22b171
@@ -260,7 +260,7 @@ static int _writecache_add_target_line(struct dev_manager *dm,
22b171
 	if ((pmem = lv_on_pmem(seg->writecache)) < 0)
22b171
 		return_0;
22b171
 
22b171
-	if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0), NULL)))
22b171
+	if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0), "real")))
22b171
 		return_0;
22b171
 
22b171
 	if (!(fast_uuid = build_dm_uuid(mem, seg->writecache, "cvol")))
22b171
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
22b171
index 757b323..0ddeb35 100644
22b171
--- a/tools/lvconvert.c
22b171
+++ b/tools/lvconvert.c
22b171
@@ -5537,6 +5537,8 @@ static struct logical_volume *_lv_writecache_create(struct cmd_context *cmd,
22b171
 	if (!(segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_WRITECACHE)))
22b171
 		return_NULL;
22b171
 
22b171
+	lv->status |= WRITECACHE;
22b171
+
22b171
 	/*
22b171
 	 * "lv_wcorig" is a new LV with new id, but with the segments from "lv".
22b171
 	 * "lv" keeps the existing name and id, but gets a new writecache segment,