bdev: reset status immediately to PENDING for nomem_io queue

Reset the status for a bdev_io that fails with NOMEM status
back to PENDING immediately when it is put on the nomem_io
list, instead of waiting until it gets submitted again.

This helps keep the bdev_io states consistent, so that if
we need to complete these IO for abort reasons later, that
we aren't completing IO that already have a non-PENDING
state.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I9532095141209ed6f7af362b52c689da62e755ce
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17335
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Jim Harris 2023-03-24 23:36:17 +00:00 committed by David Ko
parent a1ae05bb3f
commit c757d4b706

View File

@ -1321,11 +1321,15 @@ bdev_ch_retry_io(struct spdk_bdev_channel *bdev_ch)
TAILQ_REMOVE(&shared_resource->nomem_io, bdev_io, internal.link);
bdev_io->internal.ch->io_outstanding++;
shared_resource->io_outstanding++;
bdev_io->internal.status = SPDK_BDEV_IO_STATUS_PENDING;
bdev_io->internal.error.nvme.cdw0 = 0;
bdev_io->num_retries++;
bdev_submit_request(bdev, spdk_bdev_io_get_io_channel(bdev_io), bdev_io);
if (bdev_io->internal.status == SPDK_BDEV_IO_STATUS_NOMEM) {
if (bdev_io == TAILQ_FIRST(&shared_resource->nomem_io)) {
/* This IO completed again with NOMEM status, so break the loop and
* don't try anymore. Note that a bdev_io that fails with NOMEM
* always gets requeued at the front of the list, to maintain
* ordering.
*/
break;
}
}
@ -1348,6 +1352,7 @@ _bdev_io_handle_no_mem(struct spdk_bdev_io *bdev_io)
struct spdk_bdev_shared_resource *shared_resource = bdev_ch->shared_resource;
if (spdk_unlikely(bdev_io->internal.status == SPDK_BDEV_IO_STATUS_NOMEM)) {
bdev_io->internal.status = SPDK_BDEV_IO_STATUS_PENDING;
TAILQ_INSERT_HEAD(&shared_resource->nomem_io, bdev_io, internal.link);
/*
* Wait for some of the outstanding I/O to complete before we