From 42287a6954071a2ce843565c63d619bec1944953 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Tue, 18 Jun 2019 11:23:15 +0200 Subject: [PATCH] lib/ftl: error logging around getting chunk info Some of the errors were silent, making it hard to pinpoint the exact failing call. This patch adds SPDK_ERRLOGs for each error path. Change-Id: I71be6c97cab916ac52314e5f4e4d63358877bd96 Signed-off-by: Konrad Sztyber Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458426 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Darek Stojaczyk --- lib/ftl/ftl_init.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/ftl/ftl_init.c b/lib/ftl/ftl_init.c index abad660ae..2ea4d5b2d 100644 --- a/lib/ftl/ftl_init.c +++ b/lib/ftl/ftl_init.c @@ -35,6 +35,8 @@ #include "spdk/nvme.h" #include "spdk/io_channel.h" #include "spdk/bdev_module.h" +#include "spdk/string.h" +#include "spdk/likely.h" #include "spdk_internal/log.h" #include "spdk/ftl.h" #include "ftl_core.h" @@ -208,11 +210,14 @@ ftl_retrieve_chunk_info(struct spdk_ftl_dev *dev, struct ftl_ppa ppa, uint32_t nsid = spdk_nvme_ns_get_id(dev->ns); uint64_t offset = (ppa.grp * dev->geo.num_pu + ppa.pu) * dev->geo.num_chk + ppa.chk; + int rc; - if (spdk_nvme_ctrlr_cmd_get_log_page(dev->ctrlr, SPDK_OCSSD_LOG_CHUNK_INFO, nsid, - info, num_entries * sizeof(*info), - offset * sizeof(*info), - ftl_admin_cb, (void *)&cmpl)) { + rc = spdk_nvme_ctrlr_cmd_get_log_page(dev->ctrlr, SPDK_OCSSD_LOG_CHUNK_INFO, nsid, + info, num_entries * sizeof(*info), + offset * sizeof(*info), + ftl_admin_cb, (void *)&cmpl); + if (spdk_unlikely(rc != 0)) { + SPDK_ERRLOG("spdk_nvme_ctrlr_cmd_get_log_page: %s\n", spdk_strerror(-rc)); return -1; } @@ -236,6 +241,7 @@ ftl_retrieve_punit_chunk_info(struct spdk_ftl_dev *dev, const struct ftl_punit * uint32_t i = 0; unsigned int num_entries = FTL_BLOCK_SIZE / sizeof(*info); struct ftl_ppa chunk_ppa = punit->start_ppa; + char ppa_buf[128]; for (i = 0; i < dev->geo.num_chk; i += num_entries, chunk_ppa.chk += num_entries) { if (num_entries > dev->geo.num_chk - i) { @@ -243,6 +249,8 @@ ftl_retrieve_punit_chunk_info(struct spdk_ftl_dev *dev, const struct ftl_punit * } if (ftl_retrieve_chunk_info(dev, chunk_ppa, &info[i], num_entries)) { + SPDK_ERRLOG("Failed to retrieve chunk information @ppa: %s\n", + ftl_ppa2str(chunk_ppa, ppa_buf, sizeof(ppa_buf))); return -1; } }