scsi: pass management function as a parameter
Specify the function as a parameter to spdk_scsi_dev_queue_mgmt_task. This makes the API clearer by making it explicit that the management function is required for management tasks. Change-Id: I92d893aadb6faebea81dd79729894d2c2fddf088 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
1e7e6a618b
commit
f66a0c9e34
@ -167,7 +167,8 @@ int spdk_scsi_dev_get_id(const struct spdk_scsi_dev *dev);
|
||||
int spdk_scsi_dev_get_max_lun(const struct spdk_scsi_dev *dev);
|
||||
struct spdk_scsi_lun *spdk_scsi_dev_get_lun(struct spdk_scsi_dev *dev, int lun_id);
|
||||
void spdk_scsi_dev_destruct(struct spdk_scsi_dev *dev);
|
||||
void spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev, struct spdk_scsi_task *task);
|
||||
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_task(struct spdk_scsi_dev *dev, struct spdk_scsi_task *task);
|
||||
int spdk_scsi_dev_add_port(struct spdk_scsi_dev *dev, uint64_t id, const char *name);
|
||||
struct spdk_scsi_port *spdk_scsi_dev_find_port_by_id(struct spdk_scsi_dev *dev, uint64_t id);
|
||||
|
@ -2836,11 +2836,12 @@ 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)
|
||||
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);
|
||||
spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi, func);
|
||||
}
|
||||
|
||||
int spdk_iscsi_conn_handle_queued_tasks(struct spdk_iscsi_conn *conn)
|
||||
@ -3267,10 +3268,9 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
case ISCSI_TASK_FUNC_ABORT_TASK:
|
||||
SPDK_NOTICELOG("ABORT_TASK\n");
|
||||
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_ABORT_TASK;
|
||||
task->scsi.abort_id = ref_task_tag;
|
||||
|
||||
spdk_iscsi_queue_mgmt_task(conn, task);
|
||||
spdk_iscsi_queue_mgmt_task(conn, task, SPDK_SCSI_TASK_FUNC_ABORT_TASK);
|
||||
spdk_del_transfer_task(conn, ref_task_tag);
|
||||
|
||||
return SPDK_SUCCESS;
|
||||
@ -3279,9 +3279,7 @@ 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");
|
||||
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET;
|
||||
|
||||
spdk_iscsi_queue_mgmt_task(conn, task);
|
||||
spdk_iscsi_queue_mgmt_task(conn, task, SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET);
|
||||
spdk_clear_all_transfer_task(conn, task->scsi.lun);
|
||||
|
||||
return SPDK_SUCCESS;
|
||||
@ -3298,9 +3296,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");
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
|
||||
spdk_iscsi_queue_mgmt_task(conn, task);
|
||||
spdk_iscsi_queue_mgmt_task(conn, task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
spdk_clear_all_transfer_task(conn, task->scsi.lun);
|
||||
return SPDK_SUCCESS;
|
||||
|
||||
|
@ -1067,11 +1067,10 @@ 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;
|
||||
|
||||
task->scsi.cb_event = spdk_event_allocate(spdk_env_get_current_core(),
|
||||
process_task_mgmt_completion, conn, task);
|
||||
spdk_scsi_dev_queue_mgmt_task(target->dev, &task->scsi);
|
||||
spdk_scsi_dev_queue_mgmt_task(target->dev, &task->scsi, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -201,12 +201,14 @@ error:
|
||||
|
||||
void
|
||||
spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev,
|
||||
struct spdk_scsi_task *task)
|
||||
struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
{
|
||||
assert(task != NULL);
|
||||
|
||||
task->type = SPDK_SCSI_TASK_TYPE_MANAGE;
|
||||
spdk_scsi_lun_task_mgmt_execute(task);
|
||||
task->function = func;
|
||||
spdk_scsi_lun_task_mgmt_execute(task, func);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -134,7 +134,8 @@ spdk_scsi_lun_reset(struct spdk_scsi_task *mtask, struct spdk_scsi_lun *lun)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task)
|
||||
spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@ -142,7 +143,7 @@ spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task)
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (task->function) {
|
||||
switch (func) {
|
||||
case SPDK_SCSI_TASK_FUNC_ABORT_TASK:
|
||||
rc = spdk_scsi_lun_abort_task(task, task->lun,
|
||||
task->initiator_port,
|
||||
|
@ -128,7 +128,7 @@ int spdk_scsi_lun_destruct(struct spdk_scsi_lun *lun);
|
||||
void spdk_scsi_lun_clear_all(struct spdk_scsi_lun *lun);
|
||||
int spdk_scsi_lun_append_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task);
|
||||
void spdk_scsi_lun_execute_tasks(struct spdk_scsi_lun *lun);
|
||||
int spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task);
|
||||
int spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task, enum spdk_scsi_task_func func);
|
||||
void spdk_scsi_lun_complete_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task);
|
||||
void spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task);
|
||||
int spdk_scsi_lun_claim(struct spdk_scsi_lun *lun);
|
||||
|
@ -374,13 +374,13 @@ task_submit(struct spdk_vhost_task *task)
|
||||
}
|
||||
|
||||
static void
|
||||
mgmt_task_submit(struct spdk_vhost_task *task)
|
||||
mgmt_task_submit(struct spdk_vhost_task *task, enum spdk_scsi_task_func func)
|
||||
{
|
||||
task->tmf_resp->response = VIRTIO_SCSI_S_OK;
|
||||
task->scsi.cb_event = spdk_event_allocate(rte_lcore_id(),
|
||||
process_mgmt_task_completion,
|
||||
task, NULL);
|
||||
spdk_scsi_dev_queue_mgmt_task(task->scsi_dev, &task->scsi);
|
||||
spdk_scsi_dev_queue_mgmt_task(task->scsi_dev, &task->scsi, func);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -475,10 +475,9 @@ process_ctrl_request(struct spdk_vhost_scsi_ctrlr *vdev, struct rte_vhost_vring
|
||||
case VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET:
|
||||
/* Handle LUN reset */
|
||||
SPDK_TRACELOG(SPDK_TRACE_VHOST_QUEUE, "LUN reset\n");
|
||||
task->scsi.function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
task->scsi.lun = get_scsi_lun(task->scsi_dev, ctrl_req->lun);
|
||||
|
||||
mgmt_task_submit(task);
|
||||
mgmt_task_submit(task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
return;
|
||||
default:
|
||||
task->tmf_resp->response = VIRTIO_SCSI_S_ABORTED;
|
||||
|
@ -81,7 +81,8 @@ 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)
|
||||
struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ spdk_scsi_lun_unclaim(struct spdk_scsi_lun *lun)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task)
|
||||
spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task, enum spdk_scsi_task_func func)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -343,7 +343,7 @@ dev_queue_mgmt_task_success(void)
|
||||
|
||||
task = spdk_get_task(NULL);
|
||||
|
||||
spdk_scsi_dev_queue_mgmt_task(dev, task);
|
||||
spdk_scsi_dev_queue_mgmt_task(dev, task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
|
||||
spdk_scsi_task_put(task);
|
||||
|
||||
@ -386,7 +386,7 @@ 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_dev_queue_mgmt_task(&dev, task_mgmt, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
|
||||
spdk_scsi_task_put(task);
|
||||
spdk_scsi_task_put(task_mgmt);
|
||||
|
@ -149,7 +149,8 @@ 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)
|
||||
struct spdk_scsi_task *task,
|
||||
enum spdk_scsi_task_func func)
|
||||
{
|
||||
}
|
||||
|
||||
@ -228,7 +229,7 @@ lun_task_mgmt_execute_null_task(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(NULL);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(NULL, SPDK_SCSI_TASK_FUNC_ABORT_TASK);
|
||||
|
||||
/* returns -1 since we passed NULL for the task */
|
||||
CU_ASSERT_TRUE(rc < 0);
|
||||
@ -243,11 +244,10 @@ lun_task_mgmt_execute_abort_task_null_lun_failure(void)
|
||||
int rc;
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
mgmt_task->function = SPDK_SCSI_TASK_FUNC_ABORT_TASK;
|
||||
mgmt_task->lun = NULL;
|
||||
mgmt_task->initiator_port = &initiator_port;
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, SPDK_SCSI_TASK_FUNC_ABORT_TASK);
|
||||
|
||||
spdk_scsi_task_put(mgmt_task);
|
||||
|
||||
@ -271,7 +271,6 @@ lun_task_mgmt_execute_abort_task_not_supported(void)
|
||||
lun->dev = &dev;
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
mgmt_task->function = SPDK_SCSI_TASK_FUNC_ABORT_TASK;
|
||||
mgmt_task->lun = lun;
|
||||
mgmt_task->initiator_port = &initiator_port;
|
||||
|
||||
@ -290,7 +289,7 @@ lun_task_mgmt_execute_abort_task_not_supported(void)
|
||||
/* task should now be on the tasks list */
|
||||
CU_ASSERT(!TAILQ_EMPTY(&lun->tasks));
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, SPDK_SCSI_TASK_FUNC_ABORT_TASK);
|
||||
|
||||
/* returns -1 since task abort is not supported */
|
||||
CU_ASSERT_TRUE(rc < 0);
|
||||
@ -312,11 +311,10 @@ lun_task_mgmt_execute_abort_task_all_null_lun_failure(void)
|
||||
int rc;
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
mgmt_task->function = SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET;
|
||||
mgmt_task->lun = NULL;
|
||||
mgmt_task->initiator_port = &initiator_port;
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET);
|
||||
|
||||
/* Returns -1 since we passed NULL for lun */
|
||||
CU_ASSERT_TRUE(rc < 0);
|
||||
@ -341,7 +339,6 @@ lun_task_mgmt_execute_abort_task_all_not_supported(void)
|
||||
lun->dev = &dev;
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
mgmt_task->function = SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET;
|
||||
mgmt_task->lun = lun;
|
||||
mgmt_task->initiator_port = &initiator_port;
|
||||
|
||||
@ -361,7 +358,7 @@ lun_task_mgmt_execute_abort_task_all_not_supported(void)
|
||||
/* task should now be on the tasks list */
|
||||
CU_ASSERT(!TAILQ_EMPTY(&lun->tasks));
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, SPDK_SCSI_TASK_FUNC_ABORT_TASK_SET);
|
||||
|
||||
/* returns -1 since task abort is not supported */
|
||||
CU_ASSERT_TRUE(rc < 0);
|
||||
@ -383,9 +380,8 @@ lun_task_mgmt_execute_lun_reset_failure(void)
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
mgmt_task->lun = NULL;
|
||||
mgmt_task->function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
|
||||
/* Returns -1 since we passed NULL for lun */
|
||||
CU_ASSERT_TRUE(rc < 0);
|
||||
@ -408,9 +404,8 @@ lun_task_mgmt_execute_lun_reset(void)
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
mgmt_task->lun = lun;
|
||||
mgmt_task->function = SPDK_SCSI_TASK_FUNC_LUN_RESET;
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||
|
||||
/* Returns success */
|
||||
CU_ASSERT_EQUAL(rc, 0);
|
||||
@ -435,9 +430,7 @@ lun_task_mgmt_execute_invalid_case(void)
|
||||
|
||||
mgmt_task = spdk_get_task(NULL);
|
||||
/* Pass an invalid value to the switch statement */
|
||||
mgmt_task->function = 5;
|
||||
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task);
|
||||
rc = spdk_scsi_lun_task_mgmt_execute(mgmt_task, 5);
|
||||
|
||||
/* Returns -1 on passing an invalid value to the switch case */
|
||||
CU_ASSERT_TRUE(rc < 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user