Commit 41852055 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

scsi: Remove cb_event. It is no longer necessary.



This is an artifact from a past design. There is no longer
any reason to create an event here - the bdev layer will
correctly queue events and call completions on the correct
thread.

Change-Id: I145dab4046899834c0449ec7380dcbb28215b493
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/364831


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 293f9201
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -72,11 +72,6 @@ enum spdk_scsi_task_func {
	SPDK_SCSI_TASK_FUNC_LUN_RESET,
};

enum spdk_scsi_task_type {
	SPDK_SCSI_TASK_TYPE_CMD = 0,
	SPDK_SCSI_TASK_TYPE_MANAGE,
};

/*
 * SAM does not define the value for these service responses.  Each transport
 *  (i.e. SAS, FC, iSCSI) will map these value to transport-specific codes,
@@ -91,8 +86,11 @@ enum spdk_scsi_task_mgmt_resp {
	SPDK_SCSI_TASK_MGMT_RESP_REJECT_FUNC_NOT_SUPPORTED
};

struct spdk_scsi_task;
typedef void (*spdk_scsi_task_cpl)(struct spdk_scsi_task *task);
typedef void (*spdk_scsi_task_free)(struct spdk_scsi_task *task);

struct spdk_scsi_task {
	uint8_t				type;
	uint8_t				status;
	uint8_t				function; /* task mgmt function */
	uint8_t				response; /* task mgmt response */
@@ -100,7 +98,9 @@ struct spdk_scsi_task {
	struct spdk_io_channel		*ch;
	struct spdk_scsi_port		*target_port;
	struct spdk_scsi_port		*initiator_port;
	struct spdk_event 		*cb_event;

	spdk_scsi_task_cpl		cpl_fn;
	spdk_scsi_task_free		free_fn;

	uint32_t ref;
	uint32_t transfer_len;
@@ -116,8 +116,6 @@ struct spdk_scsi_task {
	uint64_t offset;
	struct spdk_scsi_task *parent;

	void (*free_fn)(struct spdk_scsi_task *);

	uint8_t *cdb;

	/**
@@ -208,7 +206,8 @@ const char *spdk_scsi_port_get_name(const struct spdk_scsi_port *port);


void spdk_scsi_task_construct(struct spdk_scsi_task *task,
			      void (*free_fn)(struct spdk_scsi_task *task),
			      spdk_scsi_task_cpl cpl_fn,
			      spdk_scsi_task_free free_fn,
			      struct spdk_scsi_task *parent);
void spdk_scsi_task_put(struct spdk_scsi_task *task);

+8 −8
Original line number Diff line number Diff line
@@ -847,13 +847,12 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
}

void
process_task_mgmt_completion(void *arg1, void *arg2)
spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
{
	struct spdk_iscsi_conn *conn = arg1;
	struct spdk_iscsi_task *task = arg2;
	struct spdk_iscsi_task *task = spdk_iscsi_task_from_scsi_task(scsi_task);

	conn->last_activity_tsc = spdk_get_ticks();
	spdk_iscsi_task_mgmt_response(conn, task);
	task->conn->last_activity_tsc = spdk_get_ticks();
	spdk_iscsi_task_mgmt_response(task->conn, task);
	spdk_iscsi_task_put(task);
}

@@ -909,11 +908,12 @@ process_read_task_completion(struct spdk_iscsi_conn *conn,
	process_completed_read_subtask_list(conn, primary);
}

void process_task_completion(void *arg1, void *arg2)
void
spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task)
{
	struct spdk_iscsi_conn *conn = arg1;
	struct spdk_iscsi_task *task = arg2;
	struct spdk_iscsi_task *primary;
	struct spdk_iscsi_task *task = spdk_iscsi_task_from_scsi_task(scsi_task);
	struct spdk_iscsi_conn *conn = task->conn;

	assert(task != NULL);
	spdk_trace_record(TRACE_ISCSI_TASK_DONE, conn->id, 0, (uintptr_t)task, 0);
+5 −9
Original line number Diff line number Diff line
@@ -2830,8 +2830,6 @@ spdk_iscsi_compare_pdu_bhs_within_existed_r2t_tasks(struct spdk_iscsi_conn *conn
static void spdk_iscsi_queue_task(struct spdk_iscsi_conn *conn,
				  struct spdk_iscsi_task *task)
{
	task->scsi.cb_event = spdk_event_allocate(spdk_env_get_current_core(), process_task_completion,
			      conn, task);
	spdk_trace_record(TRACE_ISCSI_TASK_QUEUE, conn->id, task->scsi.length,
			  (uintptr_t)task, (uintptr_t)task->pdu);
	spdk_scsi_dev_queue_task(conn->dev, &task->scsi);
@@ -2841,8 +2839,6 @@ static void spdk_iscsi_queue_mgmt_task(struct spdk_iscsi_conn *conn,
				       struct spdk_iscsi_task *task,
				       enum spdk_scsi_task_func func)
{
	task->scsi.cb_event = spdk_event_allocate(spdk_env_get_current_core(), process_task_mgmt_completion,
			      conn, task);
	spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi, func);
}

@@ -2866,7 +2862,7 @@ int spdk_iscsi_conn_handle_queued_tasks(struct spdk_iscsi_conn *conn)
			uint32_t remaining_size = 0;

			remaining_size = task->scsi.transfer_len - task->current_datain_offset;
			subtask = spdk_iscsi_task_get(conn, task);
			subtask = spdk_iscsi_task_get(conn, task, spdk_iscsi_task_cpl);
			assert(subtask != NULL);
			subtask->scsi.offset = task->current_datain_offset;
			subtask->scsi.length = DMIN32(SPDK_BDEV_LARGE_BUF_MAX_SIZE, remaining_size);
@@ -2937,7 +2933,7 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)

	SPDK_TRACEDUMP(SPDK_TRACE_DEBUG, "CDB", cdb, 16);

	task = spdk_iscsi_task_get(conn, NULL);
	task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_cpl);
	if (!task) {
		SPDK_ERRLOG("Unable to acquire task\n");
		return SPDK_ISCSI_CONNECTION_FATAL;
@@ -2963,7 +2959,7 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)

	if (task->scsi.lun == NULL) {
		spdk_scsi_task_process_null_lun(&task->scsi);
		process_task_completion(conn, task);
		spdk_iscsi_task_cpl(&task->scsi);
		return 0;
	}

@@ -3253,7 +3249,7 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
	lun_i = spdk_islun2lun(lun);
	dev = conn->dev;

	task = spdk_iscsi_task_get(conn, NULL);
	task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_mgmt_cpl);
	if (!task) {
		SPDK_ERRLOG("Unable to acquire task\n");
		return SPDK_ISCSI_CONNECTION_FATAL;
@@ -4089,7 +4085,7 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn,
		task->current_r2t_length = 0;
	}

	subtask = spdk_iscsi_task_get(conn, task);
	subtask = spdk_iscsi_task_get(conn, task, spdk_iscsi_task_cpl);
	if (subtask == NULL) {
		SPDK_ERRLOG("Unable to acquire subtask\n");
		return SPDK_ISCSI_CONNECTION_FATAL;
+2 −2
Original line number Diff line number Diff line
@@ -357,8 +357,8 @@ int spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
				int alloc_len, int data_len);
int spdk_iscsi_copy_param2var(struct spdk_iscsi_conn *conn);

void process_task_completion(void *arg1, void *arg2);
void process_task_mgmt_completion(void *arg1, void *arg2);
void spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task);
void spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task);

/* Memory management */
void spdk_put_pdu(struct spdk_iscsi_pdu *pdu);
+3 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ spdk_iscsi_task_free(struct spdk_scsi_task *scsi_task)
}

struct spdk_iscsi_task *
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent)
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent,
		    spdk_scsi_task_cpl cpl_fn)
{
	struct spdk_iscsi_task *task;
	int rc;
@@ -67,6 +68,7 @@ spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent
	assert(conn->pending_task_cnt < UINT32_MAX);
	conn->pending_task_cnt++;
	spdk_scsi_task_construct(&task->scsi,
				 cpl_fn,
				 spdk_iscsi_task_free,
				 parent ? &parent->scsi : NULL);
	if (parent) {
Loading