Switch spdk_bdev_read/write arg order for length and offset.

This matches the general order (LBA start then LBA count) for
the NVMe API.

While here, fix a copy/paste error in a debug message (write
instead of writev).

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ice326af5d6025867dffed4d1f6c7b81fb9eba5eb
This commit is contained in:
Jim Harris 2016-09-14 10:34:48 -07:00
parent edbed73064
commit f93bb8a32d
7 changed files with 30 additions and 34 deletions

View File

@ -287,14 +287,14 @@ struct spdk_bdev *spdk_bdev_next(struct spdk_bdev *prev);
bool spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type);
struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev,
void *buf, uint64_t nbytes, uint64_t offset,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_write(struct spdk_bdev *bdev,
void *buf, uint64_t nbytes, uint64_t offset,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_writev(struct spdk_bdev *bdev,
struct iovec *iov, int iovcnt,
uint64_t len, uint64_t offset,
uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_unmap(struct spdk_bdev *bdev,
struct spdk_scsi_unmap_bdesc *unmap_d,

View File

@ -536,7 +536,7 @@ spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_ty
struct spdk_bdev_io *
spdk_bdev_read(struct spdk_bdev *bdev,
void *buf, uint64_t nbytes, uint64_t offset,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
struct spdk_bdev_io *bdev_io;
@ -581,7 +581,7 @@ spdk_bdev_read(struct spdk_bdev *bdev,
struct spdk_bdev_io *
spdk_bdev_write(struct spdk_bdev *bdev,
void *buf, uint64_t nbytes, uint64_t offset,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
struct spdk_bdev_io *bdev_io;
@ -605,7 +605,7 @@ spdk_bdev_write(struct spdk_bdev *bdev,
bdev_io = spdk_bdev_get_io();
if (!bdev_io) {
SPDK_ERRLOG("blockdev_io memory allocation failed duing writev\n");
SPDK_ERRLOG("blockdev_io memory allocation failed duing write\n");
return NULL;
}
@ -630,7 +630,7 @@ spdk_bdev_write(struct spdk_bdev *bdev,
struct spdk_bdev_io *
spdk_bdev_writev(struct spdk_bdev *bdev,
struct iovec *iov, int iovcnt,
uint64_t len, uint64_t offset,
uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
struct spdk_bdev_io *bdev_io;

View File

@ -413,14 +413,14 @@ nvmf_virtual_ctrlr_rw_cmd(struct spdk_bdev *bdev, struct spdk_nvmf_request *req)
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, req->data, req->length, offset, nvmf_virtual_ctrlr_complete_cmd,
if (spdk_bdev_read(bdev, req->data, offset, req->length, nvmf_virtual_ctrlr_complete_cmd,
req) == NULL) {
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, req->data, req->length, offset, nvmf_virtual_ctrlr_complete_cmd,
if (spdk_bdev_write(bdev, req->data, offset, req->length, nvmf_virtual_ctrlr_complete_cmd,
req) == NULL) {
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;

View File

@ -1334,9 +1334,8 @@ spdk_bdev_scsi_read(struct spdk_bdev *bdev,
return -1;
}
task->blockdev_io = spdk_bdev_read(bdev, task->rbuf, nbytes,
offset, spdk_bdev_scsi_task_complete,
task);
task->blockdev_io = spdk_bdev_read(bdev, task->rbuf, offset, nbytes,
spdk_bdev_scsi_task_complete, task);
if (!task->blockdev_io) {
SPDK_ERRLOG("spdk_bdev_read() failed\n");
return -1;
@ -1386,7 +1385,7 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev,
offset += task->offset;
task->blockdev_io = spdk_bdev_writev(bdev, &task->iov,
1, task->length, offset,
1, offset, task->length,
spdk_bdev_scsi_task_complete,
task);

View File

@ -131,7 +131,7 @@ struct iovec iov;
static int
blockdev_write(struct io_target *target, void *bdev_task_ctx, char **tx_buf,
int data_len, uint64_t offset)
uint64_t offset, int data_len)
{
struct spdk_bdev_io *bdev_io;
@ -140,8 +140,8 @@ blockdev_write(struct io_target *target, void *bdev_task_ctx, char **tx_buf,
iov.iov_base = *tx_buf;
iov.iov_len = data_len;
bdev_io = spdk_bdev_writev(target->bdev, &iov, 1, iov.iov_len,
(uint64_t)offset, quick_test_complete,
bdev_io = spdk_bdev_writev(target->bdev, &iov, 1, (uint64_t)offset,
iov.iov_len, quick_test_complete,
bdev_task_ctx);
if (!bdev_io) {
return -1;
@ -152,14 +152,14 @@ blockdev_write(struct io_target *target, void *bdev_task_ctx, char **tx_buf,
static int
blockdev_read(struct io_target *target, void *bdev_task_ctx, char **rx_buf,
int data_len, uint64_t offset)
uint64_t offset, int data_len)
{
struct spdk_bdev_io *bdev_io;
complete = 0;
completion_status_per_io = SPDK_BDEV_IO_STATUS_FAILED;
bdev_io = spdk_bdev_read(target->bdev, *rx_buf, data_len, offset,
bdev_io = spdk_bdev_read(target->bdev, *rx_buf, offset, data_len,
quick_test_complete, bdev_task_ctx);
if (!bdev_io) {
@ -202,7 +202,7 @@ blockdev_write_read(uint32_t data_length, int pattern, uint64_t offset,
initialize_buffer(&rx_buf, 0, data_length);
rc = blockdev_write(target, (void *)bdev_task_ctx, &tx_buf,
data_length, offset);
offset, data_length);
/* Assert the rc of the respective blockdev */
CU_ASSERT_EQUAL(rc, expected_rc);
@ -217,7 +217,7 @@ blockdev_write_read(uint32_t data_length, int pattern, uint64_t offset,
}
rc = blockdev_read(target, (void *)bdev_task_ctx, &rx_buf,
data_length, offset);
offset, data_length);
/* Assert the rc of the respective blockdev */
CU_ASSERT_EQUAL(rc, expected_rc);
@ -346,7 +346,7 @@ blockdev_write_read_offset_plus_nbytes_equals_bdev_size(void)
initialize_buffer(&rx_buf, 0, bdev->blocklen);
rc = blockdev_write(target, (void *)bdev_task_ctx, &tx_buf,
bdev->blocklen, offset);
offset, bdev->blocklen);
/* Assert the rc of the respective blockdev */
CU_ASSERT_EQUAL(rc, (int)bdev->blocklen);
@ -357,7 +357,7 @@ blockdev_write_read_offset_plus_nbytes_equals_bdev_size(void)
CU_ASSERT_EQUAL(completion_status_per_io, SPDK_BDEV_IO_STATUS_SUCCESS);
rc = blockdev_read(target, (void *)bdev_task_ctx, &rx_buf,
bdev->blocklen, offset);
offset, bdev->blocklen);
/* Assert the rc of the respective blockdev */
CU_ASSERT_EQUAL(rc, (int)bdev->blocklen);
@ -411,7 +411,7 @@ blockdev_write_read_offset_plus_nbytes_gt_bdev_size(void)
initialize_buffer(&rx_buf, 0, data_length);
rc = blockdev_write(target, (void *)bdev_task_ctx, &tx_buf,
data_length, offset);
offset, data_length);
/* Assert the rc of the respective blockdev */
CU_ASSERT_EQUAL(rc, expected_rc);
@ -421,7 +421,7 @@ blockdev_write_read_offset_plus_nbytes_gt_bdev_size(void)
CU_ASSERT_EQUAL(completion_status_per_io, SPDK_BDEV_IO_STATUS_FAILED);
rc = blockdev_read(target, (void *)bdev_task_ctx, &rx_buf,
data_length, offset);
offset, data_length);
/* Assert the rc of the respective blockdev */
CU_ASSERT_EQUAL(rc, expected_rc);

View File

@ -231,8 +231,8 @@ bdevperf_unmap_complete(spdk_event_t event)
/* Read the data back in */
spdk_bdev_read(target->bdev, NULL,
from_be32(&bdev_io->u.unmap.unmap_bdesc->block_count) * target->bdev->blocklen,
from_be64(&bdev_io->u.unmap.unmap_bdesc->lba) * target->bdev->blocklen,
from_be32(&bdev_io->u.unmap.unmap_bdesc->block_count) * target->bdev->blocklen,
bdevperf_complete, task);
free(bdev_io->u.unmap.unmap_bdesc);
@ -265,8 +265,8 @@ bdevperf_verify_write_complete(spdk_event_t event)
} else {
/* Read the data back in */
spdk_bdev_read(target->bdev, NULL,
bdev_io->u.write.len,
bdev_io->u.write.offset,
bdev_io->u.write.len,
bdevperf_complete, task);
}
@ -313,20 +313,17 @@ 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, &task->iov, 1, g_io_size,
offset_in_ios * g_io_size,
spdk_bdev_writev(bdev, &task->iov, 1, offset_in_ios * g_io_size, g_io_size,
bdevperf_verify_write_complete, task);
} 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, rbuf, g_io_size,
offset_in_ios * g_io_size,
spdk_bdev_read(bdev, rbuf, offset_in_ios * g_io_size, g_io_size,
bdevperf_complete, task);
} else {
task->iov.iov_base = task->buf;
task->iov.iov_len = g_io_size;
spdk_bdev_writev(bdev, &task->iov, 1, g_io_size,
offset_in_ios * g_io_size,
spdk_bdev_writev(bdev, &task->iov, 1, offset_in_ios * g_io_size, g_io_size,
bdevperf_complete, task);
}

View File

@ -133,7 +133,7 @@ spdk_scsi_task_build_sense_data(struct spdk_scsi_task *task, int sk, int asc, in
struct spdk_bdev_io *
spdk_bdev_read(struct spdk_bdev *bdev,
void *buf, uint64_t nbytes, uint64_t offset,
void *buf, uint64_t offset, uint64_t nbytes,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;
@ -142,7 +142,7 @@ spdk_bdev_read(struct spdk_bdev *bdev,
struct spdk_bdev_io *
spdk_bdev_writev(struct spdk_bdev *bdev,
struct iovec *iov, int iovcnt,
uint64_t len, uint64_t offset,
uint64_t offset, uint64_t len,
spdk_bdev_io_completion_cb cb, void *cb_arg)
{
return NULL;