Commit a96dc259 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

bdev: remove event dependency from I/O callback



Use a plain function pointer + callback context for the bdev I/O
completion callback.  This is possible now because each I/O channel will
be polled on the core that submitted the I/O.

Change-Id: I29ee8e4a3430df11c74845adab840395b9bc5010
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 292c9c42
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -142,7 +142,9 @@ enum spdk_bdev_reset_type {
	SPDK_BDEV_RESET_SOFT,
};

typedef spdk_event_fn spdk_bdev_io_completion_cb;
typedef void (*spdk_bdev_io_completion_cb)(struct spdk_bdev_io *bdev_io,
		enum spdk_bdev_io_status status,
		void *cb_arg);
typedef void (*spdk_bdev_io_get_rbuf_cb)(struct spdk_bdev_io *bdev_io);

/**
@@ -253,8 +255,6 @@ struct spdk_bdev_io {
	/** Context that will be passed to the completion callback */
	void *caller_ctx;

	struct spdk_event *cb_event;

	/** Callback for when rbuf is allocated */
	spdk_bdev_io_get_rbuf_cb get_rbuf_cb;

+4 −13
Original line number Diff line number Diff line
@@ -409,10 +409,8 @@ spdk_bdev_cleanup_pending_rbuf_io(struct spdk_bdev *bdev)
}

static void
__submit_request(struct spdk_bdev *bdev, struct spdk_bdev_io *bdev_io, struct spdk_event *cb_event)
__submit_request(struct spdk_bdev *bdev, struct spdk_bdev_io *bdev_io)
{
	bdev_io->cb_event = cb_event;

	if (bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING) {
		if (bdev_io->type == SPDK_BDEV_IO_TYPE_RESET) {
			spdk_bdev_cleanup_pending_rbuf_io(bdev);
@@ -445,15 +443,8 @@ static int
spdk_bdev_io_submit(struct spdk_bdev_io *bdev_io)
{
	struct spdk_bdev *bdev = bdev_io->bdev;
	struct spdk_event *cb_event = NULL;

	if (bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING) {
		cb_event = spdk_event_allocate(rte_lcore_id(), bdev_io->cb,
					       bdev_io->caller_ctx, bdev_io);
		assert(cb_event != NULL);
	}

	__submit_request(bdev, bdev_io, cb_event);
	__submit_request(bdev, bdev_io);
	return 0;
}

@@ -842,8 +833,8 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta

	bdev_io->status = status;

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

void
+3 −4
Original line number Diff line number Diff line
@@ -118,11 +118,10 @@ nvmf_virtual_ctrlr_poll_for_completions(struct spdk_nvmf_session *session)
}

static void
nvmf_virtual_ctrlr_complete_cmd(void *arg1, void *arg2)
nvmf_virtual_ctrlr_complete_cmd(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status,
				void *cb_arg)
{
	struct spdk_bdev_io		*bdev_io = arg2;
	struct spdk_nvmf_request 	*req = arg1;
	enum spdk_bdev_io_status	status = bdev_io->status;
	struct spdk_nvmf_request 	*req = cb_arg;
	struct spdk_nvme_cpl 		*response = &req->rsp->nvme_cpl;
	struct spdk_nvme_cmd 		*cmd = &req->cmd->nvme_cmd;

+3 −4
Original line number Diff line number Diff line
@@ -1222,11 +1222,10 @@ spdk_bdev_scsi_mode_select_page(struct spdk_bdev *bdev,
}

static void
spdk_bdev_scsi_task_complete(void *arg1, void *arg2)
spdk_bdev_scsi_task_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status,
			     void *cb_arg)
{
	struct spdk_bdev_io		*bdev_io = arg2;
	struct spdk_scsi_task		*task = arg1;
	enum spdk_bdev_io_status	status = bdev_io->status;
	struct spdk_scsi_task		*task = cb_arg;

	if (task->type == SPDK_SCSI_TASK_TYPE_CMD) {
		if (status == SPDK_BDEV_IO_STATUS_SUCCESS) {
+2 −4
Original line number Diff line number Diff line
@@ -163,11 +163,9 @@ initialize_buffer(char **buf, int pattern, int size)
}

static void
quick_test_complete(void *arg1, void *arg2)
quick_test_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status, void *arg)
{
	struct spdk_bdev_io *bdev_io = arg2;

	g_completion_status = bdev_io->status;
	g_completion_status = status;
	spdk_bdev_free_io(bdev_io);
	wake_ut_thread();
}
Loading