diff --git a/include/spdk/bdev.h b/include/spdk/bdev.h index 4d34cbaf7..4c23d87db 100644 --- a/include/spdk/bdev.h +++ b/include/spdk/bdev.h @@ -881,14 +881,13 @@ int spdk_bdev_nvme_io_passthru_md(struct spdk_bdev_desc *bdev_desc, spdk_bdev_io_completion_cb cb, void *cb_arg); /** - * Free an I/O request. This should be called after the callback for the I/O has - * been called and notifies the bdev layer that memory may now be released. + * Free an I/O request. This should only be called after the completion callback + * for the I/O has been called and notifies the bdev layer that memory may now + * be released. * * \param bdev_io I/O request. - * - * \return -1 on failure, 0 on success. */ -int spdk_bdev_free_io(struct spdk_bdev_io *bdev_io); +void spdk_bdev_free_io(struct spdk_bdev_io *bdev_io); /** * Return I/O statistics for this channel. diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 324ea640c..f009c2151 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -935,11 +935,14 @@ spdk_bdev_get_io(struct spdk_bdev_channel *channel) return bdev_io; } -static void -spdk_bdev_put_io(struct spdk_bdev_io *bdev_io) +void +spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) { struct spdk_bdev_mgmt_channel *ch = bdev_io->ch->shared_resource->mgmt_ch; + assert(bdev_io != NULL); + assert(bdev_io->status != SPDK_BDEV_IO_STATUS_PENDING); + if (bdev_io->buf != NULL) { spdk_bdev_io_put_buf(bdev_io); } @@ -2277,25 +2280,6 @@ spdk_bdev_nvme_io_passthru_md(struct spdk_bdev_desc *desc, struct spdk_io_channe return 0; } -int -spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) -{ - if (!bdev_io) { - SPDK_ERRLOG("bdev_io is NULL\n"); - return -1; - } - - if (bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING) { - SPDK_ERRLOG("bdev_io is in pending state\n"); - assert(false); - return -1; - } - - spdk_bdev_put_io(bdev_io); - - return 0; -} - static void _spdk_bdev_ch_retry_io(struct spdk_bdev_channel *bdev_ch) { diff --git a/test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut.c b/test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut.c index 51740fd4e..342187ad9 100644 --- a/test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut.c +++ b/test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut.c @@ -164,9 +164,8 @@ spdk_bdev_nvme_io_passthru(struct spdk_bdev_desc *desc, return 0; } -int spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) +void spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) { - return -1; } const char *spdk_nvmf_subsystem_get_nqn(struct spdk_nvmf_subsystem *subsystem) diff --git a/test/unit/lib/scsi/lun.c/lun_ut.c b/test/unit/lib/scsi/lun.c/lun_ut.c index 3e2cd0168..2b439e621 100644 --- a/test/unit/lib/scsi/lun.c/lun_ut.c +++ b/test/unit/lib/scsi/lun.c/lun_ut.c @@ -123,11 +123,10 @@ spdk_dma_free(void *buf) free(buf); } -int +void spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) { CU_ASSERT(0); - return -1; } int diff --git a/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c b/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c index edcfb1765..8a038f837 100644 --- a/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c +++ b/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c @@ -79,11 +79,10 @@ spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_ty return false; } -int +void spdk_bdev_free_io(struct spdk_bdev_io *bdev_io) { CU_ASSERT(0); - return -1; } const char * diff --git a/test/unit/lib/vhost/vhost_blk.c/vhost_blk_ut.c b/test/unit/lib/vhost/vhost_blk.c/vhost_blk_ut.c index 7bcdaf08b..483bb02da 100644 --- a/test/unit/lib/vhost/vhost_blk.c/vhost_blk_ut.c +++ b/test/unit/lib/vhost/vhost_blk.c/vhost_blk_ut.c @@ -44,7 +44,7 @@ #include "spdk/bdev_module.h" #include "spdk/env.h" -DEFINE_STUB(spdk_bdev_free_io, int, (struct spdk_bdev_io *bdev_io), 0); +DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *bdev_io)); DEFINE_STUB(spdk_bdev_readv, int, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, struct iovec *iov, int iovcnt, uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg), 0); diff --git a/test/unit/lib/vhost/vhost_nvme.c/vhost_nvme_ut.c b/test/unit/lib/vhost/vhost_nvme.c/vhost_nvme_ut.c index 7e1cf551f..4cee930c0 100644 --- a/test/unit/lib/vhost/vhost_nvme.c/vhost_nvme_ut.c +++ b/test/unit/lib/vhost/vhost_nvme.c/vhost_nvme_ut.c @@ -45,7 +45,7 @@ #include "spdk/env.h" -DEFINE_STUB(spdk_bdev_free_io, int, (struct spdk_bdev_io *bdev_io), 0); +DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *bdev_io)); DEFINE_STUB(spdk_bdev_readv, int, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, struct iovec *iov, int iovcnt, uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg), 0);