lib/bdev: Add spdk_bdev_io_get_cb_arg() to get cb_arg of bdev_io

bdev_io is passed to the callback to the timeout I/O, but the context
of bdev_io is stored in cb_arg and spdk_bdev_abort() needs cb_arg.

Hence add an new helper function, spdk_bdev_io_get_cb_arg(), to get
cb_arg of bdev_io.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I5eb25ffdad2467c55a1b55f8cf0accef8799bb4b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2621
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-05-27 06:24:40 +09:00 committed by Tomasz Zawadzki
parent 97a5ea5796
commit 5bc400f382
3 changed files with 20 additions and 0 deletions

View File

@ -1648,6 +1648,14 @@ void spdk_bdev_io_get_iovec(struct spdk_bdev_io *bdev_io, struct iovec **iovp, i
*/
void *spdk_bdev_io_get_md_buf(struct spdk_bdev_io *bdev_io);
/**
* Get the callback argument of bdev_io to abort it by spdk_bdev_abort.
*
* \param bdev_io I/O to get the callback argument from.
* \return Callback argument of bdev_io.
*/
void *spdk_bdev_io_get_cb_arg(struct spdk_bdev_io *bdev_io);
typedef void (*spdk_bdev_histogram_status_cb)(void *cb_arg, int status);
typedef void (*spdk_bdev_histogram_data_cb)(void *cb_arg, int status,
struct spdk_histogram_data *histogram);

View File

@ -5793,6 +5793,17 @@ spdk_bdev_io_get_md_buf(struct spdk_bdev_io *bdev_io)
return NULL;
}
void *
spdk_bdev_io_get_cb_arg(struct spdk_bdev_io *bdev_io)
{
if (bdev_io == NULL) {
assert(false);
return NULL;
}
return bdev_io->internal.caller_ctx;
}
void
spdk_bdev_module_list_add(struct spdk_bdev_module *bdev_module)
{

View File

@ -86,6 +86,7 @@
spdk_bdev_io_get_scsi_status;
spdk_bdev_io_get_iovec;
spdk_bdev_io_get_md_buf;
spdk_bdev_io_get_cb_arg;
spdk_bdev_histogram_enable;
spdk_bdev_histogram_get;
spdk_bdev_get_media_events;