Blob Blame History Raw
 WHATS_NEW                  |  4 ++++
 lib/activate/activate.c    | 10 ++++++++++
 lib/activate/dev_manager.c | 13 +++++++------
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/WHATS_NEW b/WHATS_NEW
index 8c87a92..6441cc1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.02.155 - 
+====================================
+  Fix flushing for mirror target.
+
 Version 2.02.142 - 
 ====================================
   Do not check for suspended devices if scanning for lvmetad update.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 7d2adf1..8b0fcb3 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1900,6 +1900,16 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
 		}
 	}
 
+	/* Flush is ATM required for the tested cases
+	 * NOTE: Mirror repair requires noflush for proper repair!
+	 * TODO: Relax this limiting condition further */
+	if (!flush_required &&
+	    (lv_is_pvmove(ondisk_lv) ||
+	    (!lv_is_mirror(ondisk_lv) && !lv_is_thin_pool(ondisk_lv) && !lv_is_thin_volume(ondisk_lv)))) {
+		log_debug("Requiring flush for LV %s.", display_lvname(ondisk_lv));
+		flush_required = 1;
+	}
+
 	if (!monitor_dev_for_events(cmd, ondisk_lv, laopts, 0))
 		/* FIXME Consider aborting here */
 		stack;
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index e1f547f..c95dfbe 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -3277,7 +3277,7 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
 		break;
 	case SUSPEND:
 		dm_tree_skip_lockfs(root);
-		if (!dm->flush_required && !lv_is_pvmove(lv))
+		if (!dm->flush_required)
 			dm_tree_use_no_flush_suspend(root);
 		/* Fall through */
 	case SUSPEND_WITH_LOCKFS:
@@ -3298,12 +3298,11 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
 
 		if ((dm_tree_node_size_changed(root) < 0))
 			dm->flush_required = 1;
-
 		/* Currently keep the code require flush for any
-		 * non 'thin pool/volume, mirror' or with any size change */
-		if (!lv_is_thin_volume(lv) &&
-		    !lv_is_thin_pool(lv) &&
-		    (!lv_is_mirror(lv) || dm_tree_node_size_changed(root)))
+		 * non 'thin pool/volume' and  size increase */
+		else if (!lv_is_thin_volume(lv) &&
+			 !lv_is_thin_pool(lv) &&
+			 dm_tree_node_size_changed(root))
 			dm->flush_required = 1;
 
 		if (action == ACTIVATE) {
@@ -3347,6 +3346,8 @@ int dev_manager_activate(struct dev_manager *dm, const struct logical_volume *lv
 int dev_manager_preload(struct dev_manager *dm, const struct logical_volume *lv,
 			struct lv_activate_opts *laopts, int *flush_required)
 {
+	dm->flush_required = *flush_required;
+
 	if (!_tree_action(dm, lv, laopts, PRELOAD))
 		return_0;