Skip to contentSkip to conversation

master - activation: separate reporting of error and monitoring status

PATCH Zdenek Kabelac 1 participant 1 message Feb 12, 2018 MD RAID

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d90a6478026dc2810947d552d6165ec7f0534894
Commit:        d90a6478026dc2810947d552d6165ec7f0534894
Parent:        12fba201be314dd16ea01fc756e39c04c8ba50c3
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Mon Jan 29 16:28:57 2018 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Feb 12 22:14:59 2018 +0100

activation: separate reporting of error and monitoring status

Avoid using same return code for reporting 2 different things and stricly report error code by return value and add new parameter for reporting monitoring status.

This makes easier to recognize which error we got from dm_event and continue only with ENOENT.

---
 WHATS_NEW                             |    1 +
 daemons/dmeventd/libdevmapper-event.c |    7 +--
 lib/activate/activate.c               |   84 ++++++++++++++++++++++++--------
 lib/activate/activate.h               |    2 +-
 lib/metadata/lv.c                     |   14 +++--
 lib/metadata/segtype.h                |    2 +-
 lib/mirror/mirrored.c                 |    4 +-
 lib/raid/raid.c                       |    4 +-
 lib/snapshot/snapshot.c               |    7 ++-
 lib/thin/thin.c                       |    4 +-
 10 files changed, 87 insertions(+), 42 deletions(-)
WHATS_NEW +1 -0
index 1ffa3db..2bded4d 100644
@@ -1,5 +1,6 @@
 Version 2.02.178 - 
 =====================================
+  Separate reporting of monitoring status and error status.
   Improve validation of created strings in vgimportclone.
   Add missing initialisation of mem pool in systemd generator.
   Do not reopen output streams for multithreaded users of liblvm.
daemons/dmeventd/libdevmapper-event.c +3 -4
index 210e384..9aeb4c5 100644
@@ -754,11 +754,10 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
 	uuid = dm_task_get_uuid(dmt);
 
 	/* FIXME Distinguish errors connecting to daemon */
-	if (_do_event(next ? DM_EVENT_CMD_GET_NEXT_REGISTERED_DEVICE :
-		      DM_EVENT_CMD_GET_REGISTERED_DEVICE, dmevh->dmeventd_path,
-		      &msg, dmevh->dso, uuid, dmevh->mask, 0)) {
+	if ((ret = _do_event(next ? DM_EVENT_CMD_GET_NEXT_REGISTERED_DEVICE :
+			    DM_EVENT_CMD_GET_REGISTERED_DEVICE, dmevh->dmeventd_path,
+			    &msg, dmevh->dso, uuid, dmevh->mask, 0))) {
 		log_debug("%s: device not registered.", dm_task_get_name(dmt));
-		ret = -ENOENT;
 		goto fail;
 	}
 
lib/activate/activate.c +63 -21

155 lines not on this page · raw message

lib/activate/activate.h +1 -1
index 25b7cc8..b1cc176 100644
@@ -208,7 +208,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
 #  include "libdevmapper-event.h"
 char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath);
 int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso,
-				    const struct logical_volume *lv, int *pending);
+				    const struct logical_volume *lv, int *pending, int *monitored);
 int target_register_events(struct cmd_context *cmd, const char *dso, const struct logical_volume *lv,
 			    int evmask __attribute__((unused)), int set, int timeout);
 #endif
lib/metadata/lv.c +8 -6
index 630880f..b19ae34 100644
@@ -298,7 +298,7 @@ char *lvseg_monitor_dup(struct dm_pool *mem, const struct lv_segment *seg)
 
 #ifdef DMEVENTD
 	struct lvinfo info;
-	int pending = 0, monitored;
+	int pending = 0, monitored = 0;
 	struct lv_segment *segm = (struct lv_segment *) seg;
 
 	if (lv_is_cow(seg->lv) && !lv_is_merging_cow(seg->lv))
@@ -314,11 +314,13 @@ char *lvseg_monitor_dup(struct dm_pool *mem, const struct lv_segment *seg)
 	else if (!seg_monitored(segm) || (segm->status & PVMOVE))
 		s = "not monitored";
 	else if (lv_info(seg->lv->vg->cmd, seg->lv, 1, &info, 0, 0) && info.exists) {
-		monitored = segm->segtype->ops->target_monitored(segm, &pending);
-		if (pending)
-			s = "pending";
-		else
-			s = (monitored) ? "monitored" : "not monitored";
+		if (segm->segtype->ops->target_monitored(segm, &pending, &monitored)) {
+			if (pending)
+				s = "pending";
+			else
+				s = (monitored) ? "monitored" : "not monitored";
+		} else
+			s = "not monitored";
 	} // else log_debug("Not active");
 #endif
 	return dm_pool_strdup(mem, s);
lib/metadata/segtype.h +1 -1
index 61a6580..fd8646c 100644
@@ -259,7 +259,7 @@ struct segtype_handler {
 			       const struct lv_segment *seg,
 			       struct dm_list *modules);
 	void (*destroy) (struct segment_type * segtype);
-	int (*target_monitored) (struct lv_segment *seg, int *pending);
+	int (*target_monitored) (struct lv_segment *seg, int *pending, int *monitored);
 	int (*target_monitor_events) (struct lv_segment *seg, int events);
 	int (*target_unmonitor_events) (struct lv_segment *seg, int events);
 };
lib/mirror/mirrored.c +2 -2
index 602c30a..012501e 100644
@@ -486,10 +486,10 @@ static const char *_get_mirror_dso_path(struct cmd_context *cmd)
 }
 
 /* FIXME Cache this */
-static int _target_registered(struct lv_segment *seg, int *pending)
+static int _target_registered(struct lv_segment *seg, int *pending, int *monitored)
 {
 	return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
-					       seg->lv, pending);
+					       seg->lv, pending, monitored);
 }
 
 /* FIXME This gets run while suspended and performs banned operations. */
lib/raid/raid.c +2 -2
index 5d2e1ea..9b85373 100644
@@ -544,12 +544,12 @@ static const char *_get_raid_dso_path(struct cmd_context *cmd)
 	return get_monitor_dso_path(cmd, config_str);
 }
 
-static int _raid_target_monitored(struct lv_segment *seg, int *pending)
+static int _raid_target_monitored(struct lv_segment *seg, int *pending, int *monitored)
 {
 	struct cmd_context *cmd = seg->lv->vg->cmd;
 	const char *dso_path = _get_raid_dso_path(cmd);
 
-	return target_registered_with_dmeventd(cmd, dso_path, seg->lv, pending);
+	return target_registered_with_dmeventd(cmd, dso_path, seg->lv, pending, monitored);
 }
 
 static int _raid_set_events(struct lv_segment *seg, int evmask, int set)
lib/snapshot/snapshot.c +4 -3
index a80f283..68e01f5 100644
@@ -186,10 +186,11 @@ static const char *_get_snapshot_dso_path(struct cmd_context *cmd)
 }
 
 /* FIXME Cache this */
-static int _target_registered(struct lv_segment *seg, int *pending)
+static int _target_registered(struct lv_segment *seg, int *pending, int *monitored)
 {
-	return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd),
-					       seg->cow, pending);
+	return target_registered_with_dmeventd(seg->lv->vg->cmd,
+					       _get_snapshot_dso_path(seg->lv->vg->cmd),
+					       seg->cow, pending, monitored);
 }
 
 /* FIXME This gets run while suspended and performs banned operations. */
lib/thin/thin.c +2 -2
index 73fffa6..9cb1ee0 100644
@@ -437,11 +437,11 @@ static const char *_get_thin_dso_path(struct cmd_context *cmd)
 }
 
 /* FIXME Cache this */
-static int _target_registered(struct lv_segment *seg, int *pending)
+static int _target_registered(struct lv_segment *seg, int *pending, int *monitored)
 {
 	return target_registered_with_dmeventd(seg->lv->vg->cmd,
 					       _get_thin_dso_path(seg->lv->vg->cmd),
-					       seg->lv, pending);
+					       seg->lv, pending, monitored);
 }
 
 /* FIXME This gets run while suspended and performs banned operations. */