Commit ce49d2f9 authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Tomasz Zawadzki
Browse files

bdev/compress: Update error handling in IO submission path



The only rc that we may get in _comp_bdev_io_submit func
is ENOTSUP. ENOMEM is not available since submission funcs
are void.

Signed-off-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Change-Id: I8980644a02889c5e64a2b9b1382dff6d8a7ffa9b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11974


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarDong Yi <dongx.yi@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent f530abca
Loading
Loading
Loading
Loading
+17 −22
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "spdk/thread.h"
#include "spdk/util.h"
#include "spdk/bdev_module.h"
#include "spdk/likely.h"

#include "spdk/log.h"

@@ -431,8 +432,10 @@ _reduce_rw_blocks_cb(void *arg)
{
	struct comp_bdev_io *io_ctx = arg;

	if (io_ctx->status == 0) {
	if (spdk_likely(io_ctx->status == 0)) {
		spdk_bdev_io_complete(io_ctx->orig_io, SPDK_BDEV_IO_STATUS_SUCCESS);
	} else if (io_ctx->status == -ENOMEM) {
		vbdev_compress_queue_io(spdk_bdev_io_from_ctx(io_ctx));
	} else {
		SPDK_ERRLOG("status %d on operation from reduce API\n", io_ctx->status);
		spdk_bdev_io_complete(io_ctx->orig_io, SPDK_BDEV_IO_STATUS_FAILED);
@@ -783,6 +786,12 @@ comp_read_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, b
	struct vbdev_compress *comp_bdev = SPDK_CONTAINEROF(bdev_io->bdev, struct vbdev_compress,
					   comp_bdev);

	if (spdk_unlikely(!success)) {
		SPDK_ERRLOG("Failed to get data buffer\n");
		reduce_rw_blocks_cb(bdev_io, -ENOMEM);
		return;
	}

	spdk_reduce_vol_readv(comp_bdev->vol, bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt,
			      bdev_io->u.bdev.offset_blocks, bdev_io->u.bdev.num_blocks,
			      reduce_rw_blocks_cb, bdev_io);
@@ -810,7 +819,6 @@ _comp_bdev_io_submit(void *arg)
	struct vbdev_compress *comp_bdev = SPDK_CONTAINEROF(bdev_io->bdev, struct vbdev_compress,
					   comp_bdev);
	struct spdk_thread *orig_thread;
	int rc = 0;

	switch (bdev_io->type) {
	case SPDK_BDEV_IO_TYPE_READ:
@@ -822,28 +830,14 @@ _comp_bdev_io_submit(void *arg)
				       bdev_io->u.bdev.offset_blocks, bdev_io->u.bdev.num_blocks,
				       reduce_rw_blocks_cb, bdev_io);
		return;
	/* TODO in future patch in the series */
	/* TODO support RESET in future patch in the series */
	case SPDK_BDEV_IO_TYPE_RESET:
		break;
	case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
	case SPDK_BDEV_IO_TYPE_UNMAP:
	case SPDK_BDEV_IO_TYPE_FLUSH:
	default:
		SPDK_ERRLOG("Unknown I/O type %d\n", bdev_io->type);
		rc = -EINVAL;
	}

	if (rc) {
		if (rc == -ENOMEM) {
			SPDK_ERRLOG("No memory, start to queue io for compress.\n");
			io_ctx->ch = ch;
			vbdev_compress_queue_io(bdev_io);
			return;
		} else {
			SPDK_ERRLOG("on bdev_io submission!\n");
			io_ctx->status = rc;
		}
	}
		io_ctx->status = -ENOTSUP;

		/* Complete this on the orig IO thread. */
		orig_thread = spdk_io_channel_get_thread(ch);
@@ -853,6 +847,7 @@ _comp_bdev_io_submit(void *arg)
			_complete_other_io(io_ctx);
		}
	}
}

/* Called when someone above submits IO to this vbdev. */
static void