Skip to contentSkip to conversation

master - mirror: block_on_error only with monitoring

PATCH Zdenek Kabelac 1 participant 1 message Apr 20, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=55d83f9f6ee1892d419bdd9d50c3450ac41f6749
Commit:        55d83f9f6ee1892d419bdd9d50c3450ac41f6749
Parent:        66400d003d357611f19f99fb68500c364fbef547
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Mar 29 21:10:58 2018 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Apr 20 12:13:51 2018 +0200

mirror: block_on_error only with monitoring

When user configured lvm2 to NOT user monitoring, activated mirror actually hang upon error and it's quite unusable moment.

So instead Warn those 'brave' non-monitoring users about possible problem and activation mirror without blocking error handling.

This also makes it a bit simpler for test suite to handle trouble cases when test is running without dmeventd.

---
 lib/commands/toolcontext.h |    1 +
 lib/mirror/mirrored.c      |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
lib/commands/toolcontext.h +1 -0
index 4225c57..89d1088 100644
@@ -169,6 +169,7 @@ struct cmd_context {
 	unsigned activate_component:1;		/* command activates component LV */
 	unsigned process_component_lvs:1;	/* command processes also component LVs */
 
+	unsigned mirror_warn_printed:1;		/* command already printed warning about non-monitored mirrors */
 	/*
 	 * Filtering.
 	 */
lib/mirror/mirrored.c +8 -2
index e6dc99b..10828e8 100644
@@ -314,8 +314,14 @@ static int _add_log(struct dm_pool *mem, struct lv_segment *seg,
 	if (mirror_in_sync() && !(seg->status & PVMOVE))
 		log_flags |= DM_NOSYNC;
 
-	if (_block_on_error_available && !(seg->status & PVMOVE))
-		log_flags |= DM_BLOCK_ON_ERROR;
+	if (_block_on_error_available && !(seg->status & PVMOVE)) {
+		if (dmeventd_monitor_mode() > 0)
+			log_flags |= DM_BLOCK_ON_ERROR;
+		else {
+			log_warn_suppress(seg->lv->vg->cmd->mirror_warn_printed, "WARNING: Mirrors without monitoring will not react on failures.");
+			seg->lv->vg->cmd->mirror_warn_printed = 1;
+		}
+	}
 
 	return dm_tree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count, log_flags);
 }