bdev: pass descriptors for I/O operations

This enables checking permissions - for example,
spdk_bdev_write will fail if the descriptor was not
created with write permissions.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I68b65a560f471f2e0f71a7f42cfa6689b911110f

Reviewed-on: https://review.gerrithub.io/369493
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Jim Harris 2017-07-06 12:39:19 -07:00
parent f71447e80d
commit be9a3b9f69
17 changed files with 176 additions and 101 deletions

View File

@ -164,6 +164,14 @@ int spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t rem
*/ */
void spdk_bdev_close(struct spdk_bdev_desc *desc); void spdk_bdev_close(struct spdk_bdev_desc *desc);
/**
* Get the bdev associated with a bdev descriptor.
*
* \param desc Open block device desciptor
* \return bdev associated with the descriptor
*/
struct spdk_bdev *spdk_bdev_desc_get_bdev(struct spdk_bdev_desc *desc);
bool spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type); bool spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type);
int spdk_bdev_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w); int spdk_bdev_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w);
@ -256,7 +264,7 @@ struct spdk_io_channel *spdk_bdev_get_io_channel(struct spdk_bdev_desc *desc);
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch, int spdk_bdev_read(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes, void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -280,7 +288,7 @@ int spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch, int spdk_bdev_readv(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t nbytes, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -300,7 +308,7 @@ int spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch, int spdk_bdev_write(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes, void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -324,7 +332,7 @@ int spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch, int spdk_bdev_writev(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len, uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -345,7 +353,7 @@ int spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch, int spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d, struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count, uint16_t bdesc_count,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -366,7 +374,7 @@ int spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch, int spdk_bdev_flush(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length, uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
@ -382,7 +390,7 @@ int spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * 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, int spdk_bdev_reset(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
spdk_bdev_io_completion_cb cb, void *cb_arg); spdk_bdev_io_completion_cb cb, void *cb_arg);
/** /**
@ -405,7 +413,7 @@ int spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, int spdk_bdev_nvme_admin_passthru(struct spdk_bdev_desc *desc,
struct spdk_io_channel *ch, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes, void *buf, size_t nbytes,
@ -432,7 +440,7 @@ int spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev,
* be called (even if the request ultimately failed). Return * be called (even if the request ultimately failed). Return
* negated errno on failure, in which case the callback will not be called. * negated errno on failure, in which case the callback will not be called.
*/ */
int spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, int spdk_bdev_nvme_io_passthru(struct spdk_bdev_desc *bdev_desc,
struct spdk_io_channel *ch, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes, void *buf, size_t nbytes,

View File

@ -95,6 +95,7 @@ struct spdk_scsi_task {
uint8_t function; /* task mgmt function */ uint8_t function; /* task mgmt function */
uint8_t response; /* task mgmt response */ uint8_t response; /* task mgmt response */
struct spdk_scsi_lun *lun; struct spdk_scsi_lun *lun;
struct spdk_bdev_desc *desc;
struct spdk_io_channel *ch; struct spdk_io_channel *ch;
struct spdk_scsi_port *target_port; struct spdk_scsi_port *target_port;
struct spdk_scsi_port *initiator_port; struct spdk_scsi_port *initiator_port;

View File

@ -398,7 +398,7 @@ void spdk_bdev_poller_stop(struct spdk_bdev_poller **ppoller);
void spdk_bdev_io_get_buf(struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_buf_cb cb); void spdk_bdev_io_get_buf(struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_buf_cb cb);
struct spdk_bdev_io *spdk_bdev_get_io(void); struct spdk_bdev_io *spdk_bdev_get_io(void);
void spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev *new_bdev); void spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev_desc *new_bdev_desc);
void spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, void spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io,
enum spdk_bdev_io_status status); enum spdk_bdev_io_status status);

View File

@ -580,8 +580,10 @@ spdk_bdev_io_submit(struct spdk_bdev_io *bdev_io)
} }
void void
spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev *new_bdev) spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev_desc *new_bdev_desc)
{ {
struct spdk_bdev *new_bdev = new_bdev_desc->bdev;
assert(bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING); assert(bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING);
bdev_io->bdev = new_bdev; bdev_io->bdev = new_bdev;
@ -764,10 +766,11 @@ spdk_bdev_io_valid(struct spdk_bdev *bdev, uint64_t offset, uint64_t nbytes)
} }
int int
spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_read(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes, void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
@ -802,11 +805,12 @@ spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_readv(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t nbytes, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
@ -839,14 +843,19 @@ spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_write(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes, void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
if (!desc->write) {
return -EBADF;
}
if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) { if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) {
return -EINVAL; return -EINVAL;
} }
@ -877,15 +886,20 @@ spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_writev(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len, uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
if (!desc->write) {
return -EBADF;
}
if (spdk_bdev_io_valid(bdev, offset, len) != 0) { if (spdk_bdev_io_valid(bdev, offset, len) != 0) {
return -EINVAL; return -EINVAL;
} }
@ -914,15 +928,20 @@ spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d, struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count, uint16_t bdesc_count,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
if (!desc->write) {
return -EBADF;
}
if (bdesc_count == 0) { if (bdesc_count == 0) {
SPDK_ERRLOG("Invalid bdesc_count 0\n"); SPDK_ERRLOG("Invalid bdesc_count 0\n");
return -EINVAL; return -EINVAL;
@ -956,14 +975,19 @@ spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_flush(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length, uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
if (!desc->write) {
return -EBADF;
}
bdev_io = spdk_bdev_get_io(); bdev_io = spdk_bdev_get_io();
if (!bdev_io) { if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed duing flush\n"); SPDK_ERRLOG("bdev_io memory allocation failed duing flush\n");
@ -1045,9 +1069,10 @@ _spdk_bdev_start_next_reset(struct spdk_bdev *bdev)
} }
int int
spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_reset(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
@ -1087,14 +1112,19 @@ spdk_bdev_get_io_stat(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_nvme_admin_passthru(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes, const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
if (!desc->write) {
return -EBADF;
}
bdev_io = spdk_bdev_get_io(); bdev_io = spdk_bdev_get_io();
if (!bdev_io) { if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n"); SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n");
@ -1119,14 +1149,24 @@ spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch
} }
int int
spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_nvme_io_passthru(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes, const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
struct spdk_bdev *bdev = desc->bdev;
struct spdk_bdev_io *bdev_io; struct spdk_bdev_io *bdev_io;
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
int rc; int rc;
if (!desc->write) {
/*
* Do not try to parse the NVMe command - we could maybe use bits in the opcode
* to easily determine if the command is a read or write, but for now just
* do not allow io_passthru with a read-only descriptor.
*/
return -EBADF;
}
bdev_io = spdk_bdev_get_io(); bdev_io = spdk_bdev_get_io();
if (!bdev_io) { if (!bdev_io) {
SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n"); SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n");
@ -1560,6 +1600,12 @@ spdk_bdev_module_release_bdev(struct spdk_bdev *bdev)
bdev->claim_module = NULL; bdev->claim_module = NULL;
} }
struct spdk_bdev *
spdk_bdev_desc_get_bdev(struct spdk_bdev_desc *desc)
{
return desc->bdev;
}
void void
spdk_bdev_io_get_iovec(struct spdk_bdev_io *bdev_io, struct iovec **iovp, int *iovcntp) spdk_bdev_io_get_iovec(struct spdk_bdev_io *bdev_io, struct iovec **iovp, int *iovcntp)
{ {

View File

@ -60,6 +60,7 @@ struct vbdev_error_info {
struct vbdev_error_disk { struct vbdev_error_disk {
struct spdk_bdev disk; struct spdk_bdev disk;
struct spdk_bdev *base_bdev; struct spdk_bdev *base_bdev;
struct spdk_bdev_desc *base_bdev_desc;
struct vbdev_error_info error_vector[SPDK_BDEV_IO_TYPE_RESET]; struct vbdev_error_info error_vector[SPDK_BDEV_IO_TYPE_RESET];
TAILQ_ENTRY(vbdev_error_disk) tailq; TAILQ_ENTRY(vbdev_error_disk) tailq;
@ -162,7 +163,7 @@ vbdev_error_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev
error_type = vbdev_error_get_error_type(error_disk, bdev_io->type); error_type = vbdev_error_get_error_type(error_disk, bdev_io->type);
if (error_type == 0) { if (error_type == 0) {
spdk_bdev_io_resubmit(bdev_io, error_disk->base_bdev); spdk_bdev_io_resubmit(bdev_io, error_disk->base_bdev_desc);
return; return;
} else if (error_type == VBDEV_IO_FAILURE) { } else if (error_type == VBDEV_IO_FAILURE) {
error_disk->error_vector[bdev_io->type].error_num--; error_disk->error_vector[bdev_io->type].error_num--;
@ -259,7 +260,12 @@ spdk_vbdev_error_create(struct spdk_bdev *base_bdev)
goto cleanup; goto cleanup;
} }
rc = spdk_bdev_module_claim_bdev(base_bdev, NULL, SPDK_GET_BDEV_MODULE(error)); rc = spdk_bdev_open(base_bdev, false, NULL, NULL, &disk->base_bdev_desc);
if (rc) {
SPDK_ERRLOG("could not open bdev %s\n", spdk_bdev_get_name(base_bdev));
}
rc = spdk_bdev_module_claim_bdev(base_bdev, disk->base_bdev_desc, SPDK_GET_BDEV_MODULE(error));
if (rc) { if (rc) {
SPDK_ERRLOG("could not claim bdev %s\n", spdk_bdev_get_name(base_bdev)); SPDK_ERRLOG("could not claim bdev %s\n", spdk_bdev_get_name(base_bdev));
goto cleanup; goto cleanup;

View File

@ -208,7 +208,7 @@ vbdev_gpt_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
case SPDK_BDEV_IO_TYPE_RESET: case SPDK_BDEV_IO_TYPE_RESET:
base_ch = spdk_get_io_channel(gpt_partition_disk->base_bdev); base_ch = spdk_get_io_channel(gpt_partition_disk->base_bdev);
*(struct spdk_io_channel **)bdev_io->driver_ctx = base_ch; *(struct spdk_io_channel **)bdev_io->driver_ctx = base_ch;
spdk_bdev_reset(gpt_partition_disk->base_bdev, base_ch, spdk_bdev_reset(gpt_partition_disk->gpt_base->bdev_desc, base_ch,
_vbdev_gpt_complete_reset, bdev_io); _vbdev_gpt_complete_reset, bdev_io);
return; return;
default: default:
@ -218,7 +218,7 @@ vbdev_gpt_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
} }
/* Submit the modified I/O to the underlying bdev. */ /* Submit the modified I/O to the underlying bdev. */
spdk_bdev_io_resubmit(bdev_io, gpt_partition_disk->base_bdev); spdk_bdev_io_resubmit(bdev_io, gpt_partition_disk->gpt_base->bdev_desc);
} }
static void static void
@ -429,8 +429,6 @@ spdk_gpt_bdev_complete(struct spdk_bdev_io *bdev_io, bool status, void *arg)
/* free the ch and also close the bdev_desc */ /* free the ch and also close the bdev_desc */
spdk_put_io_channel(gpt_bdev->ch); spdk_put_io_channel(gpt_bdev->ch);
gpt_bdev->ch = NULL; gpt_bdev->ch = NULL;
spdk_bdev_close(gpt_bdev->bdev_desc);
gpt_bdev->bdev_desc = NULL;
spdk_bdev_free_io(bdev_io); spdk_bdev_free_io(bdev_io);
if (status != SPDK_BDEV_IO_STATUS_SUCCESS) { if (status != SPDK_BDEV_IO_STATUS_SUCCESS) {
@ -445,7 +443,7 @@ spdk_gpt_bdev_complete(struct spdk_bdev_io *bdev_io, bool status, void *arg)
goto end; goto end;
} }
rc = spdk_bdev_module_claim_bdev(bdev, NULL, SPDK_GET_BDEV_MODULE(gpt)); rc = spdk_bdev_module_claim_bdev(bdev, gpt_bdev->bdev_desc, SPDK_GET_BDEV_MODULE(gpt));
if (rc) { if (rc) {
SPDK_ERRLOG("could not claim bdev %s\n", spdk_bdev_get_name(bdev)); SPDK_ERRLOG("could not claim bdev %s\n", spdk_bdev_get_name(bdev));
goto end; goto end;
@ -467,6 +465,7 @@ end:
if (gpt_bdev->ref == 0) { if (gpt_bdev->ref == 0) {
/* If no gpt_partition_disk instances were created, free the base context */ /* If no gpt_partition_disk instances were created, free the base context */
spdk_bdev_close(gpt_bdev->bdev_desc);
spdk_gpt_bdev_free(gpt_bdev); spdk_gpt_bdev_free(gpt_bdev);
if (claimed) { if (claimed) {
spdk_bdev_module_release_bdev(bdev); spdk_bdev_module_release_bdev(bdev);
@ -486,7 +485,7 @@ vbdev_gpt_read_gpt(struct spdk_bdev *bdev)
return -1; return -1;
} }
rc = spdk_bdev_read(gpt_bdev->bdev, gpt_bdev->ch, gpt_bdev->gpt.buf, 0, SPDK_GPT_BUFFER_SIZE, rc = spdk_bdev_read(gpt_bdev->bdev_desc, gpt_bdev->ch, gpt_bdev->gpt.buf, 0, SPDK_GPT_BUFFER_SIZE,
spdk_gpt_bdev_complete, gpt_bdev); spdk_gpt_bdev_complete, gpt_bdev);
if (rc < 0) { if (rc < 0) {
spdk_gpt_bdev_free(gpt_bdev); spdk_gpt_bdev_free(gpt_bdev);

View File

@ -52,6 +52,7 @@ SPDK_DECLARE_BDEV_MODULE(split);
/* Base block device split context */ /* Base block device split context */
struct split_base { struct split_base {
struct spdk_bdev *base_bdev; struct spdk_bdev *base_bdev;
struct spdk_bdev_desc *desc;
uint32_t ref; uint32_t ref;
}; };
@ -132,7 +133,8 @@ vbdev_split_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev
case SPDK_BDEV_IO_TYPE_RESET: case SPDK_BDEV_IO_TYPE_RESET:
base_ch = spdk_get_io_channel(split_disk->base_bdev); base_ch = spdk_get_io_channel(split_disk->base_bdev);
*(struct spdk_io_channel **)bdev_io->driver_ctx = base_ch; *(struct spdk_io_channel **)bdev_io->driver_ctx = base_ch;
spdk_bdev_reset(split_disk->base_bdev, base_ch, _vbdev_split_complete_reset, bdev_io); spdk_bdev_reset(split_disk->split_base->desc, base_ch,
_vbdev_split_complete_reset, bdev_io);
return; return;
default: default:
SPDK_ERRLOG("split: unknown I/O type %d\n", bdev_io->type); SPDK_ERRLOG("split: unknown I/O type %d\n", bdev_io->type);
@ -141,7 +143,7 @@ vbdev_split_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev
} }
/* Submit the modified I/O to the underlying bdev. */ /* Submit the modified I/O to the underlying bdev. */
spdk_bdev_io_resubmit(bdev_io, split_disk->base_bdev); spdk_bdev_io_resubmit(bdev_io, split_disk->split_base->desc);
} }
static void static void
@ -240,12 +242,6 @@ vbdev_split_create(struct spdk_bdev *base_bdev, uint64_t split_count, uint64_t s
int rc; int rc;
struct split_base *split_base; struct split_base *split_base;
rc = spdk_bdev_module_claim_bdev(base_bdev, NULL, SPDK_GET_BDEV_MODULE(split));
if (rc) {
SPDK_ERRLOG("could not claim bdev %s\n", spdk_bdev_get_name(base_bdev));
return -1;
}
if (split_size_mb) { if (split_size_mb) {
if (((split_size_mb * mb) % base_bdev->blocklen) != 0) { if (((split_size_mb * mb) % base_bdev->blocklen) != 0) {
SPDK_ERRLOG("Split size %" PRIu64 " MB is not possible with block size " SPDK_ERRLOG("Split size %" PRIu64 " MB is not possible with block size "
@ -282,6 +278,21 @@ vbdev_split_create(struct spdk_bdev *base_bdev, uint64_t split_count, uint64_t s
split_base->base_bdev = base_bdev; split_base->base_bdev = base_bdev;
split_base->ref = 0; split_base->ref = 0;
rc = spdk_bdev_open(base_bdev, false, NULL, NULL, &split_base->desc);
if (rc) {
SPDK_ERRLOG("could not open bdev %s\n", spdk_bdev_get_name(base_bdev));
free(split_base);
return -1;
}
rc = spdk_bdev_module_claim_bdev(base_bdev, split_base->desc, SPDK_GET_BDEV_MODULE(split));
if (rc) {
SPDK_ERRLOG("could not claim bdev %s\n", spdk_bdev_get_name(base_bdev));
spdk_bdev_close(split_base->desc);
free(split_base);
return -1;
}
offset_bytes = 0; offset_bytes = 0;
offset_blocks = 0; offset_blocks = 0;
for (i = 0; i < split_count; i++) { for (i = 0; i < split_count; i++) {
@ -334,7 +345,9 @@ vbdev_split_create(struct spdk_bdev *base_bdev, uint64_t split_count, uint64_t s
cleanup: cleanup:
if (split_base->ref == 0) { if (split_base->ref == 0) {
/* If no split_disk instances were created, free the base context */ /* If no split_disk instances were created, free the resources */
spdk_bdev_module_release_bdev(split_base->base_bdev);
spdk_bdev_close(split_base->desc);
free(split_base); free(split_base);
} }

View File

@ -81,7 +81,7 @@ bdev_blob_read(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, void *p
int rc; int rc;
uint32_t block_size = spdk_bdev_get_block_size(bdev); uint32_t block_size = spdk_bdev_get_block_size(bdev);
rc = spdk_bdev_read(bdev, channel, payload, lba * block_size, rc = spdk_bdev_read(__get_desc(dev), channel, payload, lba * block_size,
lba_count * block_size, bdev_blob_io_complete, cb_args); lba_count * block_size, bdev_blob_io_complete, cb_args);
if (rc) { if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc); cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
@ -96,7 +96,7 @@ bdev_blob_write(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, void *
int rc; int rc;
uint32_t block_size = spdk_bdev_get_block_size(bdev); uint32_t block_size = spdk_bdev_get_block_size(bdev);
rc = spdk_bdev_write(bdev, channel, payload, lba * block_size, rc = spdk_bdev_write(__get_desc(dev), channel, payload, lba * block_size,
lba_count * block_size, bdev_blob_io_complete, cb_args); lba_count * block_size, bdev_blob_io_complete, cb_args);
if (rc) { if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc); cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
@ -107,7 +107,6 @@ static void
bdev_blob_unmap(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64_t lba, bdev_blob_unmap(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64_t lba,
uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args) uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args)
{ {
struct spdk_bdev *bdev = __get_bdev(dev);
struct spdk_scsi_unmap_bdesc *desc; struct spdk_scsi_unmap_bdesc *desc;
int rc; int rc;
@ -118,7 +117,7 @@ bdev_blob_unmap(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64
to_be32(&desc->block_count, lba_count); to_be32(&desc->block_count, lba_count);
desc->reserved = 0; desc->reserved = 0;
rc = spdk_bdev_unmap(bdev, channel, desc, 1, bdev_blob_io_complete, cb_args); rc = spdk_bdev_unmap(__get_desc(dev), channel, desc, 1, bdev_blob_io_complete, cb_args);
if (rc) { if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc); cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
} }

View File

@ -434,8 +434,8 @@ nvmf_virtual_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req)
} }
static int static int
nvmf_virtual_ctrlr_rw_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch, nvmf_virtual_ctrlr_rw_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
struct spdk_nvmf_request *req) struct spdk_io_channel *ch, struct spdk_nvmf_request *req)
{ {
uint64_t lba_address; uint64_t lba_address;
uint64_t blockcnt; uint64_t blockcnt;
@ -468,14 +468,14 @@ nvmf_virtual_ctrlr_rw_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
if (cmd->opc == SPDK_NVME_OPC_READ) { if (cmd->opc == SPDK_NVME_OPC_READ) {
spdk_trace_record(TRACE_NVMF_LIB_READ_START, 0, 0, (uint64_t)req, 0); 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, if (spdk_bdev_read(desc, ch, req->data, offset, req->length, nvmf_virtual_ctrlr_complete_cmd,
req)) { req)) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
} }
} else { } else {
spdk_trace_record(TRACE_NVMF_LIB_WRITE_START, 0, 0, (uint64_t)req, 0); 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, if (spdk_bdev_write(desc, ch, req->data, offset, req->length, nvmf_virtual_ctrlr_complete_cmd,
req)) { req)) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
@ -486,15 +486,14 @@ nvmf_virtual_ctrlr_rw_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
static int static int
nvmf_virtual_ctrlr_flush_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch, nvmf_virtual_ctrlr_flush_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
struct spdk_nvmf_request *req) struct spdk_io_channel *ch, struct spdk_nvmf_request *req)
{ {
uint64_t nbytes; uint64_t nbytes;
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl; struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
nbytes = spdk_bdev_get_num_blocks(bdev) * spdk_bdev_get_block_size(bdev); 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)) { if (spdk_bdev_flush(desc, ch, 0, nbytes, nvmf_virtual_ctrlr_complete_cmd, req)) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
} }
@ -502,8 +501,8 @@ nvmf_virtual_ctrlr_flush_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
static int static int
nvmf_virtual_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch, nvmf_virtual_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
struct spdk_nvmf_request *req) struct spdk_io_channel *ch, struct spdk_nvmf_request *req)
{ {
int i; int i;
uint32_t attribute; uint32_t attribute;
@ -534,7 +533,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_be64(&unmap[i].lba, dsm_range[i].starting_lba);
to_be32(&unmap[i].block_count, dsm_range[i].length); to_be32(&unmap[i].block_count, dsm_range[i].length);
} }
if (spdk_bdev_unmap(bdev, ch, unmap, nr, nvmf_virtual_ctrlr_complete_cmd, req)) { if (spdk_bdev_unmap(desc, ch, unmap, nr, nvmf_virtual_ctrlr_complete_cmd, req)) {
free(unmap); free(unmap);
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
@ -550,10 +549,10 @@ nvmf_virtual_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
static int static int
nvmf_virtual_ctrlr_nvme_passthru_io(struct spdk_bdev *bdev, struct spdk_io_channel *ch, nvmf_virtual_ctrlr_nvme_passthru_io(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
struct spdk_nvmf_request *req) struct spdk_io_channel *ch, struct spdk_nvmf_request *req)
{ {
if (spdk_bdev_nvme_io_passthru(bdev, ch, &req->cmd->nvme_cmd, req->data, req->length, if (spdk_bdev_nvme_io_passthru(desc, ch, &req->cmd->nvme_cmd, req->data, req->length,
nvmf_virtual_ctrlr_complete_cmd, req)) { nvmf_virtual_ctrlr_complete_cmd, req)) {
req->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC; req->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INVALID_OPCODE; req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INVALID_OPCODE;
@ -568,6 +567,7 @@ nvmf_virtual_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)
{ {
uint32_t nsid; uint32_t nsid;
struct spdk_bdev *bdev; struct spdk_bdev *bdev;
struct spdk_bdev_desc *desc;
struct spdk_io_channel *ch; struct spdk_io_channel *ch;
struct spdk_nvmf_subsystem *subsystem = req->conn->sess->subsys; struct spdk_nvmf_subsystem *subsystem = req->conn->sess->subsys;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
@ -589,17 +589,18 @@ nvmf_virtual_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
} }
desc = subsystem->dev.virt.desc[nsid - 1];
ch = subsystem->dev.virt.ch[nsid - 1]; ch = subsystem->dev.virt.ch[nsid - 1];
switch (cmd->opc) { switch (cmd->opc) {
case SPDK_NVME_OPC_READ: case SPDK_NVME_OPC_READ:
case SPDK_NVME_OPC_WRITE: case SPDK_NVME_OPC_WRITE:
return nvmf_virtual_ctrlr_rw_cmd(bdev, ch, req); return nvmf_virtual_ctrlr_rw_cmd(bdev, desc, ch, req);
case SPDK_NVME_OPC_FLUSH: case SPDK_NVME_OPC_FLUSH:
return nvmf_virtual_ctrlr_flush_cmd(bdev, ch, req); return nvmf_virtual_ctrlr_flush_cmd(bdev, desc, ch, req);
case SPDK_NVME_OPC_DATASET_MANAGEMENT: case SPDK_NVME_OPC_DATASET_MANAGEMENT:
return nvmf_virtual_ctrlr_dsm_cmd(bdev, ch, req); return nvmf_virtual_ctrlr_dsm_cmd(bdev, desc, ch, req);
default: default:
return nvmf_virtual_ctrlr_nvme_passthru_io(bdev, ch, req); return nvmf_virtual_ctrlr_nvme_passthru_io(bdev, desc, ch, req);
} }
} }

View File

@ -109,6 +109,7 @@ spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task,
} }
task->ch = task->lun->io_channel; task->ch = task->lun->io_channel;
task->desc = task->lun->bdev_desc;
switch (func) { switch (func) {
case SPDK_SCSI_TASK_FUNC_ABORT_TASK: case SPDK_SCSI_TASK_FUNC_ABORT_TASK:
@ -194,6 +195,7 @@ spdk_scsi_lun_execute_tasks(struct spdk_scsi_lun *lun)
TAILQ_FOREACH_SAFE(task, &lun->pending_tasks, scsi_link, task_tmp) { TAILQ_FOREACH_SAFE(task, &lun->pending_tasks, scsi_link, task_tmp) {
task->status = SPDK_SCSI_STATUS_GOOD; task->status = SPDK_SCSI_STATUS_GOOD;
task->ch = lun->io_channel; task->ch = lun->io_channel;
task->desc = lun->bdev_desc;
spdk_trace_record(TRACE_SCSI_TASK_START, lun->dev->id, task->length, (uintptr_t)task, 0); spdk_trace_record(TRACE_SCSI_TASK_START, lun->dev->id, task->length, (uintptr_t)task, 0);
TAILQ_REMOVE(&lun->pending_tasks, task, scsi_link); TAILQ_REMOVE(&lun->pending_tasks, task, scsi_link);
TAILQ_INSERT_TAIL(&lun->tasks, task, scsi_link); TAILQ_INSERT_TAIL(&lun->tasks, task, scsi_link);

View File

@ -1328,7 +1328,7 @@ spdk_bdev_scsi_read(struct spdk_bdev *bdev,
"Read: lba=%"PRIu64", len=%"PRIu64"\n", "Read: lba=%"PRIu64", len=%"PRIu64"\n",
lba, (uint64_t)task->length / blen); lba, (uint64_t)task->length / blen);
rc = spdk_bdev_readv(bdev, task->ch, task->iovs, rc = spdk_bdev_readv(task->desc, task->ch, task->iovs,
task->iovcnt, offset, nbytes, task->iovcnt, offset, nbytes,
spdk_bdev_scsi_task_complete_cmd, task); spdk_bdev_scsi_task_complete_cmd, task);
if (rc) { if (rc) {
@ -1384,7 +1384,7 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev,
} }
offset += task->offset; offset += task->offset;
rc = spdk_bdev_writev(bdev, task->ch, task->iovs, rc = spdk_bdev_writev(task->desc, task->ch, task->iovs,
task->iovcnt, offset, task->length, task->iovcnt, offset, task->length,
spdk_bdev_scsi_task_complete_cmd, spdk_bdev_scsi_task_complete_cmd,
task); task);
@ -1440,7 +1440,7 @@ spdk_bdev_scsi_sync(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
return SPDK_SCSI_TASK_COMPLETE; return SPDK_SCSI_TASK_COMPLETE;
} }
rc = spdk_bdev_flush(bdev, task->ch, offset, nbytes, rc = spdk_bdev_flush(task->desc, task->ch, offset, nbytes,
spdk_bdev_scsi_task_complete_cmd, task); spdk_bdev_scsi_task_complete_cmd, task);
if (rc) { if (rc) {
@ -1488,7 +1488,6 @@ static int
spdk_bdev_scsi_unmap(struct spdk_bdev *bdev, spdk_bdev_scsi_unmap(struct spdk_bdev *bdev,
struct spdk_scsi_task *task) struct spdk_scsi_task *task)
{ {
uint8_t *data; uint8_t *data;
struct spdk_scsi_unmap_bdesc *desc; struct spdk_scsi_unmap_bdesc *desc;
uint32_t bdesc_count, max_unmap_bdesc_count; uint32_t bdesc_count, max_unmap_bdesc_count;
@ -1542,7 +1541,7 @@ spdk_bdev_scsi_unmap(struct spdk_bdev *bdev,
return SPDK_SCSI_TASK_COMPLETE; return SPDK_SCSI_TASK_COMPLETE;
} }
rc = spdk_bdev_unmap(bdev, task->ch, desc, rc = spdk_bdev_unmap(task->desc, task->ch, desc,
bdesc_count, spdk_bdev_scsi_task_complete_cmd, bdesc_count, spdk_bdev_scsi_task_complete_cmd,
task); task);
@ -1965,6 +1964,6 @@ spdk_bdev_scsi_execute(struct spdk_bdev *bdev, struct spdk_scsi_task *task)
int int
spdk_bdev_scsi_reset(struct spdk_bdev *bdev, struct spdk_scsi_task *task) spdk_bdev_scsi_reset(struct spdk_bdev *bdev, struct spdk_scsi_task *task)
{ {
return spdk_bdev_reset(bdev, task->ch, return spdk_bdev_reset(task->desc, task->ch,
spdk_bdev_scsi_task_complete_mgmt, task); spdk_bdev_scsi_task_complete_mgmt, task);
} }

View File

@ -253,11 +253,11 @@ process_blk_request(struct spdk_vhost_blk_task *task, struct spdk_vhost_blk_dev
} }
if (type == VIRTIO_BLK_T_IN) { if (type == VIRTIO_BLK_T_IN) {
rc = spdk_bdev_readv(bvdev->bdev, bvdev->bdev_io_channel, rc = spdk_bdev_readv(bvdev->bdev_desc, bvdev->bdev_io_channel,
&task->iovs[1], task->iovcnt, req->sector * 512, &task->iovs[1], task->iovcnt, req->sector * 512,
task->length, blk_request_complete_cb, task); task->length, blk_request_complete_cb, task);
} else if (!bvdev->readonly) { } else if (!bvdev->readonly) {
rc = spdk_bdev_writev(bvdev->bdev, bvdev->bdev_io_channel, rc = spdk_bdev_writev(bvdev->bdev_desc, bvdev->bdev_io_channel,
&task->iovs[1], task->iovcnt, req->sector * 512, &task->iovs[1], task->iovcnt, req->sector * 512,
task->length, blk_request_complete_cb, task); task->length, blk_request_complete_cb, task);
} else { } else {

View File

@ -192,10 +192,10 @@ __blockdev_write(void *arg1, void *arg2)
int rc; int rc;
if (req->iovcnt) { if (req->iovcnt) {
rc = spdk_bdev_writev(target->bdev, target->ch, req->iov, req->iovcnt, req->offset, rc = spdk_bdev_writev(target->bdev_desc, target->ch, req->iov, req->iovcnt, req->offset,
req->data_len, quick_test_complete, NULL); req->data_len, quick_test_complete, NULL);
} else { } else {
rc = spdk_bdev_write(target->bdev, target->ch, req->buf, req->offset, rc = spdk_bdev_write(target->bdev_desc, target->ch, req->buf, req->offset,
req->data_len, quick_test_complete, NULL); req->data_len, quick_test_complete, NULL);
} }
@ -254,10 +254,10 @@ __blockdev_read(void *arg1, void *arg2)
int rc; int rc;
if (req->iovcnt) { if (req->iovcnt) {
rc = spdk_bdev_readv(target->bdev, target->ch, req->iov, req->iovcnt, req->offset, rc = spdk_bdev_readv(target->bdev_desc, target->ch, req->iov, req->iovcnt, req->offset,
req->data_len, quick_test_complete, NULL); req->data_len, quick_test_complete, NULL);
} else { } else {
rc = spdk_bdev_read(target->bdev, target->ch, req->buf, req->offset, rc = spdk_bdev_read(target->bdev_desc, target->ch, req->buf, req->offset,
req->data_len, quick_test_complete, NULL); req->data_len, quick_test_complete, NULL);
} }
@ -666,7 +666,7 @@ __blockdev_reset(void *arg1, void *arg2)
struct io_target *target = req->target; struct io_target *target = req->target;
int rc; int rc;
rc = spdk_bdev_reset(target->bdev, target->ch, quick_test_complete, NULL); rc = spdk_bdev_reset(target->bdev_desc, target->ch, quick_test_complete, NULL);
if (rc < 0) { if (rc < 0) {
g_completion_success = false; g_completion_success = false;
wake_ut_thread(); wake_ut_thread();

View File

@ -252,7 +252,7 @@ bdevperf_unmap_complete(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg
memset(task->buf, 0, g_io_size); memset(task->buf, 0, g_io_size);
/* Read the data back in */ /* Read the data back in */
rc = spdk_bdev_read(target->bdev, target->ch, NULL, task->offset, g_io_size, rc = spdk_bdev_read(target->bdev_desc, target->ch, NULL, task->offset, g_io_size,
bdevperf_complete, task); bdevperf_complete, task);
if (rc) { if (rc) {
printf("Failed to submit read: %d\n", rc); printf("Failed to submit read: %d\n", rc);
@ -282,7 +282,7 @@ bdevperf_verify_write_complete(struct spdk_bdev_io *bdev_io, bool success,
to_be64(&task->bdesc.lba, task->offset / block_size); to_be64(&task->bdesc.lba, task->offset / block_size);
to_be32(&task->bdesc.block_count, g_io_size / block_size); to_be32(&task->bdesc.block_count, g_io_size / block_size);
rc = spdk_bdev_unmap(target->bdev, target->ch, &task->bdesc, 1, bdevperf_unmap_complete, rc = spdk_bdev_unmap(target->bdev_desc, target->ch, &task->bdesc, 1, bdevperf_unmap_complete,
task); task);
if (rc) { if (rc) {
printf("Failed to submit unmap: %d\n", rc); printf("Failed to submit unmap: %d\n", rc);
@ -292,7 +292,7 @@ bdevperf_verify_write_complete(struct spdk_bdev_io *bdev_io, bool success,
} }
} else { } else {
/* Read the data back in */ /* Read the data back in */
rc = spdk_bdev_read(target->bdev, target->ch, NULL, rc = spdk_bdev_read(target->bdev_desc, target->ch, NULL,
task->offset, task->offset,
g_io_size, g_io_size,
bdevperf_complete, task); bdevperf_complete, task);
@ -320,14 +320,14 @@ static __thread unsigned int seed = 0;
static void static void
bdevperf_submit_single(struct io_target *target) bdevperf_submit_single(struct io_target *target)
{ {
struct spdk_bdev *bdev; struct spdk_bdev_desc *desc;
struct spdk_io_channel *ch; struct spdk_io_channel *ch;
struct bdevperf_task *task = NULL; struct bdevperf_task *task = NULL;
uint64_t offset_in_ios; uint64_t offset_in_ios;
void *rbuf; void *rbuf;
int rc; int rc;
bdev = target->bdev; desc = target->bdev_desc;
ch = target->ch; ch = target->ch;
if (rte_mempool_get(task_pool, (void **)&task) != 0 || task == NULL) { if (rte_mempool_get(task_pool, (void **)&task) != 0 || task == NULL) {
@ -351,7 +351,7 @@ bdevperf_submit_single(struct io_target *target)
memset(task->buf, rand_r(&seed) % 256, g_io_size); memset(task->buf, rand_r(&seed) % 256, g_io_size);
task->iov.iov_base = task->buf; task->iov.iov_base = task->buf;
task->iov.iov_len = g_io_size; task->iov.iov_len = g_io_size;
rc = spdk_bdev_writev(bdev, ch, &task->iov, 1, task->offset, g_io_size, rc = spdk_bdev_writev(desc, ch, &task->iov, 1, task->offset, g_io_size,
bdevperf_verify_write_complete, task); bdevperf_verify_write_complete, task);
if (rc) { if (rc) {
printf("Failed to submit writev: %d\n", rc); printf("Failed to submit writev: %d\n", rc);
@ -362,7 +362,7 @@ bdevperf_submit_single(struct io_target *target)
} else if ((g_rw_percentage == 100) || } else if ((g_rw_percentage == 100) ||
(g_rw_percentage != 0 && ((rand_r(&seed) % 100) < g_rw_percentage))) { (g_rw_percentage != 0 && ((rand_r(&seed) % 100) < g_rw_percentage))) {
rbuf = g_zcopy ? NULL : task->buf; rbuf = g_zcopy ? NULL : task->buf;
rc = spdk_bdev_read(bdev, ch, rbuf, task->offset, g_io_size, rc = spdk_bdev_read(desc, ch, rbuf, task->offset, g_io_size,
bdevperf_complete, task); bdevperf_complete, task);
if (rc) { if (rc) {
printf("Failed to submit read: %d\n", rc); printf("Failed to submit read: %d\n", rc);
@ -373,7 +373,7 @@ bdevperf_submit_single(struct io_target *target)
} else { } else {
task->iov.iov_base = task->buf; task->iov.iov_base = task->buf;
task->iov.iov_len = g_io_size; task->iov.iov_len = g_io_size;
rc = spdk_bdev_writev(bdev, ch, &task->iov, 1, task->offset, g_io_size, rc = spdk_bdev_writev(desc, ch, &task->iov, 1, task->offset, g_io_size,
bdevperf_complete, task); bdevperf_complete, task);
if (rc) { if (rc) {
printf("Failed to submit writev: %d\n", rc); printf("Failed to submit writev: %d\n", rc);
@ -440,7 +440,7 @@ reset_target(void *arg)
/* Do reset. */ /* Do reset. */
rte_mempool_get(task_pool, (void **)&task); rte_mempool_get(task_pool, (void **)&task);
task->target = target; task->target = target;
rc = spdk_bdev_reset(target->bdev, target->ch, rc = spdk_bdev_reset(target->bdev_desc, target->ch,
reset_cb, task); reset_cb, task);
if (rc) { if (rc) {
printf("Reset failed: %d\n", rc); printf("Reset failed: %d\n", rc);

View File

@ -169,26 +169,27 @@ nbd_io_done(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg)
} }
static void static void
nbd_submit_bdev_io(struct spdk_bdev *bdev, struct spdk_io_channel *ch, struct nbd_io *io) nbd_submit_bdev_io(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
struct spdk_io_channel *ch, struct nbd_io *io)
{ {
int rc; int rc;
switch (io->type) { switch (io->type) {
case SPDK_BDEV_IO_TYPE_READ: case SPDK_BDEV_IO_TYPE_READ:
rc = spdk_bdev_read(bdev, ch, io->payload, from_be64(&io->req.from), rc = spdk_bdev_read(desc, ch, io->payload, from_be64(&io->req.from),
io->payload_size, nbd_io_done, io); io->payload_size, nbd_io_done, io);
break; break;
case SPDK_BDEV_IO_TYPE_WRITE: case SPDK_BDEV_IO_TYPE_WRITE:
rc = spdk_bdev_write(bdev, ch, io->payload, from_be64(&io->req.from), rc = spdk_bdev_write(desc, ch, io->payload, from_be64(&io->req.from),
io->payload_size, nbd_io_done, io); io->payload_size, nbd_io_done, io);
break; break;
case SPDK_BDEV_IO_TYPE_UNMAP: case SPDK_BDEV_IO_TYPE_UNMAP:
to_be64(&io->unmap.lba, from_be64(&io->req.from) / spdk_bdev_get_block_size(bdev)); to_be64(&io->unmap.lba, from_be64(&io->req.from) / spdk_bdev_get_block_size(bdev));
to_be32(&io->unmap.block_count, io->payload_size / spdk_bdev_get_block_size(bdev)); to_be32(&io->unmap.block_count, io->payload_size / spdk_bdev_get_block_size(bdev));
rc = spdk_bdev_unmap(bdev, ch, &io->unmap, 1, nbd_io_done, io); rc = spdk_bdev_unmap(desc, ch, &io->unmap, 1, nbd_io_done, io);
break; break;
case SPDK_BDEV_IO_TYPE_FLUSH: case SPDK_BDEV_IO_TYPE_FLUSH:
rc = spdk_bdev_flush(bdev, ch, 0, spdk_bdev_get_num_blocks(bdev) * spdk_bdev_get_block_size(bdev), rc = spdk_bdev_flush(desc, ch, 0, spdk_bdev_get_num_blocks(bdev) * spdk_bdev_get_block_size(bdev),
nbd_io_done, io); nbd_io_done, io);
break; break;
default: default:
@ -224,7 +225,7 @@ process_request(struct nbd_disk *nbd)
switch (from_be32(&io->req.type)) { switch (from_be32(&io->req.type)) {
case NBD_CMD_READ: case NBD_CMD_READ:
io->type = SPDK_BDEV_IO_TYPE_READ; io->type = SPDK_BDEV_IO_TYPE_READ;
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io); nbd_submit_bdev_io(nbd->bdev, nbd->bdev_desc, nbd->ch, io);
break; break;
case NBD_CMD_WRITE: case NBD_CMD_WRITE:
io->type = SPDK_BDEV_IO_TYPE_WRITE; io->type = SPDK_BDEV_IO_TYPE_WRITE;
@ -236,13 +237,13 @@ process_request(struct nbd_disk *nbd)
#ifdef NBD_FLAG_SEND_FLUSH #ifdef NBD_FLAG_SEND_FLUSH
case NBD_CMD_FLUSH: case NBD_CMD_FLUSH:
io->type = SPDK_BDEV_IO_TYPE_FLUSH; io->type = SPDK_BDEV_IO_TYPE_FLUSH;
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io); nbd_submit_bdev_io(nbd->bdev, nbd->bdev_desc, nbd->ch, io);
break; break;
#endif #endif
#ifdef NBD_FLAG_SEND_TRIM #ifdef NBD_FLAG_SEND_TRIM
case NBD_CMD_TRIM: case NBD_CMD_TRIM:
io->type = SPDK_BDEV_IO_TYPE_UNMAP; io->type = SPDK_BDEV_IO_TYPE_UNMAP;
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io); nbd_submit_bdev_io(nbd->bdev, nbd->bdev_desc, nbd->ch, io);
break; break;
#endif #endif
} }
@ -276,7 +277,7 @@ nbd_poll(void *arg)
io->offset += ret; io->offset += ret;
if (io->offset == io->payload_size) { if (io->offset == io->payload_size) {
io->payload_in_progress = false; io->payload_in_progress = false;
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io); nbd_submit_bdev_io(nbd->bdev, nbd->bdev_desc, nbd->ch, io);
io->offset = 0; io->offset = 0;
} }
} }

View File

@ -143,14 +143,14 @@ spdk_bdev_get_io_channel(struct spdk_bdev_desc *desc)
} }
int int
spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_flush(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length, spdk_bdev_io_completion_cb cb, void *cb_arg) uint64_t offset, uint64_t length, spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
return 0; return 0;
} }
int int
spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d, uint16_t bdesc_count, spdk_bdev_io_completion_cb cb, struct spdk_scsi_unmap_bdesc *unmap_d, uint16_t bdesc_count, spdk_bdev_io_completion_cb cb,
void *cb_arg) void *cb_arg)
{ {
@ -170,21 +170,21 @@ spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_ty
} }
int int
spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch, void *buf, spdk_bdev_write(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, void *buf,
uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg) uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
return 0; return 0;
} }
int int
spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch, void *buf, spdk_bdev_read(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, void *buf,
uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg) uint64_t offset, uint64_t nbytes, spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
return 0; return 0;
} }
int int
spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, spdk_bdev_nvme_io_passthru(struct spdk_bdev_desc *desc,
struct spdk_io_channel *ch, struct spdk_io_channel *ch,
const struct spdk_nvme_cmd *cmd, const struct spdk_nvme_cmd *cmd,
void *buf, size_t nbytes, void *buf, size_t nbytes,

View File

@ -189,7 +189,7 @@ spdk_bdev_io_get_iovec(struct spdk_bdev_io *bdev_io, struct iovec **iovp, int *i
} }
int int
spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_read(struct spdk_bdev_desc *bdev_desc, struct spdk_io_channel *ch,
void *buf, uint64_t offset, uint64_t nbytes, void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
@ -197,7 +197,7 @@ spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_readv(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t nbytes, struct iovec *iov, int iovcnt, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
@ -205,7 +205,7 @@ spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_writev(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct iovec *iov, int iovcnt, struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t len, uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -214,7 +214,7 @@ spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_scsi_unmap_bdesc *unmap_d, struct spdk_scsi_unmap_bdesc *unmap_d,
uint16_t bdesc_count, uint16_t bdesc_count,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
@ -223,14 +223,14 @@ spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
} }
int int
spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_reset(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {
return 0; return 0;
} }
int int
spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_flush(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
uint64_t offset, uint64_t length, uint64_t offset, uint64_t length,
spdk_bdev_io_completion_cb cb, void *cb_arg) spdk_bdev_io_completion_cb cb, void *cb_arg)
{ {