Commit d2704a0f authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

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: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: Ic031ca23241dd77ef47e6ac21f6c346e67f3ce28
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5720


Community-CI: Broadcom CI
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatar <dongx.yi@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 6ea36f46
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -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) {