Commit 19a98714 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

scsi: remove spdk_scsi_task::owner_task_ctr



The SCSI library already provides a callback when the task is released
(free_fn), so the user can update their own task counter.

Change-Id: I7fb13f6fff66dbba2315fd03fb06e49f793be123
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 7145cf62
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -141,16 +141,6 @@ struct spdk_scsi_task {

	TAILQ_ENTRY(spdk_scsi_task) scsi_link;

	/*
	 * Pointer to scsi task owner's outstanding
	 * task counter. Inc/Dec by get/put task functions.
	 * Note: in the future, we could consider replacing this
	 * with an owner-provided task management fuction that
	 * could perform protocol specific task mangement
	 * operations (such as tracking outstanding tasks).
	 */
	uint32_t *owner_task_ctr;

	uint32_t abort_id;
};

@@ -212,7 +202,7 @@ void spdk_scsi_port_free(struct spdk_scsi_port **pport);
const char *spdk_scsi_port_get_name(const struct spdk_scsi_port *port);


void spdk_scsi_task_construct(struct spdk_scsi_task *task, uint32_t *owner_task_ctr,
void spdk_scsi_task_construct(struct spdk_scsi_task *task,
			      void (*free_fn)(struct spdk_scsi_task *task),
			      struct spdk_scsi_task *parent);
void spdk_scsi_task_put(struct spdk_scsi_task *task);
+4 −4
Original line number Diff line number Diff line
@@ -2863,7 +2863,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->pending_task_cnt, task);
			subtask = spdk_iscsi_task_get(conn, task);
			assert(subtask != NULL);
			subtask->scsi.offset = task->current_datain_offset;
			subtask->scsi.length = DMIN32(SPDK_BDEV_LARGE_BUF_MAX_SIZE, remaining_size);
@@ -2934,7 +2934,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->pending_task_cnt, NULL);
	task = spdk_iscsi_task_get(conn, NULL);
	if (!task) {
		SPDK_ERRLOG("Unable to acquire task\n");
		return SPDK_ISCSI_CONNECTION_FATAL;
@@ -3250,7 +3250,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->pending_task_cnt, NULL);
	task = spdk_iscsi_task_get(conn, NULL);
	if (!task) {
		SPDK_ERRLOG("Unable to acquire task\n");
		return SPDK_ISCSI_CONNECTION_FATAL;
@@ -4091,7 +4091,7 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn,
		task->current_r2t_length = 0;
	}

	subtask = spdk_iscsi_task_get(&conn->pending_task_cnt, task);
	subtask = spdk_iscsi_task_get(conn, task);
	if (subtask == NULL) {
		SPDK_ERRLOG("Unable to acquire subtask\n");
		return SPDK_ISCSI_CONNECTION_FATAL;
+12 −4
Original line number Diff line number Diff line
@@ -36,17 +36,22 @@
#include <rte_mempool.h>

#include "spdk/log.h"
#include "iscsi/conn.h"
#include "iscsi/task.h"

static void
spdk_iscsi_task_free(struct spdk_scsi_task *task)
spdk_iscsi_task_free(struct spdk_scsi_task *scsi_task)
{
	spdk_iscsi_task_disassociate_pdu((struct spdk_iscsi_task *)task);
	struct spdk_iscsi_task *task = (struct spdk_iscsi_task *)scsi_task;

	spdk_iscsi_task_disassociate_pdu(task);
	rte_mempool_put(g_spdk_iscsi.task_pool, (void *)task);
	assert(task->conn->pending_task_cnt > 0);
	task->conn->pending_task_cnt--;
}

struct spdk_iscsi_task *
spdk_iscsi_task_get(uint32_t *owner_task_ctr, struct spdk_iscsi_task *parent)
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent)
{
	struct spdk_iscsi_task *task;
	int rc;
@@ -58,7 +63,10 @@ spdk_iscsi_task_get(uint32_t *owner_task_ctr, struct spdk_iscsi_task *parent)
	}

	memset(task, 0, sizeof(*task));
	spdk_scsi_task_construct((struct spdk_scsi_task *)task, owner_task_ctr,
	task->conn = conn;
	assert(conn->pending_task_cnt < UINT32_MAX);
	conn->pending_task_cnt++;
	spdk_scsi_task_construct((struct spdk_scsi_task *)task,
				 spdk_iscsi_task_free,
				 (struct spdk_scsi_task *)parent);
	if (parent) {
+2 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
struct spdk_iscsi_task {
	struct spdk_scsi_task	scsi;

	struct spdk_iscsi_conn *conn;
	struct spdk_iscsi_pdu *pdu;
	uint32_t outstanding_r2t;

@@ -153,7 +154,7 @@ spdk_iscsi_task_get_cmdsn(struct spdk_iscsi_task *task)
	return spdk_iscsi_task_get_pdu(task)->cmd_sn;
}

struct spdk_iscsi_task *spdk_iscsi_task_get(uint32_t *owner_task_ctr,
struct spdk_iscsi_task *spdk_iscsi_task_get(struct spdk_iscsi_conn *conn,
		struct spdk_iscsi_task *parent);

static inline struct spdk_iscsi_task *
+1 −1
Original line number Diff line number Diff line
@@ -1058,7 +1058,7 @@ spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
			continue;

		/* we create a fake management task per LUN to cleanup */
		task = spdk_iscsi_task_get(&conn->pending_task_cnt, NULL);
		task = spdk_iscsi_task_get(conn, NULL);
		if (!task) {
			SPDK_ERRLOG("Unable to acquire task\n");
			return -1;
Loading