From 1b2f095865d103141bdf12cf941590ae135db353 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 8 Feb 2019 14:20:52 +0900 Subject: [PATCH] bdev: Add spdk_bdev_io_get_io_channel API Currently struct bdev_io holds io_channel that the I/O was submitted on through bdev_io::bdev_channel, but bdev_io::bdev_channel is private in bdev.c and cannot be referenced in other files. Hence add an new API spdk_bdev_io_get_io_channel API to get io_channel coniveniently. Change-Id: Ic2e2fde845d324f7a1637e3c75080727a62de5ec Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/c/443843 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- include/spdk/bdev_module.h | 8 ++++++++ lib/bdev/bdev.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index d38a66f37..fda468153 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -761,6 +761,14 @@ void spdk_bdev_io_complete_scsi_status(struct spdk_bdev_io *bdev_io, enum spdk_s */ struct spdk_thread *spdk_bdev_io_get_thread(struct spdk_bdev_io *bdev_io); +/** + * Get the bdev module's I/O channel that the given bdev_io was submitted on. + * + * \param bdev_io I/O + * \return the bdev module's I/O channel that the given bdev_io was submitted on. + */ +struct spdk_io_channel *spdk_bdev_io_get_io_channel(struct spdk_bdev_io *bdev_io); + /** * Resize for a bdev. * diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 0c9aaad64..ddc9e0d6a 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -3459,6 +3459,12 @@ spdk_bdev_io_get_thread(struct spdk_bdev_io *bdev_io) return spdk_io_channel_get_thread(bdev_io->internal.ch->channel); } +struct spdk_io_channel * +spdk_bdev_io_get_io_channel(struct spdk_bdev_io *bdev_io) +{ + return bdev_io->internal.ch->channel; +} + static void _spdk_bdev_qos_config_limit(struct spdk_bdev *bdev, uint64_t *limits) {