Blame SOURCES/lvm2-2_03_03-dm-migration_threshold-for-old-linked-tools.patch

146ac4
 WHATS_NEW_DM          |  1 +
146ac4
 libdm/libdm-deptree.c | 20 +++++++++++++++++---
146ac4
 2 files changed, 18 insertions(+), 3 deletions(-)
146ac4
146ac4
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
146ac4
index 24148d8..eacdc91 100644
146ac4
--- a/WHATS_NEW_DM
146ac4
+++ b/WHATS_NEW_DM
146ac4
@@ -1,5 +1,6 @@
146ac4
 Version 1.02.157 - 
146ac4
 =====================================
146ac4
+  Ensure migration_threshold for cache is at least 8 chunks.
146ac4
   Fix compilation of vdo status parsing in dmeventd.
146ac4
 
146ac4
 Version 1.02.155 - 18th December 2018
146ac4
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
146ac4
index 3f95a0d..ee12da2 100644
146ac4
--- a/libdm/libdm-deptree.c
146ac4
+++ b/libdm/libdm-deptree.c
146ac4
@@ -192,6 +192,7 @@ struct load_segment {
146ac4
 	uint64_t transaction_id;	/* Thin_pool */
146ac4
 	uint64_t low_water_mark;	/* Thin_pool */
146ac4
 	uint32_t data_block_size;       /* Thin_pool + cache */
146ac4
+	uint32_t migration_threshold;   /* Cache */
146ac4
 	unsigned skip_block_zeroing;	/* Thin_pool */
146ac4
 	unsigned ignore_discard;	/* Thin_pool target vsn 1.1 */
146ac4
 	unsigned no_discard_passdown;	/* Thin_pool target vsn 1.1 */
146ac4
@@ -2462,10 +2463,14 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
146ac4
 
146ac4
 	EMIT_PARAMS(pos, " %s", name);
146ac4
 
146ac4
-	EMIT_PARAMS(pos, " %u", seg->policy_argc * 2);
146ac4
+	/* Do not pass migration_threshold 2048 which is default */
146ac4
+	EMIT_PARAMS(pos, " %u", (seg->policy_argc + (seg->migration_threshold != 2048) ? 1 : 0) * 2);
146ac4
+	if (seg->migration_threshold != 2048)
146ac4
+		    EMIT_PARAMS(pos, " migration_threshold %u", seg->migration_threshold);
146ac4
 	if (seg->policy_settings)
146ac4
 		for (cn = seg->policy_settings->child; cn; cn = cn->sib)
146ac4
-			EMIT_PARAMS(pos, " %s %" PRIu64, cn->key, cn->v->v.i);
146ac4
+			if (cn->v) /* Skip deleted entry */
146ac4
+				EMIT_PARAMS(pos, " %s %" PRIu64, cn->key, cn->v->v.i);
146ac4
 
146ac4
 	return 1;
146ac4
 }
146ac4
@@ -3373,6 +3378,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
146ac4
 	seg->data_block_size = data_block_size;
146ac4
 	seg->flags = feature_flags;
146ac4
 	seg->policy_name = policy_name;
146ac4
+	seg->migration_threshold = 2048; /* Default migration threshold 1MiB */
146ac4
 
146ac4
 	/* FIXME: better validation missing */
146ac4
 	if (policy_settings) {
146ac4
@@ -3385,10 +3391,18 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
146ac4
 				log_error("Cache policy parameter %s is without integer value.", cn->key);
146ac4
 				return 0;
146ac4
 			}
146ac4
-			seg->policy_argc++;
146ac4
+			if (strcmp(cn->key, "migration_threshold") == 0) {
146ac4
+				seg->migration_threshold = cn->v->v.i;
146ac4
+				cn->v = NULL; /* skip this entry */
146ac4
+			} else
146ac4
+				seg->policy_argc++;
146ac4
 		}
146ac4
 	}
146ac4
 
146ac4
+	/* Always some throughput available for cache to proceed */
146ac4
+	if (seg->migration_threshold < data_block_size * 8)
146ac4
+		seg->migration_threshold = data_block_size * 8;
146ac4
+
146ac4
 	return 1;
146ac4
 }
146ac4