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

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