Commit b9bcc353 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

bdev: make enum spdk_bdev_io_status private



The user should not see the bdev_io status directly; the NVMe and SCSI
error code wrappers provide the ability to translate to the desired
format regardless of what kind of error is stored inside the bdev_io.

Replace the spdk_bdev_io_completion_cb status parameter with a bool
simply indiciating whether the I/O completed successfully.

Change-Id: Iad18c2dac4374112c41b7a656154ed3ae1a68569
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/362047


Tested-by: default avatar <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 54cfee2e
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -84,15 +84,6 @@ enum spdk_bdev_io_type {
	SPDK_BDEV_IO_TYPE_RESET,
};

/** Blockdev I/O completion status */
enum spdk_bdev_io_status {
	SPDK_BDEV_IO_STATUS_SCSI_ERROR = -3,
	SPDK_BDEV_IO_STATUS_NVME_ERROR = -2,
	SPDK_BDEV_IO_STATUS_FAILED = -1,
	SPDK_BDEV_IO_STATUS_PENDING = 0,
	SPDK_BDEV_IO_STATUS_SUCCESS = 1,
};

/** Blockdev reset operation type */
enum spdk_bdev_reset_type {
	/**
@@ -110,8 +101,17 @@ enum spdk_bdev_reset_type {
	SPDK_BDEV_RESET_SOFT,
};

/**
 * Block device completion callback
 *
 * \param bdev_io Block device I/O that has completed.
 * \param success true if I/O completed successfully or false if it failed; additional error
 *                information may be retrieved from bdev_io by calling
 *                spdk_bdev_io_get_nvme_status() or spdk_bdev_io_get_scsi_status().
 * \param cb_arg Callback argument specified when bdev_io was submitted.
 */
typedef void (*spdk_bdev_io_completion_cb)(struct spdk_bdev_io *bdev_io,
		enum spdk_bdev_io_status status,
		bool success,
		void *cb_arg);

struct spdk_bdev *spdk_bdev_get_by_name(const char *bdev_name);
+9 −0
Original line number Diff line number Diff line
@@ -148,6 +148,15 @@ struct spdk_bdev_fn_table {
	int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
};

/** Blockdev I/O completion status */
enum spdk_bdev_io_status {
	SPDK_BDEV_IO_STATUS_SCSI_ERROR = -3,
	SPDK_BDEV_IO_STATUS_NVME_ERROR = -2,
	SPDK_BDEV_IO_STATUS_FAILED = -1,
	SPDK_BDEV_IO_STATUS_PENDING = 0,
	SPDK_BDEV_IO_STATUS_SUCCESS = 1,
};

struct spdk_bdev {
	/** User context passed in by the backend */
	void *ctxt;
+1 −1
Original line number Diff line number Diff line
@@ -943,7 +943,7 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta
	bdev_io->status = status;

	assert(bdev_io->cb != NULL);
	bdev_io->cb(bdev_io, status, bdev_io->caller_ctx);
	bdev_io->cb(bdev_io, status == SPDK_BDEV_IO_STATUS_SUCCESS, bdev_io->caller_ctx);
}

void
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ spdk_vbdev_inject_error(uint32_t io_type_mask, uint32_t error_num)
}

static void
vbdev_error_task_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status,
vbdev_error_task_complete(struct spdk_bdev_io *bdev_io, bool success,
			  void *cb_arg)
{
	struct spdk_bdev_io *bdevio = (struct spdk_bdev_io *)cb_arg;
+2 −2
Original line number Diff line number Diff line
@@ -52,12 +52,12 @@ __get_bdev(struct spdk_bs_dev *dev)
}

static void
bdev_blob_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status, void *arg)
bdev_blob_io_complete(struct spdk_bdev_io *bdev_io, bool success, void *arg)
{
	struct spdk_bs_dev_cb_args *cb_args = arg;
	int bserrno;

	if (status == SPDK_BDEV_IO_STATUS_SUCCESS) {
	if (success) {
		bserrno = 0;
	} else {
		bserrno = -EIO;
Loading