From 90aba31ac3ace0136b3363768003dba9997f0983 Mon Sep 17 00:00:00 2001 From: Gal Hammer Date: Sun, 24 Apr 2022 09:12:37 +0300 Subject: [PATCH] bdev/ocf: Implement ENOMEM handling when submitting IO to base device Replaced the TODO comment with an error handing in case SPDK fails to allocate memory for the IO request. Returning the proper error code will use the bdev's no memory retry mechanism to handle the failure. Signed-off-by: Gal Hammer Signed-off-by: Shai Fultheim Change-Id: I151668f26b7f122dca95eaf65934be675e601952 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12372 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Reviewed-by: Rafal Stefanowski Tested-by: SPDK CI Jenkins --- module/bdev/ocf/volume.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/module/bdev/ocf/volume.c b/module/bdev/ocf/volume.c index a24cfa78e..b65a5eb30 100644 --- a/module/bdev/ocf/volume.c +++ b/module/bdev/ocf/volume.c @@ -175,7 +175,7 @@ vbdev_ocf_volume_submit_io_cb(struct spdk_bdev_io *bdev_io, bool success, void * assert(io_ctx != NULL); if (!success) { - io_ctx->error |= 1; + io_ctx->error = io_ctx->error ? : -OCF_ERR_IO; } if (io_ctx->iovs_allocated && bdev_io != NULL) { @@ -360,10 +360,13 @@ vbdev_ocf_volume_submit_io(struct ocf_io *io) end: if (status) { - /* TODO [ENOMEM]: implement ENOMEM handling when submitting IO to base device */ + if (status == -ENOMEM) { + io_ctx->error = -OCF_ERR_NO_MEM; + } else { + SPDK_ERRLOG("submission failed with status=%d\n", status); + } /* Since callback is not called, we need to do it manually to free io structures */ - SPDK_ERRLOG("submission failed with status=%d\n", status); vbdev_ocf_volume_submit_io_cb(NULL, false, io); } }