Blame SOURCES/0187-rbd-fixup-log-messages.patch

f20720
From 3ed9a923904887e41c774c71232ae2a1ff6fc3fb Mon Sep 17 00:00:00 2001
f20720
From: Mike Christie <mchristi@redhat.com>
f20720
Date: Wed, 31 Aug 2016 15:59:53 -0500
f20720
Subject: [PATCH 11/11] rbd: fixup log messages
f20720
f20720
Add rbd device prefix to condlog messages that was missing it, and drop
f20720
it in RBD_MSG because it is already added by caller.
f20720
f20720
Signed-off-by: Mike Christie <mchristi@redhat.com>
f20720
---
f20720
 libmultipath/checkers/rbd.c | 67 +++++++++++++++++++++++----------------------
f20720
 1 file changed, 35 insertions(+), 32 deletions(-)
f20720
f20720
diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c
f20720
index e34bf53..8e6cd3c 100644
f20720
--- a/libmultipath/checkers/rbd.c
f20720
+++ b/libmultipath/checkers/rbd.c
f20720
@@ -113,8 +113,8 @@ int libcheck_init(struct checker * c)
f20720
 
f20720
 	addr = udev_device_get_sysattr_value(bus_dev, "client_addr");
f20720
 	if (!addr) {
f20720
-		condlog(0, "Could not find client_addr in rbd sysfs. Try "
f20720
-			"updating kernel");
f20720
+		condlog(0, "rbd%d: Could not find client_addr in rbd sysfs. "
f20720
+			"Try updating kernel", ct->rbd_bus_id);
f20720
 		goto free_dev;
f20720
 	}
f20720
 
f20720
@@ -127,7 +127,7 @@ int libcheck_init(struct checker * c)
f20720
 		goto free_addr;
f20720
 	features = strtoll(features_str, NULL, 16);
f20720
 	if (!(features & RBD_FEATURE_EXCLUSIVE_LOCK)) {
f20720
-		condlog(3, "Exclusive lock not set.");
f20720
+		condlog(3, "rbd%d: Exclusive lock not set.", ct->rbd_bus_id);
f20720
 		goto free_addr;
f20720
 	}
f20720
 
f20720
@@ -136,7 +136,8 @@ int libcheck_init(struct checker * c)
f20720
 		goto free_addr;
f20720
 
f20720
 	if (!strstr(config_info, "noshare")) {
f20720
-		condlog(3, "Only nonshared clients supported.");
f20720
+		condlog(3, "rbd%d: Only nonshared clients supported.",
f20720
+			ct->rbd_bus_id);
f20720
 		goto free_addr;
f20720
 	}
f20720
 
f20720
@@ -189,18 +190,20 @@ int libcheck_init(struct checker * c)
f20720
 	}
f20720
 
f20720
 	if (rados_create(&ct->cluster, NULL) < 0) {
f20720
-		condlog(0, "Could not create rados cluster");
f20720
+		condlog(0, "rbd%d: Could not create rados cluster",
f20720
+			ct->rbd_bus_id);
f20720
 		goto free_snap;
f20720
 	}
f20720
 
f20720
 	if (rados_conf_read_file(ct->cluster, NULL) < 0) {
f20720
-		condlog(0, "Could not read rados conf");
f20720
+		condlog(0, "rbd%d: Could not read rados conf", ct->rbd_bus_id);
f20720
 		goto shutdown_rados;
f20720
 	}
f20720
 
f20720
 	ret = rados_connect(ct->cluster);
f20720
 	if (ret < 0) {
f20720
-		condlog(0, "Could not connect to rados cluster");
f20720
+		condlog(0, "rbd%d: Could not connect to rados cluster",
f20720
+			ct->rbd_bus_id);
f20720
 		goto shutdown_rados;
f20720
 	}
f20720
 
f20720
@@ -291,8 +294,7 @@ static int rbd_is_blacklisted(struct rbd_checker_context *ct, char *msg)
f20720
 	ret = rados_mon_command(ct->cluster, (const char **)cmd, 1, "", 0,
f20720
 				&blklist, &blklist_len, &stat, &stat_len);
f20720
 	if (ret < 0) {
f20720
-		RBD_MSG(msg, "rbd checker failed: mon command failed %d",
f20720
-			ret);
f20720
+		RBD_MSG(msg, "checker failed: mon command failed %d", ret);
f20720
 		return ret;
f20720
 	}
f20720
 
f20720
@@ -313,16 +315,15 @@ static int rbd_is_blacklisted(struct rbd_checker_context *ct, char *msg)
f20720
 
f20720
 		end = strchr(addr_tok, ' ');
f20720
 		if (!end) {
f20720
-			RBD_MSG(msg, "rbd%d checker failed: invalid blacklist %s",
f20720
-				 ct->rbd_bus_id, addr_tok);
f20720
+			RBD_MSG(msg, "checker failed: invalid blacklist %s",
f20720
+				 addr_tok);
f20720
 			break;
f20720
 		}
f20720
 		*end = '\0';
f20720
 
f20720
 		if (!strcmp(addr_tok, ct->client_addr)) {
f20720
 			ct->blacklisted = 1;
f20720
-			RBD_MSG(msg, "rbd%d checker: %s is blacklisted",
f20720
-				ct->rbd_bus_id, ct->client_addr);
f20720
+			RBD_MSG(msg, "%s is blacklisted", ct->client_addr);
f20720
 			ret = 1;
f20720
 			break;
f20720
 		}
f20720
@@ -339,7 +340,7 @@ int rbd_check(struct rbd_checker_context *ct, char *msg)
f20720
 	if (ct->blacklisted || rbd_is_blacklisted(ct, msg) == 1)
f20720
 		return PATH_DOWN;
f20720
 
f20720
-	RBD_MSG(msg, "rbd checker reports path is up");
f20720
+	RBD_MSG(msg, "checker reports path is up");
f20720
 	/*
f20720
 	 * Path may have issues, but the ceph cluster is at least
f20720
 	 * accepting IO, so we can attempt to do IO.
f20720
@@ -411,10 +412,12 @@ static int rbd_remap(struct rbd_checker_context *ct)
f20720
 		argv[i] = NULL;
f20720
 
f20720
 		ret = execvp(argv[0], argv);
f20720
-		condlog(0, "Error executing rbd: %s", strerror(errno));
f20720
+		condlog(0, "rbd%d: Error executing rbd: %s", ct->rbd_bus_id,
f20720
+			strerror(errno));
f20720
 		exit(-1);
f20720
 	case -1:
f20720
-		condlog(0, "fork failed: %s", strerror(errno));
f20720
+		condlog(0, "rbd%d: fork failed: %s", ct->rbd_bus_id,
f20720
+			strerror(errno));
f20720
 		return -1;
f20720
 	default:
f20720
 		ret = -1;
f20720
@@ -424,7 +427,8 @@ static int rbd_remap(struct rbd_checker_context *ct)
f20720
 			if (status == 0)
f20720
 				ret = 0;
f20720
 			else
f20720
-				condlog(0, "rbd failed with %d", status);
f20720
+				condlog(0, "rbd%d: failed with %d",
f20720
+					ct->rbd_bus_id, status);
f20720
 		}
f20720
 	}
f20720
 
f20720
@@ -454,12 +458,12 @@ static int rbd_rm_blacklist(struct rbd_checker_context *ct)
f20720
 	ret = rados_mon_command(ct->cluster, (const char **)cmd, 1, "", 0,
f20720
 				NULL, 0, &stat, &stat_len);
f20720
 	if (ret < 0) {
f20720
-		condlog(1, "rbd%d repair failed to remove blacklist for %s %d",
f20720
+		condlog(1, "rbd%d: repair failed to remove blacklist for %s %d",
f20720
 			ct->rbd_bus_id, ct->client_addr, ret);
f20720
 		goto free_cmd;
f20720
 	}
f20720
 
f20720
-	condlog(1, "rbd%d repair rm blacklist for %s",
f20720
+	condlog(1, "rbd%d: repair rm blacklist for %s",
f20720
 	       ct->rbd_bus_id, ct->client_addr);
f20720
 	free(stat);
f20720
 free_cmd:
f20720
@@ -478,8 +482,7 @@ static int rbd_repair(struct rbd_checker_context *ct, char *msg)
f20720
 	if (!ct->remapped) {
f20720
 		ret = rbd_remap(ct);
f20720
 		if (ret) {
f20720
-			RBD_MSG(msg, "rbd%d repair failed to remap. Err %d",
f20720
-				ct->rbd_bus_id, ret);
f20720
+			RBD_MSG(msg, "repair failed to remap. Err %d", ret);
f20720
 			return PATH_DOWN;
f20720
 		}
f20720
 	}
f20720
@@ -488,22 +491,21 @@ static int rbd_repair(struct rbd_checker_context *ct, char *msg)
f20720
 	snprintf(del, sizeof(del), "%d force", ct->rbd_bus_id);
f20720
 	ret = sysfs_write_rbd_remove(del, strlen(del) + 1);
f20720
 	if (ret) {
f20720
-		RBD_MSG(msg, "rbd%d repair failed to clean up. Err %d",
f20720
-			ct->rbd_bus_id, ret);
f20720
+		RBD_MSG(msg, "repair failed to clean up. Err %d", ret);
f20720
 		return PATH_DOWN;
f20720
 	}
f20720
 
f20720
 	ret = rbd_rm_blacklist(ct);
f20720
 	if (ret) {
f20720
-		RBD_MSG(msg, "rbd%d repair could not remove blacklist entry. Err %d",
f20720
-			ct->rbd_bus_id, ret);
f20720
+		RBD_MSG(msg, "repair could not remove blacklist entry. Err %d",
f20720
+			ret);
f20720
 		return PATH_DOWN;
f20720
 	}
f20720
 
f20720
 	ct->remapped = 0;
f20720
 	ct->blacklisted = 0;
f20720
 
f20720
-	RBD_MSG(msg, "rbd%d has been repaired", ct->rbd_bus_id);
f20720
+	RBD_MSG(msg, "has been repaired");
f20720
 	return PATH_UP;
f20720
 }
f20720
 
f20720
@@ -528,7 +530,7 @@ void *rbd_thread(void *ctx)
f20720
 	struct rbd_checker_context *ct = ctx;
f20720
 	int state;
f20720
 
f20720
-	condlog(3, "rbd%d thread starting up", ct->rbd_bus_id);
f20720
+	condlog(3, "rbd%d: thread starting up", ct->rbd_bus_id);
f20720
 
f20720
 	ct->message[0] = '\0';
f20720
 	/* This thread can be canceled, so setup clean up */
f20720
@@ -547,7 +549,7 @@ void *rbd_thread(void *ctx)
f20720
 	pthread_mutex_unlock(&ct->lock);
f20720
 	pthread_cond_signal(&ct->active);
f20720
 
f20720
-	condlog(3, "rbd%d thead finished, state %s", ct->rbd_bus_id,
f20720
+	condlog(3, "rbd%d: thead finished, state %s", ct->rbd_bus_id,
f20720
 		checker_state_name(state));
f20720
 	rbd_thread_cleanup_pop(ct);
f20720
 	return ((void *)0);
f20720
@@ -577,16 +579,17 @@ static int rbd_exec_fn(struct checker *c, thread_fn *fn)
f20720
 	 */
f20720
 	r = pthread_mutex_lock(&ct->lock);
f20720
 	if (r != 0) {
f20720
-		condlog(2, "rbd%d mutex lock failed with %d", ct->rbd_bus_id,
f20720
+		condlog(2, "rbd%d: mutex lock failed with %d", ct->rbd_bus_id,
f20720
 			r);
f20720
-		MSG(c, "rbd%d thread failed to initialize", ct->rbd_bus_id);
f20720
+		MSG(c, "rbd%d: thread failed to initialize", ct->rbd_bus_id);
f20720
 		return PATH_WILD;
f20720
 	}
f20720
 
f20720
 	if (ct->running) {
f20720
 		/* Check if checker is still running */
f20720
 		if (ct->thread) {
f20720
-			condlog(3, "rbd%d thread not finished", ct->rbd_bus_id);
f20720
+			condlog(3, "rbd%d: thread not finished",
f20720
+				ct->rbd_bus_id);
f20720
 			rbd_status = PATH_PENDING;
f20720
 		} else {
f20720
 			/* checker done */
f20720
@@ -623,7 +626,7 @@ static int rbd_exec_fn(struct checker *c, thread_fn *fn)
f20720
 
f20720
 		if (ct->thread &&
f20720
 		    (rbd_status == PATH_PENDING || rbd_status == PATH_UNCHECKED)) {
f20720
-			condlog(3, "rbd%d thread still running",
f20720
+			condlog(3, "rbd%d: thread still running",
f20720
 				ct->rbd_bus_id);
f20720
 			ct->running = 1;
f20720
 			rbd_status = PATH_PENDING;
f20720
-- 
f20720
1.8.3.1
f20720