lib/bdev: Factor out bdev I/O complete operation in _bdev_io_submit()

The following patch will add another spdk_bdev_io_complete() call
in _bdev_io_submit(). Then, factoring out set/clear in_submit flag,
incrementing counts and calling spdk_bdev_io_complete() into a helper
function will be simpler.

in_submit flag is set and clear in bdev_io_do_submit() anyway,
and bdev_qos_io_submit() needs in_submit flag only for
bdev_io_do_submit().

All cases to call spdk_bdev_io_complete() in _bdev_io_submit() are
not performance critical.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ibb783d7d001a9c36e61d791c664c67fdc46a09e2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2386
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Michael Haeuptle <michaelhaeuptle@gmail.com>
This commit is contained in:
Shuhei Matsumoto 2020-05-12 02:53:22 +09:00 committed by Tomasz Zawadzki
parent 339a0419d3
commit 5771019fc0

View File

@ -1655,6 +1655,20 @@ bdev_qos_set_ops(struct spdk_bdev_qos *qos)
}
}
static void
_bdev_io_complete_in_submit(struct spdk_bdev_channel *bdev_ch,
struct spdk_bdev_io *bdev_io,
enum spdk_bdev_io_status status)
{
struct spdk_bdev_shared_resource *shared_resource = bdev_ch->shared_resource;
bdev_io->internal.in_submit_request = true;
bdev_ch->io_outstanding++;
shared_resource->io_outstanding++;
spdk_bdev_io_complete(bdev_io, status);
bdev_io->internal.in_submit_request = false;
}
static inline void
bdev_io_do_submit(struct spdk_bdev_channel *bdev_ch, struct spdk_bdev_io *bdev_io)
{
@ -1991,7 +2005,6 @@ _bdev_io_submit(void *ctx)
struct spdk_bdev_io *bdev_io = ctx;
struct spdk_bdev *bdev = bdev_io->bdev;
struct spdk_bdev_channel *bdev_ch = bdev_io->internal.ch;
struct spdk_bdev_shared_resource *shared_resource = bdev_ch->shared_resource;
uint64_t tsc;
tsc = spdk_get_ticks();
@ -2003,21 +2016,15 @@ _bdev_io_submit(void *ctx)
return;
}
bdev_ch->io_outstanding++;
shared_resource->io_outstanding++;
bdev_io->internal.in_submit_request = true;
if (bdev_ch->flags & BDEV_CH_RESET_IN_PROGRESS) {
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
_bdev_io_complete_in_submit(bdev_ch, bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
} else if (bdev_ch->flags & BDEV_CH_QOS_ENABLED) {
bdev_ch->io_outstanding--;
shared_resource->io_outstanding--;
TAILQ_INSERT_TAIL(&bdev->internal.qos->queued, bdev_io, internal.link);
bdev_qos_io_submit(bdev_ch, bdev->internal.qos);
} else {
SPDK_ERRLOG("unknown bdev_ch flag %x found\n", bdev_ch->flags);
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
_bdev_io_complete_in_submit(bdev_ch, bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
}
bdev_io->internal.in_submit_request = false;
}
bool