TaskManagement: Add a function to abort a scsi_task

This commit is contained in:
Ronnie Sahlberg
2011-02-19 18:04:55 +11:00
parent fb34c5615a
commit b81d21ce8c
4 changed files with 30 additions and 10 deletions

View File

@@ -413,6 +413,8 @@ struct iscsi_discovery_address {
int iscsi_nop_out_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
unsigned char *data, int len, void *private_data);
struct scsi_task;
enum iscsi_task_mgmt_funcs {
ISCSI_TM_ABORT_TASK = 0x01,
ISCSI_TM_ABORT_TASK_SET = 0x02,
@@ -423,6 +425,7 @@ enum iscsi_task_mgmt_funcs {
ISCSI_TM_TARGET_COLD_RESET = 0x07,
ISCSI_TM_TASK_REASSIGN = 0x08
};
/*
* Asynchronous call for task management
*
@@ -433,7 +436,8 @@ enum iscsi_task_mgmt_funcs {
*
* Callback parameters :
* status can be either of :
* ISCSI_STATUS_GOOD : Connection was successful. Command_data is NULL.
* ISCSI_STATUS_GOOD : Connection was successful. Command_data is a pointer to uint32_t
* containing the response code as per RFC3720/10.6.1
*
* ISCSI_STATUS_ERROR : Error.
*
@@ -446,6 +450,11 @@ iscsi_task_mgmt_async(struct iscsi_context *iscsi,
uint32_t ritt, uint32_t rcmdscn,
iscsi_command_cb cb, void *private_data);
int
iscsi_task_mgmt_abort_task_async(struct iscsi_context *iscsi,
struct scsi_task *task,
iscsi_command_cb cb, void *private_data);
@@ -496,7 +505,6 @@ iscsi_set_isid_reserved(struct iscsi_context *iscsi);
/*
* Async commands for SCSI
*/
struct scsi_task;
int iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
struct scsi_task *task, iscsi_command_cb cb,
struct iscsi_data *data, void *private_data);

View File

@@ -129,6 +129,7 @@ struct scsi_task {
uint32_t itt;
uint32_t cmdsn;
uint32_t lun;
};
void scsi_free_scsi_task(struct scsi_task *task);

View File

@@ -326,6 +326,7 @@ iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
/* remember cmdsn and itt so we can use task management */
task->cmdsn = pdu->cmdsn;
task->itt = pdu->itt;
task->lun = lun;
return 0;
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include "iscsi.h"
#include "iscsi-private.h"
#include "scsi-lowlevel.h"
int
iscsi_task_mgmt_async(struct iscsi_context *iscsi,
@@ -76,16 +77,25 @@ int
iscsi_process_task_mgmt_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
struct iscsi_in_pdu *in)
{
struct iscsi_data data;
uint32_t response;
data.data = NULL;
data.size = 0;
response = in->hdr[2];
if (in->data_pos > ISCSI_HEADER_SIZE) {
data.data = in->data;
data.size = in->data_pos;
}
pdu->callback(iscsi, SCSI_STATUS_GOOD, &data, pdu->private_data);
pdu->callback(iscsi, SCSI_STATUS_GOOD, &response, pdu->private_data);
return 0;
}
int
iscsi_task_mgmt_abort_task_async(struct iscsi_context *iscsi,
struct scsi_task *task,
iscsi_command_cb cb, void *private_data)
{
return iscsi_task_mgmt_async(iscsi,
task->lun, ISCSI_TM_ABORT_TASK,
task->itt, task->cmdsn,
cb, private_data);
}