From f566060ab49b04ed2c6fcffca51578358864abd8 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 8 Dec 2017 12:54:11 -0700 Subject: [PATCH] nbd: clean up log messages Reduce the log level of the disconnection message to INFO (this is a normal occurrence when a connection is shut down), reword the message for clarity, add a newline, and convert the error number to a string. Also replace the printf() in spdk_nbd_start() with a SPDK log message. Change-Id: I35e493100e63f84a9b7257c6f84dad77e9a0d335 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/391025 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System --- lib/nbd/nbd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/nbd/nbd.c b/lib/nbd/nbd.c index 2c1e6e5fe..abacd07c1 100644 --- a/lib/nbd/nbd.c +++ b/lib/nbd/nbd.c @@ -45,6 +45,8 @@ #include "spdk/util.h" #include "spdk/io_channel.h" +#include "spdk_internal/log.h" + struct nbd_io { enum spdk_bdev_io_type type; int ref; @@ -489,11 +491,14 @@ static void spdk_nbd_poll(void *arg) { struct spdk_nbd_disk *nbd = arg; + char buf[64]; int rc; rc = _spdk_nbd_poll(nbd); if (rc < 0) { - SPDK_NOTICELOG("spdk_nbd_poll got error %d; close it", rc); + spdk_strerror_r(-rc, buf, sizeof(buf)); + SPDK_INFOLOG(SPDK_LOG_NBD, "spdk_nbd_poll() returned %s (%d); closing connection\n", + buf, rc); spdk_nbd_stop(nbd); } } @@ -596,7 +601,8 @@ spdk_nbd_start(const char *bdev_name, const char *nbd_path) goto err; } - printf("Enabling kernel access to bdev %s via %s\n", spdk_bdev_get_name(bdev), nbd_path); + SPDK_INFOLOG(SPDK_LOG_NBD, "Enabling kernel access to bdev %s via %s\n", + spdk_bdev_get_name(bdev), nbd_path); rc = ioctl(nbd->dev_fd, NBD_SET_SOCK, nbd->kernel_sp_fd); if (rc == -1) { @@ -647,3 +653,5 @@ err: return NULL; } + +SPDK_LOG_REGISTER_COMPONENT("nbd", SPDK_LOG_NBD)