bdev: spdk_bdev_[read|write|flush|unmap|reset] now return int

It is not actually useful to be immediately returned
a handle to the bdev_io. There isn't anything valid
that the user can do with it at that point. Instead,
return an integer error code.

Change-Id: Iffa9a8dc5b2eefab57e3cc1f68919985431d17d1
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/364137
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Ben Walker 2017-06-05 11:39:38 -07:00
parent fb7ad4ac66
commit aff7e226f7
9 changed files with 241 additions and 169 deletions

View File

@ -223,11 +223,13 @@ struct spdk_io_channel *spdk_bdev_get_io_channel(struct spdk_bdev *bdev);
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
/**
* Submit a read request to the bdev on the given channel. This differs from
@ -245,12 +247,14 @@ struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_chann
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_readv(struct spdk_bdev *bdev, 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);
int spdk_bdev_readv(struct spdk_bdev *bdev, 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);
/**
* Submit a write request to the bdev on the given channel.
@ -263,11 +267,13 @@ struct spdk_bdev_io *spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_chan
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
/**
* Submit a write request to the bdev on the given channel. This differs from
@ -285,12 +291,14 @@ struct spdk_bdev_io *spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_chan
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg);
/**
* Submit an unmap request to the block device. Unmap is sometimes also called trim or
@ -304,12 +312,14 @@ struct spdk_bdev_io *spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_cha
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count,
spdk_bdev_io_completion_cb cb, void *cb_arg);
/**
* Submit a flush request to the bdev on the given channel. For devices with volatile
@ -323,11 +333,13 @@ struct spdk_bdev_io *spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_chan
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg);
/**
* Submit a reset request to the bdev on the given channel.
@ -337,7 +349,9 @@ struct spdk_bdev_io *spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_chan
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return -1 on failure, 0 on success.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
int spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -358,13 +372,15 @@ int spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev,
struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev,
struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
/**
* Submit an NVMe I/O command to the bdev. This passes directly through
@ -383,13 +399,15 @@ struct spdk_bdev_io *spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev,
* \param cb Called when the request is complete.
* \param cb_arg Argument passed to cb.
*
* \return A handle to the I/O request, or NULL on failure.
* \return 0 on success. On success, the callback will always
* be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called.
*/
struct spdk_bdev_io *spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev,
struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev,
struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes,
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

View File

@ -705,7 +705,7 @@ spdk_bdev_io_valid(struct spdk_bdev *bdev, uint64_t offset, uint64_t nbytes)
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -716,13 +716,13 @@ spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
assert(bdev->status != SPDK_BDEV_STATUS_UNCLAIMED);
if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) {
return NULL;
return -EINVAL;
}
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("spdk_bdev_io memory allocation failed duing read\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -738,13 +738,13 @@ spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t nbytes,
@ -756,13 +756,13 @@ spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
assert(bdev->status != SPDK_BDEV_STATUS_UNCLAIMED);
if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) {
return NULL;
return -EINVAL;
}
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("spdk_bdev_io memory allocation failed duing read\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -776,13 +776,13 @@ spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -793,13 +793,13 @@ spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
assert(bdev->status != SPDK_BDEV_STATUS_UNCLAIMED);
if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) {
return NULL;
return -EINVAL;
}
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("blockdev_io memory allocation failed duing write\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -815,13 +815,13 @@ spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len,
@ -833,13 +833,13 @@ spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
assert(bdev->status != SPDK_BDEV_STATUS_UNCLAIMED);
if (spdk_bdev_io_valid(bdev, offset, len) != 0) {
return NULL;
return -EINVAL;
}
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed duing writev\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -853,13 +853,13 @@ spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count,
@ -872,19 +872,19 @@ spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
assert(bdev->status != SPDK_BDEV_STATUS_UNCLAIMED);
if (bdesc_count == 0) {
SPDK_ERRLOG("Invalid bdesc_count 0\n");
return NULL;
return -EINVAL;
}
if (bdesc_count > bdev->max_unmap_bdesc_count) {
SPDK_ERRLOG("Invalid bdesc_count %u > max_unmap_bdesc_count %u\n",
bdesc_count, bdev->max_unmap_bdesc_count);
return NULL;
return -EINVAL;
}
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed duing unmap\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -896,13 +896,13 @@ spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -915,7 +915,7 @@ spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed duing flush\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -927,10 +927,10 @@ spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
static void
@ -973,7 +973,7 @@ spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed duing reset\n");
return -1;
return -ENOMEM;;
}
bdev_io->ch = channel;
@ -1005,7 +1005,7 @@ spdk_bdev_get_io_stat(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
memset(&channel->stat, 0, sizeof(channel->stat));
}
struct spdk_bdev_io *
int
spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -1017,7 +1017,7 @@ spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -1031,14 +1031,13 @@ spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -1050,7 +1049,7 @@ spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n");
return NULL;
return -ENOMEM;
}
bdev_io->ch = channel;
@ -1064,10 +1063,10 @@ spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
rc = spdk_bdev_io_submit(bdev_io);
if (rc < 0) {
spdk_bdev_put_io(bdev_io);
return NULL;
return rc;
}
return bdev_io;
return 0;
}
int

View File

@ -71,13 +71,13 @@ bdev_blob_read(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, void *p
uint64_t lba, uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args)
{
struct spdk_bdev *bdev = __get_bdev(dev);
struct spdk_bdev_io *bdev_io;
int rc;
uint32_t block_size = spdk_bdev_get_block_size(bdev);
bdev_io = spdk_bdev_read(bdev, channel, payload, lba * block_size,
lba_count * block_size, bdev_blob_io_complete, cb_args);
if (bdev_io == NULL) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, -EIO);
rc = spdk_bdev_read(bdev, channel, payload, lba * block_size,
lba_count * block_size, bdev_blob_io_complete, cb_args);
if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
}
}
@ -86,13 +86,13 @@ bdev_blob_write(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, void *
uint64_t lba, uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args)
{
struct spdk_bdev *bdev = __get_bdev(dev);
struct spdk_bdev_io *bdev_io;
int rc;
uint32_t block_size = spdk_bdev_get_block_size(bdev);
bdev_io = spdk_bdev_write(bdev, channel, payload, lba * block_size,
lba_count * block_size, bdev_blob_io_complete, cb_args);
if (bdev_io == NULL) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, -EIO);
rc = spdk_bdev_write(bdev, channel, payload, lba * block_size,
lba_count * block_size, bdev_blob_io_complete, cb_args);
if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
}
}
@ -102,7 +102,7 @@ bdev_blob_unmap(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64
{
struct spdk_bdev *bdev = __get_bdev(dev);
struct spdk_scsi_unmap_bdesc *desc;
struct spdk_bdev_io *bdev_io;
int rc;
SPDK_STATIC_ASSERT(sizeof(cb_args->scratch) >= sizeof(*desc), "scratch too small");
@ -111,9 +111,9 @@ bdev_blob_unmap(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64
to_be32(&desc->block_count, lba_count);
desc->reserved = 0;
bdev_io = spdk_bdev_unmap(bdev, channel, desc, 1, bdev_blob_io_complete, cb_args);
if (bdev_io == NULL) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, -EIO);
rc = spdk_bdev_unmap(bdev, channel, desc, 1, bdev_blob_io_complete, cb_args);
if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
}
}

View File

@ -408,14 +408,14 @@ nvmf_virtual_ctrlr_rw_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
if (cmd->opc == SPDK_NVME_OPC_READ) {
spdk_trace_record(TRACE_NVMF_LIB_READ_START, 0, 0, (uint64_t)req, 0);
if (spdk_bdev_read(bdev, ch, req->data, offset, req->length, nvmf_virtual_ctrlr_complete_cmd,
req) == NULL) {
req)) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
} else {
spdk_trace_record(TRACE_NVMF_LIB_WRITE_START, 0, 0, (uint64_t)req, 0);
if (spdk_bdev_write(bdev, ch, req->data, offset, req->length, nvmf_virtual_ctrlr_complete_cmd,
req) == NULL) {
req)) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
@ -433,7 +433,7 @@ nvmf_virtual_ctrlr_flush_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
nbytes = spdk_bdev_get_num_blocks(bdev) * spdk_bdev_get_block_size(bdev);
if (spdk_bdev_flush(bdev, ch, 0, nbytes, nvmf_virtual_ctrlr_complete_cmd, req) == NULL) {
if (spdk_bdev_flush(bdev, ch, 0, nbytes, nvmf_virtual_ctrlr_complete_cmd, req)) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
@ -473,7 +473,7 @@ nvmf_virtual_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
to_be64(&unmap[i].lba, dsm_range[i].starting_lba);
to_be32(&unmap[i].block_count, dsm_range[i].length);
}
if (spdk_bdev_unmap(bdev, ch, unmap, nr, nvmf_virtual_ctrlr_complete_cmd, req) == NULL) {
if (spdk_bdev_unmap(bdev, ch, unmap, nr, nvmf_virtual_ctrlr_complete_cmd, req)) {
free(unmap);
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
@ -493,7 +493,7 @@ nvmf_virtual_ctrlr_nvme_passthru_io(struct spdk_bdev *bdev, struct spdk_io_chann
struct spdk_nvmf_request *req)
{
if (spdk_bdev_nvme_io_passthru(bdev, ch, &req->cmd->nvme_cmd, req->data, req->length,
nvmf_virtual_ctrlr_complete_cmd, req) == NULL) {
nvmf_virtual_ctrlr_complete_cmd, req)) {
req->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INVALID_OPCODE;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;

View File

@ -1248,6 +1248,8 @@ spdk_bdev_scsi_task_complete_cmd(struct spdk_bdev_io *bdev_io, bool success,
struct spdk_scsi_task *task = cb_arg;
int sc, sk, asc, ascq;
task->blockdev_io = bdev_io;
spdk_bdev_io_get_scsi_status(bdev_io, &sc, &sk, &asc, &ascq);
spdk_scsi_task_set_status(task, sc, sk, asc, ascq);
spdk_scsi_lun_complete_task(task->lun, task);
@ -1311,6 +1313,7 @@ spdk_bdev_scsi_read(struct spdk_bdev *bdev,
uint64_t blen;
uint64_t offset;
uint64_t nbytes;
int rc;
blen = spdk_bdev_get_block_size(bdev);
@ -1322,10 +1325,10 @@ spdk_bdev_scsi_read(struct spdk_bdev *bdev,
"Read: lba=%"PRIu64", len=%"PRIu64"\n",
lba, (uint64_t)task->length / blen);
task->blockdev_io = spdk_bdev_readv(bdev, task->ch, task->iovs,
task->iovcnt, offset, nbytes,
spdk_bdev_scsi_task_complete_cmd, task);
if (!task->blockdev_io) {
rc = spdk_bdev_readv(bdev, task->ch, task->iovs,
task->iovcnt, offset, nbytes,
spdk_bdev_scsi_task_complete_cmd, task);
if (rc) {
SPDK_ERRLOG("spdk_bdev_readv() failed\n");
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
SPDK_SCSI_SENSE_NO_SENSE,
@ -1347,6 +1350,7 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev,
uint64_t blen;
uint64_t offset;
uint64_t nbytes;
int rc;
struct spdk_scsi_task *primary = task->parent;
if (len == 0) {
@ -1377,12 +1381,12 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev,
}
offset += task->offset;
task->blockdev_io = spdk_bdev_writev(bdev, task->ch, task->iovs,
task->iovcnt, offset, task->length,
spdk_bdev_scsi_task_complete_cmd,
task);
rc = spdk_bdev_writev(bdev, task->ch, task->iovs,
task->iovcnt, offset, task->length,
spdk_bdev_scsi_task_complete_cmd,
task);
if (!task->blockdev_io) {
if (rc) {
SPDK_ERRLOG("spdk_bdev_writev failed\n");
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
SPDK_SCSI_SENSE_NO_SENSE,
@ -1412,6 +1416,7 @@ spdk_bdev_scsi_sync(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
uint64_t blen;
uint64_t offset;
uint64_t nbytes;
int rc;
if (num_blocks == 0) {
return SPDK_SCSI_TASK_COMPLETE;
@ -1432,10 +1437,10 @@ spdk_bdev_scsi_sync(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
return SPDK_SCSI_TASK_COMPLETE;
}
task->blockdev_io = spdk_bdev_flush(bdev, task->ch, offset, nbytes,
spdk_bdev_scsi_task_complete_cmd, task);
rc = spdk_bdev_flush(bdev, task->ch, offset, nbytes,
spdk_bdev_scsi_task_complete_cmd, task);
if (!task->blockdev_io) {
if (rc) {
SPDK_ERRLOG("spdk_bdev_flush() failed\n");
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
SPDK_SCSI_SENSE_NO_SENSE,
@ -1486,6 +1491,7 @@ spdk_bdev_scsi_unmap(struct spdk_bdev *bdev,
uint32_t bdesc_count, max_unmap_bdesc_count;
int bdesc_data_len;
int data_len;
int rc;
if (task->iovcnt == 1) {
data = (uint8_t *)task->iovs[0].iov_base;
@ -1533,11 +1539,11 @@ spdk_bdev_scsi_unmap(struct spdk_bdev *bdev,
return SPDK_SCSI_TASK_COMPLETE;
}
task->blockdev_io = spdk_bdev_unmap(bdev, task->ch, desc,
bdesc_count, spdk_bdev_scsi_task_complete_cmd,
task);
rc = spdk_bdev_unmap(bdev, task->ch, desc,
bdesc_count, spdk_bdev_scsi_task_complete_cmd,
task);
if (!task->blockdev_io) {
if (rc) {
SPDK_ERRLOG("SCSI Unmapping failed\n");
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
SPDK_SCSI_SENSE_NO_SENSE,

View File

@ -182,17 +182,17 @@ __blockdev_write(void *arg1, void *arg2)
{
struct bdevio_request *req = arg1;
struct io_target *target = req->target;
struct spdk_bdev_io *bdev_io;
int rc;
if (req->iovcnt) {
bdev_io = spdk_bdev_writev(target->bdev, target->ch, req->iov, req->iovcnt, req->offset,
req->data_len, quick_test_complete, NULL);
rc = spdk_bdev_writev(target->bdev, target->ch, req->iov, req->iovcnt, req->offset,
req->data_len, quick_test_complete, NULL);
} else {
bdev_io = spdk_bdev_write(target->bdev, target->ch, req->buf, req->offset,
req->data_len, quick_test_complete, NULL);
rc = spdk_bdev_write(target->bdev, target->ch, req->buf, req->offset,
req->data_len, quick_test_complete, NULL);
}
if (!bdev_io) {
if (rc) {
g_completion_success = false;
wake_ut_thread();
}
@ -244,17 +244,17 @@ __blockdev_read(void *arg1, void *arg2)
{
struct bdevio_request *req = arg1;
struct io_target *target = req->target;
struct spdk_bdev_io *bdev_io;
int rc;
if (req->iovcnt) {
bdev_io = spdk_bdev_readv(target->bdev, target->ch, req->iov, req->iovcnt, req->offset,
req->data_len, quick_test_complete, NULL);
rc = spdk_bdev_readv(target->bdev, target->ch, req->iov, req->iovcnt, req->offset,
req->data_len, quick_test_complete, NULL);
} else {
bdev_io = spdk_bdev_read(target->bdev, target->ch, req->buf, req->offset,
req->data_len, quick_test_complete, NULL);
rc = spdk_bdev_read(target->bdev, target->ch, req->buf, req->offset,
req->data_len, quick_test_complete, NULL);
}
if (!bdev_io) {
if (rc) {
g_completion_success = false;
wake_ut_thread();
}

View File

@ -239,6 +239,7 @@ bdevperf_unmap_complete(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg
{
struct io_target *target;
struct bdevperf_task *task = cb_arg;
int rc;
target = task->target;
@ -246,8 +247,14 @@ bdevperf_unmap_complete(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg
memset(task->buf, 0, g_io_size);
/* Read the data back in */
spdk_bdev_read(target->bdev, target->ch, NULL, task->offset, g_io_size,
bdevperf_complete, task);
rc = spdk_bdev_read(target->bdev, target->ch, NULL, task->offset, g_io_size,
bdevperf_complete, task);
if (rc) {
printf("Failed to submit read: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
return;
}
spdk_bdev_free_io(bdev_io);
@ -259,6 +266,7 @@ bdevperf_verify_write_complete(struct spdk_bdev_io *bdev_io, bool success,
{
struct io_target *target;
struct bdevperf_task *task = cb_arg;
int rc;
target = task->target;
@ -269,14 +277,26 @@ bdevperf_verify_write_complete(struct spdk_bdev_io *bdev_io, bool success,
to_be64(&task->bdesc.lba, task->offset / block_size);
to_be32(&task->bdesc.block_count, g_io_size / block_size);
spdk_bdev_unmap(target->bdev, target->ch, &task->bdesc, 1, bdevperf_unmap_complete,
task);
rc = spdk_bdev_unmap(target->bdev, target->ch, &task->bdesc, 1, bdevperf_unmap_complete,
task);
if (rc) {
printf("Failed to submit unmap: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
return;
}
} else {
/* Read the data back in */
spdk_bdev_read(target->bdev, target->ch, NULL,
task->offset,
g_io_size,
bdevperf_complete, task);
rc = spdk_bdev_read(target->bdev, target->ch, NULL,
task->offset,
g_io_size,
bdevperf_complete, task);
if (rc) {
printf("Failed to submit read: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
return;
}
}
spdk_bdev_free_io(bdev_io);
@ -300,6 +320,7 @@ bdevperf_submit_single(struct io_target *target)
struct bdevperf_task *task = NULL;
uint64_t offset_in_ios;
void *rbuf;
int rc;
bdev = target->bdev;
ch = target->ch;
@ -325,18 +346,36 @@ bdevperf_submit_single(struct io_target *target)
memset(task->buf, rand_r(&seed) % 256, g_io_size);
task->iov.iov_base = task->buf;
task->iov.iov_len = g_io_size;
spdk_bdev_writev(bdev, ch, &task->iov, 1, task->offset, g_io_size,
bdevperf_verify_write_complete, task);
rc = spdk_bdev_writev(bdev, ch, &task->iov, 1, task->offset, g_io_size,
bdevperf_verify_write_complete, task);
if (rc) {
printf("Failed to submit writev: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
return;
}
} else if ((g_rw_percentage == 100) ||
(g_rw_percentage != 0 && ((rand_r(&seed) % 100) < g_rw_percentage))) {
rbuf = g_zcopy ? NULL : task->buf;
spdk_bdev_read(bdev, ch, rbuf, task->offset, g_io_size,
bdevperf_complete, task);
rc = spdk_bdev_read(bdev, ch, rbuf, task->offset, g_io_size,
bdevperf_complete, task);
if (rc) {
printf("Failed to submit read: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
return;
}
} else {
task->iov.iov_base = task->buf;
task->iov.iov_len = g_io_size;
spdk_bdev_writev(bdev, ch, &task->iov, 1, task->offset, g_io_size,
bdevperf_complete, task);
rc = spdk_bdev_writev(bdev, ch, &task->iov, 1, task->offset, g_io_size,
bdevperf_complete, task);
if (rc) {
printf("Failed to submit writev: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
return;
}
}
target->current_queue_depth++;
@ -378,6 +417,7 @@ reset_cb(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg)
}
rte_mempool_put(task_pool, task);
spdk_bdev_free_io(bdev_io);
spdk_poller_register(&target->reset_timer, reset_target, target, target->lcore,
10 * 1000000);
@ -388,14 +428,20 @@ reset_target(void *arg)
{
struct io_target *target = arg;
struct bdevperf_task *task = NULL;
int rc;
spdk_poller_unregister(&target->reset_timer, NULL);
/* Do reset. */
rte_mempool_get(task_pool, (void **)&task);
task->target = target;
spdk_bdev_reset(target->bdev, target->ch,
reset_cb, task);
rc = spdk_bdev_reset(target->bdev, target->ch,
reset_cb, task);
if (rc) {
printf("Reset failed: %d\n", rc);
target->is_draining = true;
g_run_failed = true;
}
}
static void

View File

@ -123,17 +123,19 @@ spdk_bdev_get_io_channel(struct spdk_bdev *bdev)
return NULL;
}
struct spdk_bdev_io *spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length, spdk_bdev_io_completion_cb cb, void *cb_arg)
int
spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length, spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
struct spdk_bdev_io *spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d, uint16_t bdesc_count, spdk_bdev_io_completion_cb cb,
void *cb_arg)
int
spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d, uint16_t bdesc_count, spdk_bdev_io_completion_cb cb,
void *cb_arg)
{
return NULL;
return 0;
}
void
@ -148,26 +150,28 @@ spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_ty
return false;
}
struct spdk_bdev_io *spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch, void *buf,
uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg)
int
spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch, void *buf,
uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch, void *buf,
uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg)
int
spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch, void *buf,
uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev,
struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
int spdk_bdev_free_io(struct spdk_bdev_io *bdev_io)

View File

@ -43,7 +43,6 @@ SPDK_LOG_REGISTER_TRACE_FLAG("scsi", SPDK_TRACE_SCSI)
struct spdk_scsi_globals g_spdk_scsi;
static uint64_t g_test_bdev_num_blocks;
static struct spdk_bdev_io g_test_bdev_io;
void *
spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr)
@ -189,38 +188,38 @@ spdk_bdev_io_get_iovec(struct spdk_bdev_io *bdev_io, struct iovec **iovp, int *i
*iovcntp = 0;
}
struct spdk_bdev_io *
int
spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_readv(struct spdk_bdev *bdev, 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)
{
return &g_test_bdev_io;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
int
@ -230,12 +229,12 @@ spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
return 0;
}
struct spdk_bdev_io *
int
spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
return 0;
}
/*