From 0d31e2bae659b5dbbf53851f0ae9d93306a5c32c Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 12 May 2020 03:36:15 +0900 Subject: [PATCH] lib/bdev: spdk_bdev_abort supports queued I/O due to out of memory Add abort queued I/O due to out of memory into bdev_io_do_submit(). Any bdev I/O is queued due to out of memory only on the submitted channel. Aborting queued I/O due to out of memory is necessary only if shared_resource->nomem_io is not empty. Checking if shared_resource->nomem_io is not empty has been done in this function. However add the abort operation without and before checking if shared_resource->nomem_io is not empty because the following patch will abort queued I/O due to buffer pool capacity. The purpose is to improve readability by consolidating all abort operations into a single place. Signed-off-by: Shuhei Matsumoto Change-Id: I69a40f096aff13b84c1ed345fa8bd0dd80cef0e1 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2249 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Michael Haeuptle --- lib/bdev/bdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index ee6db76a5..aa04892cc 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -1678,6 +1678,16 @@ bdev_io_do_submit(struct spdk_bdev_channel *bdev_ch, struct spdk_bdev_io *bdev_i struct spdk_io_channel *ch = bdev_ch->channel; struct spdk_bdev_shared_resource *shared_resource = bdev_ch->shared_resource; + if (spdk_unlikely(bdev_io->type == SPDK_BDEV_IO_TYPE_ABORT)) { + struct spdk_bdev_io *bio_to_abort = bdev_io->u.abort.bio_to_abort; + + if (bdev_abort_queued_io(&shared_resource->nomem_io, bio_to_abort)) { + _bdev_io_complete_in_submit(bdev_ch, bdev_io, + SPDK_BDEV_IO_STATUS_SUCCESS); + return; + } + } + if (spdk_likely(TAILQ_EMPTY(&shared_resource->nomem_io))) { bdev_ch->io_outstanding++; shared_resource->io_outstanding++;