Commit f93bb8a3 authored by Jim Harris's avatar Jim Harris
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ice326af5d6025867dffed4d1f6c7b81fb9eba5eb
parent edbed730
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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,
+4 −4
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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;
+3 −4
Original line number Diff line number Diff line
@@ -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);

+11 −11
Original line number Diff line number Diff line
@@ -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);
Loading