From d2704a0f48b760e238ba989cd190821957660588 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Wed, 30 Dec 2020 01:14:54 +0800 Subject: [PATCH] lib/nbd: Fix the nbd_cleanup_io logic 1 For nbd_io in received list, we should not call nbd_put_io directly. We should still let those I/O be executed by the lower bdev layer in SPDK. 2 For nbd io in executed_io_list, we should not directly put the nbd device. The correct way is that we should write the io response to the kernel NBD device. Then the nbd device will not hang. Signed-off-by: Ziye Yang Change-Id: Ic031ca23241dd77ef47e6ac21f6c346e67f3ce28 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5720 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Reviewed-by: Changpeng Liu Reviewed-by: Tomasz Zawadzki --- lib/nbd/nbd.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/lib/nbd/nbd.c b/lib/nbd/nbd.c index b28f997ce..d843f4f3f 100644 --- a/lib/nbd/nbd.c +++ b/lib/nbd/nbd.c @@ -329,30 +329,12 @@ nbd_io_xmit_check(struct spdk_nbd_disk *nbd) static int nbd_cleanup_io(struct spdk_nbd_disk *nbd) { - struct nbd_io *io, *io_tmp; - /* free io_in_recv */ if (nbd->io_in_recv != NULL) { nbd_put_io(nbd, nbd->io_in_recv); nbd->io_in_recv = NULL; } - /* free io in received_io_list */ - if (!TAILQ_EMPTY(&nbd->received_io_list)) { - TAILQ_FOREACH_SAFE(io, &nbd->received_io_list, tailq, io_tmp) { - TAILQ_REMOVE(&nbd->received_io_list, io, tailq); - nbd_put_io(nbd, io); - } - } - - /* free io in executed_io_list */ - if (!TAILQ_EMPTY(&nbd->executed_io_list)) { - TAILQ_FOREACH_SAFE(io, &nbd->executed_io_list, tailq, io_tmp) { - TAILQ_REMOVE(&nbd->executed_io_list, io, tailq); - nbd_put_io(nbd, io); - } - } - /* * Some nbd_io may be under executing in bdev. * Wait for their done operation. @@ -594,14 +576,6 @@ nbd_io_exec(struct spdk_nbd_disk *nbd) int io_count = 0; int ret = 0; - /* - * For soft disconnection, nbd server must handle all outstanding - * request before closing connection. - */ - if (nbd->state == NBD_DISK_STATE_HARDDISC) { - return 0; - } - if (!TAILQ_EMPTY(&nbd->received_io_list)) { TAILQ_FOREACH_SAFE(io, &nbd->received_io_list, tailq, io_tmp) { TAILQ_REMOVE(&nbd->received_io_list, io, tailq); @@ -809,14 +783,6 @@ nbd_io_xmit(struct spdk_nbd_disk *nbd) int ret = 0; int rc; - /* - * For soft disconnection, nbd server must handle all outstanding - * request before closing connection. - */ - if (nbd->state == NBD_DISK_STATE_HARDDISC) { - return 0; - } - while (!TAILQ_EMPTY(&nbd->executed_io_list)) { rc = nbd_io_xmit_internal(nbd); if (rc < 0) {