scsi: Set TMF code prior to calling spdk_scsi_dev_queue_mgmt_task
By subsequent patches for iSCSI, spdk_scsi_dev_queue_mgmt_task() will not be called directly from the function that knows TMF code, and currently setting TMF code to SCSI task is done in spdk_scsi_dev_queue_mgmt_task(). Hence after subsequent patches for iSCSI, to hand off TMF code to SCSI task, any dynamic context will be required. To avoid the dynamic context, extract setting TMF code from spdk_scsi_dev_queue_mgmt_task() and put appropriate place for each call of spdk_scsi_dev_queue_mgmt_task(). Additionally, in spdk_abort_transfer_task_in_task_mgmt_resp(), ref_task_tag is got from PDU but getting it from SCSI task is much easier. Hence get ref_task_tag from SCSI task in the callback. Change-Id: I7add9290598d2df7cfcf1506ec75d74c70c0f236 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/436643 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
ba1811556b
commit
728972cdf3
@ -248,13 +248,13 @@ void spdk_scsi_dev_destruct(struct spdk_scsi_dev *dev);
|
||||
* Execute the SCSI management task.
|
||||
*
|
||||
* The task can be constructed by the function spdk_scsi_task_construct().
|
||||
* Code of task management function to be executed is set before calling this API.
|
||||
*
|
||||
* \param dev SCSI device.
|
||||
* \param task SCSI task to be executed.
|
||||
* \param func Task management function to be executed.
|
||||
*/
|
||||
void spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev, struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func);
|
||||
void spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev, struct spdk_scsi_task *task);
|
||||
|
||||
/**
|
||||
* Execute the SCSI task.
|
||||
*
|
||||
|
@ -2746,10 +2746,9 @@ static void spdk_iscsi_queue_task(struct spdk_iscsi_conn *conn,
|
||||
}
|
||||
|
||||
static void spdk_iscsi_queue_mgmt_task(struct spdk_iscsi_conn *conn,
|
||||
struct spdk_iscsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
struct spdk_iscsi_task *task)
|
||||
{
|
||||
spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi, func);
|
||||
spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi);
|
||||
}
|
||||
|
||||
int spdk_iscsi_conn_handle_queued_datain_tasks(struct spdk_iscsi_conn *conn)
|
||||
@ -2973,20 +2972,14 @@ static void
|
||||
spdk_abort_transfer_task_in_task_mgmt_resp(struct spdk_iscsi_conn *conn,
|
||||
struct spdk_iscsi_task *task)
|
||||
{
|
||||
struct iscsi_bhs_task_req *reqh;
|
||||
struct spdk_iscsi_pdu *pdu;
|
||||
uint32_t ref_task_tag;
|
||||
uint8_t function;
|
||||
|
||||
pdu = spdk_iscsi_task_get_pdu(task);
|
||||
reqh = (struct iscsi_bhs_task_req *)&pdu->bhs;
|
||||
function = reqh->flags & ISCSI_TASK_FUNCTION_MASK;
|
||||
ref_task_tag = from_be32(&reqh->ref_task_tag);
|
||||
|
||||
switch (function) {
|
||||
switch (task->scsi.function) {
|
||||
/* abort task identified by Reference Task Tag field */
|
||||
case ISCSI_TASK_FUNC_ABORT_TASK:
|
||||
spdk_del_transfer_task(conn, ref_task_tag);
|
||||
spdk_del_transfer_task(conn, task->scsi.abort_id);
|
||||
break;
|
||||
|
||||
/* abort all tasks issued via this session on the LUN */
|
||||
@ -3234,8 +3227,8 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
SPDK_NOTICELOG("ABORT_TASK\n");
|
||||
|
||||
task->scsi.abort_id = ref_task_tag;
|
||||
|
||||
spdk_iscsi_queue_mgmt_task(conn, task, SPDK_SCSI_TASK_FUNC_ABORT_TASK);
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_ABORT_TASK;
|
||||
spdk_iscsi_queue_mgmt_task(conn, task);
|
||||
|
||||
return SPDK_SUCCESS;
|
||||
|
||||
@ -3243,7 +3236,8 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
case ISCSI_TASK_FUNC_ABORT_TASK_SET:
|
||||
SPDK_NOTICELOG("ABORT_TASK_SET\n");
|
||||
|
||||
spdk_iscsi_queue_mgmt_task(conn, task, SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET);
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET;
|
||||
spdk_iscsi_queue_mgmt_task(conn, task);
|
||||
|
||||
return SPDK_SUCCESS;
|
||||
|
||||
@ -3260,7 +3254,8 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
case ISCSI_TASK_FUNC_LOGICAL_UNIT_RESET:
|
||||
SPDK_NOTICELOG("LOGICAL_UNIT_RESET\n");
|
||||
|
||||
spdk_iscsi_queue_mgmt_task(conn, task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
spdk_iscsi_queue_mgmt_task(conn, task);
|
||||
|
||||
return SPDK_SUCCESS;
|
||||
|
||||
|
@ -1280,8 +1280,9 @@ spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
||||
task->scsi.target_port = conn->target_port;
|
||||
task->scsi.initiator_port = conn->initiator_port;
|
||||
task->scsi.lun = lun;
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
|
||||
spdk_scsi_dev_queue_mgmt_task(target->dev, &task->scsi, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
spdk_scsi_dev_queue_mgmt_task(target->dev, &task->scsi);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -246,12 +246,10 @@ spdk_scsi_dev_construct(const char *name, const char *bdev_name_list[],
|
||||
|
||||
void
|
||||
spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev,
|
||||
struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
struct spdk_scsi_task *task)
|
||||
{
|
||||
assert(task != NULL);
|
||||
|
||||
task->function = func;
|
||||
spdk_scsi_lun_append_mgmt_task(task->lun, task);
|
||||
spdk_scsi_lun_execute_mgmt_task(task->lun);
|
||||
}
|
||||
|
@ -269,7 +269,8 @@ static void
|
||||
mgmt_task_submit(struct spdk_vhost_scsi_task *task, enum spdk_scsi_task_func func)
|
||||
{
|
||||
task->tmf_resp->response = VIRTIO_SCSI_S_OK;
|
||||
spdk_scsi_dev_queue_mgmt_task(task->scsi_dev, &task->scsi, func);
|
||||
task->scsi.function = func;
|
||||
spdk_scsi_dev_queue_mgmt_task(task->scsi_dev, &task->scsi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -90,8 +90,7 @@ spdk_scsi_dev_find_port_by_id(struct spdk_scsi_dev *dev, uint64_t id)
|
||||
|
||||
void
|
||||
spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev,
|
||||
struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
struct spdk_scsi_task *task)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,8 @@ dev_queue_mgmt_task_success(void)
|
||||
|
||||
task = spdk_get_task(NULL);
|
||||
|
||||
spdk_scsi_dev_queue_mgmt_task(dev, task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
task->function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
spdk_scsi_dev_queue_mgmt_task(dev, task);
|
||||
|
||||
spdk_scsi_task_put(task);
|
||||
|
||||
@ -356,7 +357,8 @@ dev_stop_success(void)
|
||||
task_mgmt = spdk_get_task(NULL);
|
||||
|
||||
/* Enqueue the tasks into dev->task_mgmt_submit_queue */
|
||||
spdk_scsi_dev_queue_mgmt_task(&dev, task_mgmt, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
task->function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
spdk_scsi_dev_queue_mgmt_task(&dev, task_mgmt);
|
||||
|
||||
spdk_scsi_task_put(task);
|
||||
spdk_scsi_task_put(task_mgmt);
|
||||
|
@ -168,8 +168,7 @@ spdk_bdev_get_name(const struct spdk_bdev *bdev)
|
||||
}
|
||||
|
||||
void spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev,
|
||||
struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
struct spdk_scsi_task *task)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user