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: Alexey Marchuk <alexeymar@mellanox.com> Change-Id: I8980644a02889c5e64a2b9b1382dff6d8a7ffa9b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11974 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
f530abcab3
commit
ce49d2f91f
@ -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,36 +830,23 @@ _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;
|
||||
}
|
||||
io_ctx->status = -ENOTSUP;
|
||||
|
||||
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;
|
||||
/* Complete this on the orig IO thread. */
|
||||
orig_thread = spdk_io_channel_get_thread(ch);
|
||||
if (orig_thread != spdk_get_thread()) {
|
||||
spdk_thread_send_msg(orig_thread, _complete_other_io, io_ctx);
|
||||
} else {
|
||||
SPDK_ERRLOG("on bdev_io submission!\n");
|
||||
io_ctx->status = rc;
|
||||
_complete_other_io(io_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/* Complete this on the orig IO thread. */
|
||||
orig_thread = spdk_io_channel_get_thread(ch);
|
||||
if (orig_thread != spdk_get_thread()) {
|
||||
spdk_thread_send_msg(orig_thread, _complete_other_io, io_ctx);
|
||||
} else {
|
||||
_complete_other_io(io_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/* Called when someone above submits IO to this vbdev. */
|
||||
|
Loading…
Reference in New Issue
Block a user