From 606b453fcdcd298c48e03bec66555da0ef19b952 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 3 Sep 2019 10:07:06 +0200 Subject: [PATCH] vhost/nvme: fix error handling of session start Session start callbacks have technically two ways of returning an error code: a) as the callback return value, e.g. return -1 b) via vhost_session_start_done(int rc) The former doesn't have any effect as that return value is not checked anywhere. It's only present because we wanted to use the same function signature as for the foreach_session() callbacks. It's going to be cleaned up in subsequent patches, but before that happens we have to fix vhost_nvme. With vhost_session_start_done(-1) called, DPDK will terminate the entire socket connection. Change-Id: Ib1eff17a67eef055b0dc89fa13d1fed2f8a1fbf0 Signed-off-by: Vitaliy Mysak Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467230 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/vhost/vhost_nvme.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/vhost/vhost_nvme.c b/lib/vhost/vhost_nvme.c index 8a6c2642e..3a61107db 100644 --- a/lib/vhost/vhost_nvme.c +++ b/lib/vhost/vhost_nvme.c @@ -1082,13 +1082,16 @@ spdk_vhost_nvme_start_cb(struct spdk_vhost_dev *vdev, struct spdk_vhost_nvme_dev *nvme = to_nvme_dev(vdev); struct spdk_vhost_nvme_ns *ns_dev; uint32_t i; + int rc = 0; if (nvme == NULL) { - return -1; + rc = -1; + goto out; } - if (alloc_task_pool(nvme)) { - return -1; + rc = alloc_task_pool(nvme); + if (rc) { + goto out; } SPDK_NOTICELOG("Start Device %u, Path %s, lcore %d\n", vsession->vid, @@ -1098,7 +1101,8 @@ spdk_vhost_nvme_start_cb(struct spdk_vhost_dev *vdev, ns_dev = &nvme->ns[i]; ns_dev->bdev_io_channel = spdk_bdev_get_io_channel(ns_dev->bdev_desc); if (!ns_dev->bdev_io_channel) { - return -1; + rc = -1; + goto out; } } @@ -1106,8 +1110,9 @@ spdk_vhost_nvme_start_cb(struct spdk_vhost_dev *vdev, /* Start the NVMe Poller */ nvme->requestq_poller = spdk_poller_register(nvme_worker, nvme, 0); - vhost_session_start_done(vsession, 0); - return 0; +out: + vhost_session_start_done(vsession, rc); + return rc; } static int