static void transport_complete_task_attr(struct se_cmd *cmd);
static void transport_direct_request_timeout(struct se_cmd *cmd);
static void transport_free_dev_tasks(struct se_cmd *cmd);
-static u32 transport_generic_get_cdb_count(struct se_cmd *cmd,
+static u32 transport_allocate_tasks(struct se_cmd *cmd,
unsigned long long starting_lba, u32 sectors,
enum dma_data_direction data_direction,
struct list_head *mem_list, int set_counts);
-static int transport_generic_get_mem(struct se_cmd *cmd, u32 length,
- u32 dma_size);
+static int transport_generic_get_mem(struct se_cmd *cmd, u32 length);
static int transport_generic_remove(struct se_cmd *cmd,
int release_to_pool, int session_reinstatement);
-static int transport_get_sectors(struct se_cmd *cmd);
+static int transport_cmd_get_valid_sectors(struct se_cmd *cmd);
static int transport_map_sg_to_mem(struct se_cmd *cmd,
- struct list_head *se_mem_list, struct scatterlist *sgl,
- u32 *se_mem_cnt);
-static void transport_memcpy_se_mem_read_contig(struct se_cmd *cmd,
- unsigned char *dst, struct list_head *se_mem_list);
+ struct list_head *se_mem_list, struct scatterlist *sgl);
+static void transport_memcpy_se_mem_read_contig(unsigned char *dst,
+ struct list_head *se_mem_list, u32 len);
static void transport_release_fe_cmd(struct se_cmd *cmd);
static void transport_remove_cmd_from_queue(struct se_cmd *cmd,
struct se_queue_obj *qobj);
EXPORT_SYMBOL(transport_deregister_session);
/*
- * Called with cmd->t_task.t_state_lock held.
+ * Called with cmd->t_state_lock held.
*/
static void transport_all_task_dev_remove_state(struct se_cmd *cmd)
{
struct se_task *task;
unsigned long flags;
- list_for_each_entry(task, &cmd->t_task.t_task_list, t_list) {
+ list_for_each_entry(task, &cmd->t_task_list, t_list) {
dev = task->se_dev;
if (!(dev))
continue;
spin_unlock_irqrestore(&dev->execute_task_lock, flags);
atomic_set(&task->task_state_active, 0);
- atomic_dec(&cmd->t_task.t_task_cdbs_ex_left);
+ atomic_dec(&cmd->t_task_cdbs_ex_left);
}
}
{
unsigned long flags;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
/*
* Determine if IOCTL context caller in requesting the stopping of this
* command for LUN shutdown purposes.
*/
- if (atomic_read(&cmd->t_task.transport_lun_stop)) {
- DEBUG_CS("%s:%d atomic_read(&cmd->t_task.transport_lun_stop)"
+ if (atomic_read(&cmd->transport_lun_stop)) {
+ DEBUG_CS("%s:%d atomic_read(&cmd->transport_lun_stop)"
" == TRUE for ITT: 0x%08x\n", __func__, __LINE__,
cmd->se_tfo->get_task_tag(cmd));
cmd->deferred_t_state = cmd->t_state;
cmd->t_state = TRANSPORT_DEFERRED_CMD;
- atomic_set(&cmd->t_task.t_transport_active, 0);
+ atomic_set(&cmd->t_transport_active, 0);
if (transport_off == 2)
transport_all_task_dev_remove_state(cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
- complete(&cmd->t_task.transport_lun_stop_comp);
+ complete(&cmd->transport_lun_stop_comp);
return 1;
}
/*
* Determine if frontend context caller is requesting the stopping of
* this command for frontend exceptions.
*/
- if (atomic_read(&cmd->t_task.t_transport_stop)) {
- DEBUG_CS("%s:%d atomic_read(&cmd->t_task.t_transport_stop) =="
+ if (atomic_read(&cmd->t_transport_stop)) {
+ DEBUG_CS("%s:%d atomic_read(&cmd->t_transport_stop) =="
" TRUE for ITT: 0x%08x\n", __func__, __LINE__,
cmd->se_tfo->get_task_tag(cmd));
*/
if (transport_off == 2)
cmd->se_lun = NULL;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
- complete(&cmd->t_task.t_transport_stop_comp);
+ complete(&cmd->t_transport_stop_comp);
return 1;
}
if (transport_off) {
- atomic_set(&cmd->t_task.t_transport_active, 0);
+ atomic_set(&cmd->t_transport_active, 0);
if (transport_off == 2) {
transport_all_task_dev_remove_state(cmd);
/*
*/
if (cmd->se_tfo->check_stop_free != NULL) {
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
cmd->se_tfo->check_stop_free(cmd);
return 1;
}
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return 0;
} else if (t_state)
cmd->t_state = t_state;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return 0;
}
if (!lun)
return;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (!(atomic_read(&cmd->t_task.transport_dev_active))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (!(atomic_read(&cmd->transport_dev_active))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
goto check_lun;
}
- atomic_set(&cmd->t_task.transport_dev_active, 0);
+ atomic_set(&cmd->transport_dev_active, 0);
transport_all_task_dev_remove_state(cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
check_lun:
spin_lock_irqsave(&lun->lun_cmd_lock, flags);
- if (atomic_read(&cmd->t_task.transport_lun_active)) {
+ if (atomic_read(&cmd->transport_lun_active)) {
list_del(&cmd->se_lun_node);
- atomic_set(&cmd->t_task.transport_lun_active, 0);
+ atomic_set(&cmd->transport_lun_active, 0);
#if 0
printk(KERN_INFO "Removed ITT: 0x%08x from LUN LIST[%d]\n"
cmd->se_tfo->get_task_tag(cmd), lun->unpacked_lun);
INIT_LIST_HEAD(&cmd->se_queue_node);
if (t_state) {
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
cmd->t_state = t_state;
- atomic_set(&cmd->t_task.t_transport_active, 1);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ atomic_set(&cmd->t_transport_active, 1);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
list_add_tail(&cmd->se_queue_node, &qobj->qobj_list);
- atomic_inc(&cmd->t_task.t_transport_queue_active);
+ atomic_inc(&cmd->t_transport_queue_active);
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
atomic_inc(&qobj->queue_cnt);
}
cmd = list_first_entry(&qobj->qobj_list, struct se_cmd, se_queue_node);
- atomic_dec(&cmd->t_task.t_transport_queue_active);
+ atomic_dec(&cmd->t_transport_queue_active);
list_del(&cmd->se_queue_node);
atomic_dec(&qobj->queue_cnt);
unsigned long flags;
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
- if (!(atomic_read(&cmd->t_task.t_transport_queue_active))) {
+ if (!(atomic_read(&cmd->t_transport_queue_active))) {
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
return;
}
list_for_each_entry(t, &qobj->qobj_list, se_queue_node)
if (t == cmd) {
- atomic_dec(&cmd->t_task.t_transport_queue_active);
+ atomic_dec(&cmd->t_transport_queue_active);
atomic_dec(&qobj->queue_cnt);
list_del(&cmd->se_queue_node);
break;
}
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
- if (atomic_read(&cmd->t_task.t_transport_queue_active)) {
+ if (atomic_read(&cmd->t_transport_queue_active)) {
printk(KERN_ERR "ITT: 0x%08x t_transport_queue_active: %d\n",
cmd->se_tfo->get_task_tag(cmd),
- atomic_read(&cmd->t_task.t_transport_queue_active));
+ atomic_read(&cmd->t_transport_queue_active));
}
}
*/
void transport_complete_sync_cache(struct se_cmd *cmd, int good)
{
- struct se_task *task = list_entry(cmd->t_task.t_task_list.next,
+ struct se_task *task = list_entry(cmd->t_task_list.next,
struct se_task, t_list);
if (good) {
unsigned long flags;
#if 0
printk(KERN_INFO "task: %p CDB: 0x%02x obj_ptr: %p\n", task,
- cmd->t_task.t_task_cdb[0], dev);
+ cmd->t_task_cdb[0], dev);
#endif
if (dev)
atomic_inc(&dev->depth_left);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
atomic_set(&task->task_active, 0);
/*
*/
if (atomic_read(&task->task_stop)) {
/*
- * Decrement cmd->t_task.t_se_count if this task had
+ * Decrement cmd->t_se_count if this task had
* previously thrown its timeout exception handler.
*/
if (atomic_read(&task->task_timeout)) {
- atomic_dec(&cmd->t_task.t_se_count);
+ atomic_dec(&cmd->t_se_count);
atomic_set(&task->task_timeout, 0);
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
complete(&task->task_stop_comp);
return;
*/
if (atomic_read(&task->task_timeout)) {
if (!(atomic_dec_and_test(
- &cmd->t_task.t_task_cdbs_timeout_left))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ &cmd->t_task_cdbs_timeout_left))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock,
flags);
return;
}
t_state = TRANSPORT_COMPLETE_TIMEOUT;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_add_cmd_to_queue(cmd, t_state);
return;
}
- atomic_dec(&cmd->t_task.t_task_cdbs_timeout_left);
+ atomic_dec(&cmd->t_task_cdbs_timeout_left);
/*
* Decrement the outstanding t_task_cdbs_left count. The last
* struct se_task from struct se_cmd will complete itself into the
* device queue depending upon int success.
*/
- if (!(atomic_dec_and_test(&cmd->t_task.t_task_cdbs_left))) {
+ if (!(atomic_dec_and_test(&cmd->t_task_cdbs_left))) {
if (!success)
- cmd->t_task.t_tasks_failed = 1;
+ cmd->t_tasks_failed = 1;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return;
}
- if (!success || cmd->t_task.t_tasks_failed) {
+ if (!success || cmd->t_tasks_failed) {
t_state = TRANSPORT_COMPLETE_FAILURE;
if (!task->task_error_status) {
task->task_error_status =
PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
}
} else {
- atomic_set(&cmd->t_task.t_transport_complete, 1);
+ atomic_set(&cmd->t_transport_complete, 1);
t_state = TRANSPORT_COMPLETE_OK;
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_add_cmd_to_queue(cmd, t_state);
}
struct se_task *task;
unsigned long flags;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- list_for_each_entry(task, &cmd->t_task.t_task_list, t_list) {
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ list_for_each_entry(task, &cmd->t_task_list, t_list) {
dev = task->se_dev;
if (atomic_read(&task->task_state_active))
spin_unlock(&dev->execute_task_lock);
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
static void transport_add_tasks_from_cmd(struct se_cmd *cmd)
unsigned long flags;
spin_lock_irqsave(&dev->execute_task_lock, flags);
- list_for_each_entry(task, &cmd->t_task.t_task_list, t_list) {
+ list_for_each_entry(task, &cmd->t_task_list, t_list) {
if (atomic_read(&task->task_execute_queue))
continue;
/*
INIT_LIST_HEAD(&task->t_execute_list);
INIT_LIST_HEAD(&task->t_state_list);
init_completion(&task->task_stop_comp);
- task->task_no = cmd->t_task.t_tasks_no++;
task->task_se_cmd = cmd;
task->se_dev = dev;
task->task_data_direction = data_direction;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- list_add_tail(&task->t_list, &cmd->t_task.t_task_list);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ list_add_tail(&task->t_list, &cmd->t_task_list);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return task;
}
INIT_LIST_HEAD(&cmd->se_delayed_node);
INIT_LIST_HEAD(&cmd->se_ordered_node);
- INIT_LIST_HEAD(&cmd->t_task.t_mem_list);
- INIT_LIST_HEAD(&cmd->t_task.t_mem_bidi_list);
- INIT_LIST_HEAD(&cmd->t_task.t_task_list);
- init_completion(&cmd->t_task.transport_lun_fe_stop_comp);
- init_completion(&cmd->t_task.transport_lun_stop_comp);
- init_completion(&cmd->t_task.t_transport_stop_comp);
- spin_lock_init(&cmd->t_task.t_state_lock);
- atomic_set(&cmd->t_task.transport_dev_active, 1);
+ INIT_LIST_HEAD(&cmd->t_mem_list);
+ INIT_LIST_HEAD(&cmd->t_mem_bidi_list);
+ INIT_LIST_HEAD(&cmd->t_task_list);
+ init_completion(&cmd->transport_lun_fe_stop_comp);
+ init_completion(&cmd->transport_lun_stop_comp);
+ init_completion(&cmd->t_transport_stop_comp);
+ spin_lock_init(&cmd->t_state_lock);
+ atomic_set(&cmd->transport_dev_active, 1);
cmd->se_tfo = tfo;
cmd->se_sess = se_sess;
/*
* Check and free any extended CDB buffer that was allocated
*/
- if (se_cmd->t_task.t_task_cdb != se_cmd->t_task.__t_task_cdb)
- kfree(se_cmd->t_task.t_task_cdb);
+ if (se_cmd->t_task_cdb != se_cmd->__t_task_cdb)
+ kfree(se_cmd->t_task_cdb);
}
EXPORT_SYMBOL(transport_free_se_cmd);
* allocate the additional extended CDB buffer now.. Otherwise
* setup the pointer from __t_task_cdb to t_task_cdb.
*/
- if (scsi_command_size(cdb) > sizeof(cmd->t_task.__t_task_cdb)) {
- cmd->t_task.t_task_cdb = kzalloc(scsi_command_size(cdb),
+ if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
+ cmd->t_task_cdb = kzalloc(scsi_command_size(cdb),
GFP_KERNEL);
- if (!(cmd->t_task.t_task_cdb)) {
- printk(KERN_ERR "Unable to allocate cmd->t_task.t_task_cdb"
- " %u > sizeof(cmd->t_task.__t_task_cdb): %lu ops\n",
+ if (!(cmd->t_task_cdb)) {
+ printk(KERN_ERR "Unable to allocate cmd->t_task_cdb"
+ " %u > sizeof(cmd->__t_task_cdb): %lu ops\n",
scsi_command_size(cdb),
- (unsigned long)sizeof(cmd->t_task.__t_task_cdb));
+ (unsigned long)sizeof(cmd->__t_task_cdb));
return -ENOMEM;
}
} else
- cmd->t_task.t_task_cdb = &cmd->t_task.__t_task_cdb[0];
+ cmd->t_task_cdb = &cmd->__t_task_cdb[0];
/*
- * Copy the original CDB into cmd->t_task.
+ * Copy the original CDB into cmd->
*/
- memcpy(cmd->t_task.t_task_cdb, cdb, scsi_command_size(cdb));
+ memcpy(cmd->t_task_cdb, cdb, scsi_command_size(cdb));
/*
* Setup the received CDB based on SCSI defined opcodes and
* perform unit attention, persistent reservations and ALUA
- * checks for virtual device backends. The cmd->t_task.t_task_cdb
+ * checks for virtual device backends. The cmd->t_task_cdb
* pointer is expected to be setup before we reach this point.
*/
ret = transport_generic_cmd_sequencer(cmd, cdb);
printk(KERN_ERR "cmd->se_lun is NULL\n");
return -EINVAL;
}
-
transport_add_cmd_to_queue(cmd, TRANSPORT_NEW_CMD);
return 0;
}
/*
* No tasks remain in the execution queue
*/
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
list_for_each_entry_safe(task, task_tmp,
- &cmd->t_task.t_task_list, t_list) {
+ &cmd->t_task_list, t_list) {
DEBUG_TS("task_no[%d] - Processing task %p\n",
task->task_no, task);
/*
*/
if (!atomic_read(&task->task_sent) &&
!atomic_read(&task->task_active)) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ spin_unlock_irqrestore(&cmd->t_state_lock,
flags);
transport_remove_task_from_execute_queue(task,
task->se_dev);
DEBUG_TS("task_no[%d] - Removed from execute queue\n",
task->task_no);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
continue;
}
*/
if (atomic_read(&task->task_active)) {
atomic_set(&task->task_stop, 1);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ spin_unlock_irqrestore(&cmd->t_state_lock,
flags);
DEBUG_TS("task_no[%d] - Waiting to complete\n",
DEBUG_TS("task_no[%d] - Stopped successfully\n",
task->task_no);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- atomic_dec(&cmd->t_task.t_task_cdbs_left);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ atomic_dec(&cmd->t_task_cdbs_left);
atomic_set(&task->task_active, 0);
atomic_set(&task->task_stop, 0);
__transport_stop_task_timer(task, &flags);
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return ret;
}
{
DEBUG_GRF("-----[ Storage Engine Exception for cmd: %p ITT: 0x%08x"
" CDB: 0x%02x\n", cmd, cmd->se_tfo->get_task_tag(cmd),
- cmd->t_task.t_task_cdb[0]);
+ cmd->t_task_cdb[0]);
DEBUG_GRF("-----[ i_state: %d t_state/def_t_state:"
" %d/%d transport_error_status: %d\n",
cmd->se_tfo->get_cmd_state(cmd),
DEBUG_GRF("-----[ t_task_cdbs: %d t_task_cdbs_left: %d"
" t_task_cdbs_sent: %d t_task_cdbs_ex_left: %d --"
" t_transport_active: %d t_transport_stop: %d"
- " t_transport_sent: %d\n", cmd->t_task.t_task_cdbs,
- atomic_read(&cmd->t_task.t_task_cdbs_left),
- atomic_read(&cmd->t_task.t_task_cdbs_sent),
- atomic_read(&cmd->t_task.t_task_cdbs_ex_left),
- atomic_read(&cmd->t_task.t_transport_active),
- atomic_read(&cmd->t_task.t_transport_stop),
- atomic_read(&cmd->t_task.t_transport_sent));
+ " t_transport_sent: %d\n", cmd->t_task_cdbs,
+ atomic_read(&cmd->t_task_cdbs_left),
+ atomic_read(&cmd->t_task_cdbs_sent),
+ atomic_read(&cmd->t_task_cdbs_ex_left),
+ atomic_read(&cmd->t_transport_active),
+ atomic_read(&cmd->t_transport_stop),
+ atomic_read(&cmd->t_transport_sent));
transport_stop_all_task_timers(cmd);
break;
default:
printk(KERN_ERR "Unknown transport error for CDB 0x%02x: %d\n",
- cmd->t_task.t_task_cdb[0],
+ cmd->t_task_cdb[0],
cmd->transport_error_status);
cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE;
break;
{
unsigned long flags;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (!(atomic_read(&cmd->t_task.t_transport_timeout))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (!(atomic_read(&cmd->t_transport_timeout))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return;
}
- if (atomic_read(&cmd->t_task.t_task_cdbs_timeout_left)) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ if (atomic_read(&cmd->t_task_cdbs_timeout_left)) {
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return;
}
- atomic_sub(atomic_read(&cmd->t_task.t_transport_timeout),
- &cmd->t_task.t_se_count);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ atomic_sub(atomic_read(&cmd->t_transport_timeout),
+ &cmd->t_se_count);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
static void transport_generic_request_timeout(struct se_cmd *cmd)
unsigned long flags;
/*
- * Reset cmd->t_task.t_se_count to allow transport_generic_remove()
+ * Reset cmd->t_se_count to allow transport_generic_remove()
* to allow last call to free memory resources.
*/
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (atomic_read(&cmd->t_task.t_transport_timeout) > 1) {
- int tmp = (atomic_read(&cmd->t_task.t_transport_timeout) - 1);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (atomic_read(&cmd->t_transport_timeout) > 1) {
+ int tmp = (atomic_read(&cmd->t_transport_timeout) - 1);
- atomic_sub(tmp, &cmd->t_task.t_se_count);
+ atomic_sub(tmp, &cmd->t_se_count);
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_generic_remove(cmd, 0, 0);
}
return -ENOMEM;
}
- cmd->t_task.t_tasks_se_num = 0;
- cmd->t_task.t_task_buf = buf;
+ cmd->t_tasks_se_num = 0;
+ cmd->t_task_buf = buf;
return 0;
}
{
unsigned long flags;
- spin_lock_irqsave(&se_cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&se_cmd->t_state_lock, flags);
se_cmd->se_cmd_flags |= SCF_SUPPORTED_SAM_OPCODE;
- spin_unlock_irqrestore(&se_cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
}
/*
DEBUG_TT("transport task timeout fired! task: %p cmd: %p\n", task, cmd);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
if (task->task_flags & TF_STOP) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return;
}
task->task_flags &= ~TF_RUNNING;
if (!(atomic_read(&task->task_active))) {
DEBUG_TT("transport task: %p cmd: %p timeout task_active"
" == 0\n", task, cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return;
}
- atomic_inc(&cmd->t_task.t_se_count);
- atomic_inc(&cmd->t_task.t_transport_timeout);
- cmd->t_task.t_tasks_failed = 1;
+ atomic_inc(&cmd->t_se_count);
+ atomic_inc(&cmd->t_transport_timeout);
+ cmd->t_tasks_failed = 1;
atomic_set(&task->task_timeout, 1);
task->task_error_status = PYX_TRANSPORT_TASK_TIMEOUT;
if (atomic_read(&task->task_stop)) {
DEBUG_TT("transport task: %p cmd: %p timeout task_stop"
" == 1\n", task, cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
complete(&task->task_stop_comp);
return;
}
- if (!(atomic_dec_and_test(&cmd->t_task.t_task_cdbs_left))) {
+ if (!(atomic_dec_and_test(&cmd->t_task_cdbs_left))) {
DEBUG_TT("transport task: %p cmd: %p timeout non zero"
" t_task_cdbs_left\n", task, cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return;
}
DEBUG_TT("transport task: %p cmd: %p timeout ZERO t_task_cdbs_left\n",
task, cmd);
cmd->t_state = TRANSPORT_COMPLETE_FAILURE;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_add_cmd_to_queue(cmd, TRANSPORT_COMPLETE_FAILURE);
}
/*
- * Called with cmd->t_task.t_state_lock held.
+ * Called with cmd->t_state_lock held.
*/
static void transport_start_task_timer(struct se_task *task)
{
}
/*
- * Called with spin_lock_irq(&cmd->t_task.t_state_lock) held.
+ * Called with spin_lock_irq(&cmd->t_state_lock) held.
*/
void __transport_stop_task_timer(struct se_task *task, unsigned long *flags)
{
return;
task->task_flags |= TF_STOP;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, *flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, *flags);
del_timer_sync(&task->task_timer);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, *flags);
+ spin_lock_irqsave(&cmd->t_state_lock, *flags);
task->task_flags &= ~TF_RUNNING;
task->task_flags &= ~TF_STOP;
}
struct se_task *task = NULL, *task_tmp;
unsigned long flags;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
list_for_each_entry_safe(task, task_tmp,
- &cmd->t_task.t_task_list, t_list)
+ &cmd->t_task_list, t_list)
__transport_stop_task_timer(task, &flags);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
static inline int transport_tcq_window_closed(struct se_device *dev)
smp_mb__after_atomic_inc();
DEBUG_STA("Added HEAD_OF_QUEUE for CDB:"
" 0x%02x, se_ordered_id: %u\n",
- cmd->t_task->t_task_cdb[0],
+ cmd->_task_cdb[0],
cmd->se_ordered_id);
return 1;
} else if (cmd->sam_task_attr == MSG_ORDERED_TAG) {
DEBUG_STA("Added ORDERED for CDB: 0x%02x to ordered"
" list, se_ordered_id: %u\n",
- cmd->t_task.t_task_cdb[0],
+ cmd->t_task_cdb[0],
cmd->se_ordered_id);
/*
* Add ORDERED command to tail of execution queue if
DEBUG_STA("Added CDB: 0x%02x Task Attr: 0x%02x to"
" delayed CMD list, se_ordered_id: %u\n",
- cmd->t_task.t_task_cdb[0], cmd->sam_task_attr,
+ cmd->t_task_cdb[0], cmd->sam_task_attr,
cmd->se_ordered_id);
/*
* Return zero to let transport_execute_tasks() know
/*
* Check if there is enough room in the device and HBA queue to send
- * struct se_transport_task's to the selected transport.
+ * struct se_tasks to the selected transport.
*/
check_depth:
if (!atomic_read(&dev->depth_left))
cmd = task->task_se_cmd;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
atomic_set(&task->task_active, 1);
atomic_set(&task->task_sent, 1);
- atomic_inc(&cmd->t_task.t_task_cdbs_sent);
+ atomic_inc(&cmd->t_task_cdbs_sent);
- if (atomic_read(&cmd->t_task.t_task_cdbs_sent) ==
- cmd->t_task.t_task_cdbs)
+ if (atomic_read(&cmd->t_task_cdbs_sent) ==
+ cmd->t_task_list_num)
atomic_set(&cmd->transport_sent, 1);
transport_start_task_timer(task);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
/*
* The struct se_cmd->transport_emulate_cdb() function pointer is used
* to grab REPORT_LUNS and other CDBs we want to handle before they hit the
* Any unsolicited data will get dumped for failed command inside of
* the fabric plugin
*/
- spin_lock_irqsave(&se_cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&se_cmd->t_state_lock, flags);
se_cmd->se_cmd_flags |= SCF_SE_CMD_FAILED;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
- spin_unlock_irqrestore(&se_cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
se_cmd->se_tfo->new_cmd_failure(se_cmd);
}
return;
}
/*
- * Copy the scatterlist WRITE buffer located at cmd->t_task.t_mem_list
+ * Copy the scatterlist WRITE buffer located at cmd->t_mem_list
* into the locally allocated *buf
*/
- transport_memcpy_se_mem_read_contig(cmd, buf, &cmd->t_task.t_mem_list);
+ transport_memcpy_se_mem_read_contig(buf, &cmd->t_mem_list,
+ cmd->data_length);
/*
* Now perform the XOR against the BIDI read memory located at
- * cmd->t_task.t_mem_bidi_list
+ * cmd->t_mem_bidi_list
*/
offset = 0;
- list_for_each_entry(se_mem, &cmd->t_task.t_mem_bidi_list, se_list) {
+ list_for_each_entry(se_mem, &cmd->t_mem_bidi_list, se_list) {
addr = (unsigned char *)kmap_atomic(se_mem->se_page, KM_USER0);
if (!(addr))
goto out;
WARN_ON(!cmd->se_lun);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return 0;
}
list_for_each_entry_safe(task, task_tmp,
- &cmd->t_task.t_task_list, t_list) {
+ &cmd->t_task_list, t_list) {
if (!task->task_sense)
continue;
cmd->se_tfo->get_task_tag(cmd), task->task_no);
continue;
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
offset = cmd->se_tfo->set_fabric_sense_len(cmd,
TRANSPORT_SENSE_BUFFER);
cmd->scsi_status);
return 0;
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return -1;
}
if ((cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) ||
(cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB))
- return transport_generic_get_mem(cmd, length, PAGE_SIZE);
+ return transport_generic_get_mem(cmd, length);
else if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB)
return transport_generic_allocate_buf(cmd, length);
else
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_6;
- cmd->t_task.t_task_lba = transport_lba_21(cdb);
+ cmd->t_task_lba = transport_lba_21(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case READ_10:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_10;
- cmd->t_task.t_task_lba = transport_lba_32(cdb);
+ cmd->t_task_lba = transport_lba_32(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case READ_12:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_12;
- cmd->t_task.t_task_lba = transport_lba_32(cdb);
+ cmd->t_task_lba = transport_lba_32(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case READ_16:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_16;
- cmd->t_task.t_task_lba = transport_lba_64(cdb);
+ cmd->t_task_lba = transport_lba_64(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case WRITE_6:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_6;
- cmd->t_task.t_task_lba = transport_lba_21(cdb);
+ cmd->t_task_lba = transport_lba_21(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case WRITE_10:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_10;
- cmd->t_task.t_task_lba = transport_lba_32(cdb);
- cmd->t_task.t_tasks_fua = (cdb[1] & 0x8);
+ cmd->t_task_lba = transport_lba_32(cdb);
+ cmd->t_tasks_fua = (cdb[1] & 0x8);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case WRITE_12:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_12;
- cmd->t_task.t_task_lba = transport_lba_32(cdb);
- cmd->t_task.t_tasks_fua = (cdb[1] & 0x8);
+ cmd->t_task_lba = transport_lba_32(cdb);
+ cmd->t_tasks_fua = (cdb[1] & 0x8);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case WRITE_16:
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_16;
- cmd->t_task.t_task_lba = transport_lba_64(cdb);
- cmd->t_task.t_tasks_fua = (cdb[1] & 0x8);
+ cmd->t_task_lba = transport_lba_64(cdb);
+ cmd->t_tasks_fua = (cdb[1] & 0x8);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
break;
case XDWRITEREAD_10:
if ((cmd->data_direction != DMA_TO_DEVICE) ||
- !(cmd->t_task.t_tasks_bidi))
+ !(cmd->t_tasks_bidi))
goto out_invalid_cdb_field;
sectors = transport_get_sectors_10(cdb, cmd, §or_ret);
if (sector_ret)
goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd);
cmd->transport_split_cdb = &split_cdb_XX_10;
- cmd->t_task.t_task_lba = transport_lba_32(cdb);
+ cmd->t_task_lba = transport_lba_32(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
passthrough = (dev->transport->transport_type ==
TRANSPORT_PLUGIN_PHBA_PDEV);
* Setup BIDI XOR callback to be run during transport_generic_complete_ok()
*/
cmd->transport_complete_callback = &transport_xor_callback;
- cmd->t_task.t_tasks_fua = (cdb[1] & 0x8);
+ cmd->t_tasks_fua = (cdb[1] & 0x8);
break;
case VARIABLE_LENGTH_CMD:
service_action = get_unaligned_be16(&cdb[8]);
* XDWRITE_READ_32 logic.
*/
cmd->transport_split_cdb = &split_cdb_XX_32;
- cmd->t_task.t_task_lba = transport_lba_64_ext(cdb);
+ cmd->t_task_lba = transport_lba_64_ext(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
/*
* transport_generic_complete_ok()
*/
cmd->transport_complete_callback = &transport_xor_callback;
- cmd->t_task.t_tasks_fua = (cdb[10] & 0x8);
+ cmd->t_tasks_fua = (cdb[10] & 0x8);
break;
case WRITE_SAME_32:
sectors = transport_get_sectors_32(cdb, cmd, §or_ret);
else
size = dev->se_sub_dev->se_dev_attrib.block_size;
- cmd->t_task.t_task_lba = get_unaligned_be64(&cdb[12]);
+ cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
/*
*/
if (cdb[0] == SYNCHRONIZE_CACHE) {
sectors = transport_get_sectors_10(cdb, cmd, §or_ret);
- cmd->t_task.t_task_lba = transport_lba_32(cdb);
+ cmd->t_task_lba = transport_lba_32(cdb);
} else {
sectors = transport_get_sectors_16(cdb, cmd, §or_ret);
- cmd->t_task.t_task_lba = transport_lba_64(cdb);
+ cmd->t_task_lba = transport_lba_64(cdb);
}
if (sector_ret)
goto out_unsupported_cdb;
* Check to ensure that LBA + Range does not exceed past end of
* device.
*/
- if (transport_get_sectors(cmd) < 0)
+ if (!transport_cmd_get_valid_sectors(cmd))
goto out_invalid_cdb_field;
break;
case UNMAP:
else
size = dev->se_sub_dev->se_dev_attrib.block_size;
- cmd->t_task.t_task_lba = get_unaligned_be64(&cdb[2]);
+ cmd->t_task_lba = get_unaligned_be16(&cdb[2]);
passthrough = (dev->transport->transport_type ==
TRANSPORT_PLUGIN_PHBA_PDEV);
/*
static inline void transport_release_tasks(struct se_cmd *);
-/*
- * This function will copy a contiguous *src buffer into a destination
- * struct scatterlist array.
- */
-static void transport_memcpy_write_contig(
- struct se_cmd *cmd,
- struct scatterlist *sg_d,
- unsigned char *src)
-{
- u32 i = 0, length = 0, total_length = cmd->data_length;
- void *dst;
-
- while (total_length) {
- length = sg_d[i].length;
-
- if (length > total_length)
- length = total_length;
-
- dst = sg_virt(&sg_d[i]);
-
- memcpy(dst, src, length);
-
- if (!(total_length -= length))
- return;
-
- src += length;
- i++;
- }
-}
-
-/*
- * This function will copy a struct scatterlist array *sg_s into a destination
- * contiguous *dst buffer.
- */
-static void transport_memcpy_read_contig(
- struct se_cmd *cmd,
- unsigned char *dst,
- struct scatterlist *sg_s)
-{
- u32 i = 0, length = 0, total_length = cmd->data_length;
- void *src;
-
- while (total_length) {
- length = sg_s[i].length;
-
- if (length > total_length)
- length = total_length;
-
- src = sg_virt(&sg_s[i]);
-
- memcpy(dst, src, length);
-
- if (!(total_length -= length))
- return;
-
- dst += length;
- i++;
- }
-}
-
static void transport_memcpy_se_mem_read_contig(
- struct se_cmd *cmd,
unsigned char *dst,
- struct list_head *se_mem_list)
+ struct list_head *se_mem_list,
+ u32 tot_len)
{
struct se_mem *se_mem;
void *src;
- u32 length = 0, total_length = cmd->data_length;
+ u32 length;
list_for_each_entry(se_mem, se_mem_list, se_list) {
- length = se_mem->se_len;
-
- if (length > total_length)
- length = total_length;
-
+ length = min_t(u32, se_mem->se_len, tot_len);
src = page_address(se_mem->se_page) + se_mem->se_off;
-
memcpy(dst, src, length);
-
- if (!(total_length -= length))
- return;
-
+ tot_len -= length;
+ if (!tot_len)
+ break;
dst += length;
}
}
}
spin_unlock(&cmd->se_lun->lun_sep_lock);
/*
- * If enabled by TCM fabirc module pre-registered SGL
+ * If enabled by TCM fabric module pre-registered SGL
* memory, perform the memcpy() from the TCM internal
- * contigious buffer back to the original SGL.
+ * contiguous buffer back to the original SGL.
*/
if (cmd->se_cmd_flags & SCF_PASSTHROUGH_CONTIG_TO_SG)
- transport_memcpy_write_contig(cmd,
- cmd->t_task.t_task_pt_sgl,
- cmd->t_task.t_task_buf);
+ sg_copy_from_buffer(cmd->t_task_pt_sgl,
+ cmd->t_task_pt_sgl_num,
+ cmd->t_task_buf,
+ cmd->data_length);
cmd->se_tfo->queue_data_in(cmd);
break;
/*
* Check if we need to send READ payload for BIDI-COMMAND
*/
- if (!list_empty(&cmd->t_task.t_mem_bidi_list)) {
+ if (!list_empty(&cmd->t_mem_bidi_list)) {
spin_lock(&cmd->se_lun->lun_sep_lock);
if (cmd->se_lun->lun_sep) {
cmd->se_lun->lun_sep->sep_stats.tx_data_octets +=
struct se_task *task, *task_tmp;
unsigned long flags;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
list_for_each_entry_safe(task, task_tmp,
- &cmd->t_task.t_task_list, t_list) {
+ &cmd->t_task_list, t_list) {
if (atomic_read(&task->task_active))
continue;
list_del(&task->t_list);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
if (task->se_dev)
task->se_dev->transport->free_task(task);
else
printk(KERN_ERR "task[%u] - task->se_dev is NULL\n",
task->task_no);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
static inline void transport_free_pages(struct se_cmd *cmd)
if (cmd->se_dev->transport->do_se_mem_map)
free_page = 0;
- if (cmd->t_task.t_task_buf) {
- kfree(cmd->t_task.t_task_buf);
- cmd->t_task.t_task_buf = NULL;
+ if (cmd->t_task_buf) {
+ kfree(cmd->t_task_buf);
+ cmd->t_task_buf = NULL;
return;
}
return;
list_for_each_entry_safe(se_mem, se_mem_tmp,
- &cmd->t_task.t_mem_list, se_list) {
+ &cmd->t_mem_list, se_list) {
/*
* We only release call __free_page(struct se_mem->se_page) when
* SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is NOT in use,
list_del(&se_mem->se_list);
kmem_cache_free(se_mem_cache, se_mem);
}
- cmd->t_task.t_tasks_se_num = 0;
+ cmd->t_tasks_se_num = 0;
list_for_each_entry_safe(se_mem, se_mem_tmp,
- &cmd->t_task.t_mem_bidi_list, se_list) {
+ &cmd->t_mem_bidi_list, se_list) {
/*
* We only release call __free_page(struct se_mem->se_page) when
* SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is NOT in use,
list_del(&se_mem->se_list);
kmem_cache_free(se_mem_cache, se_mem);
}
- cmd->t_task.t_tasks_se_bidi_num = 0;
+ cmd->t_tasks_se_bidi_num = 0;
}
static inline void transport_release_tasks(struct se_cmd *cmd)
{
unsigned long flags;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (atomic_read(&cmd->t_task.t_fe_count)) {
- if (!(atomic_dec_and_test(&cmd->t_task.t_fe_count))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (atomic_read(&cmd->t_fe_count)) {
+ if (!(atomic_dec_and_test(&cmd->t_fe_count))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock,
flags);
return 1;
}
}
- if (atomic_read(&cmd->t_task.t_se_count)) {
- if (!(atomic_dec_and_test(&cmd->t_task.t_se_count))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ if (atomic_read(&cmd->t_se_count)) {
+ if (!(atomic_dec_and_test(&cmd->t_se_count))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock,
flags);
return 1;
}
}
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return 0;
}
if (transport_dec_and_check(cmd))
return;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (!(atomic_read(&cmd->t_task.transport_dev_active))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (!(atomic_read(&cmd->transport_dev_active))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
goto free_pages;
}
- atomic_set(&cmd->t_task.transport_dev_active, 0);
+ atomic_set(&cmd->transport_dev_active, 0);
transport_all_task_dev_remove_state(cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_release_tasks(cmd);
free_pages:
if (transport_dec_and_check(cmd)) {
if (session_reinstatement) {
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
transport_all_task_dev_remove_state(cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ spin_unlock_irqrestore(&cmd->t_state_lock,
flags);
}
return 1;
}
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (!(atomic_read(&cmd->t_task.transport_dev_active))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (!(atomic_read(&cmd->transport_dev_active))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
goto free_pages;
}
- atomic_set(&cmd->t_task.transport_dev_active, 0);
+ atomic_set(&cmd->transport_dev_active, 0);
transport_all_task_dev_remove_state(cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_release_tasks(cmd);
struct scatterlist *sgl_bidi,
u32 sgl_bidi_count)
{
- u32 mapped_sg_count = 0;
int ret;
if (!sgl || !sgl_count)
* processed into a TCM struct se_subsystem_dev, we do the mapping
* from the passed physical memory to struct se_mem->se_page here.
*/
- ret = transport_map_sg_to_mem(cmd,
- &cmd->t_task.t_mem_list, sgl, &mapped_sg_count);
+ ret = transport_map_sg_to_mem(cmd, &cmd->t_mem_list, sgl);
if (ret < 0)
return -ENOMEM;
- cmd->t_task.t_tasks_se_num = mapped_sg_count;
+ cmd->t_tasks_se_num = ret;
/*
* Setup BIDI READ list of struct se_mem elements
*/
if (sgl_bidi && sgl_bidi_count) {
- mapped_sg_count = 0;
- ret = transport_map_sg_to_mem(cmd,
- &cmd->t_task.t_mem_bidi_list, sgl_bidi,
- &mapped_sg_count);
+ ret = transport_map_sg_to_mem(cmd, &cmd->t_mem_bidi_list, sgl_bidi);
if (ret < 0)
return -ENOMEM;
- cmd->t_task.t_tasks_se_bidi_num = mapped_sg_count;
+ cmd->t_tasks_se_bidi_num = ret;
}
cmd->se_cmd_flags |= SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC;
return -ENOSYS;
}
/*
- * For incoming CDBs using a contiguous buffer internall with TCM,
+ * For incoming CDBs using a contiguous buffer internal with TCM,
* save the passed struct scatterlist memory. After TCM storage object
* processing has completed for this struct se_cmd, TCM core will call
* transport_memcpy_[write,read]_contig() as necessary from
* struct scatterlist format.
*/
cmd->se_cmd_flags |= SCF_PASSTHROUGH_CONTIG_TO_SG;
- cmd->t_task.t_task_pt_sgl = sgl;
- /* don't need sgl count? We assume it contains cmd->data_length data */
+ cmd->t_task_pt_sgl = sgl;
+ cmd->t_task_pt_sgl_num = sgl_count;
}
return 0;
return dev->transport->get_blocks(dev) + 1;
}
-static int transport_get_sectors(struct se_cmd *cmd)
+static int transport_cmd_get_valid_sectors(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;
-
- cmd->t_task.t_tasks_sectors =
- (cmd->data_length / dev->se_sub_dev->se_dev_attrib.block_size);
- if (!(cmd->t_task.t_tasks_sectors))
- cmd->t_task.t_tasks_sectors = 1;
+ u32 sectors;
if (dev->transport->get_device_type(dev) != TYPE_DISK)
return 0;
- if ((cmd->t_task.t_task_lba + cmd->t_task.t_tasks_sectors) >
+ sectors = (cmd->data_length / dev->se_sub_dev->se_dev_attrib.block_size);
+
+ if ((cmd->t_task_lba + sectors) >
transport_dev_end_lba(dev)) {
printk(KERN_ERR "LBA: %llu Sectors: %u exceeds"
" transport_dev_end_lba(): %llu\n",
- cmd->t_task.t_task_lba, cmd->t_task.t_tasks_sectors,
+ cmd->t_task_lba, sectors,
transport_dev_end_lba(dev));
- cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
- cmd->scsi_sense_reason = TCM_SECTOR_COUNT_TOO_MANY;
- return PYX_TRANSPORT_REQ_TOO_MANY_SECTORS;
+ return 0;
}
- return 0;
+ return sectors;
}
static int transport_new_cmd_obj(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;
- u32 task_cdbs = 0, rc;
+ u32 task_cdbs;
+ u32 rc;
if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) {
- task_cdbs++;
- cmd->t_task.t_task_cdbs++;
+ task_cdbs = 1;
+ cmd->t_task_list_num = 1;
} else {
int set_counts = 1;
/*
* Setup any BIDI READ tasks and memory from
- * cmd->t_task.t_mem_bidi_list so the READ struct se_tasks
+ * cmd->t_mem_bidi_list so the READ struct se_tasks
* are queued first for the non pSCSI passthrough case.
*/
- if (!list_empty(&cmd->t_task.t_mem_bidi_list) &&
+ if (!list_empty(&cmd->t_mem_bidi_list) &&
(dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV)) {
- rc = transport_generic_get_cdb_count(cmd,
- cmd->t_task.t_task_lba,
- cmd->t_task.t_tasks_sectors,
- DMA_FROM_DEVICE, &cmd->t_task.t_mem_bidi_list,
+ rc = transport_allocate_tasks(cmd,
+ cmd->t_task_lba,
+ transport_cmd_get_valid_sectors(cmd),
+ DMA_FROM_DEVICE, &cmd->t_mem_bidi_list,
set_counts);
if (!(rc)) {
cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
set_counts = 0;
}
/*
- * Setup the tasks and memory from cmd->t_task.t_mem_list
+ * Setup the tasks and memory from cmd->t_mem_list
* Note for BIDI transfers this will contain the WRITE payload
*/
- task_cdbs = transport_generic_get_cdb_count(cmd,
- cmd->t_task.t_task_lba,
- cmd->t_task.t_tasks_sectors,
- cmd->data_direction, &cmd->t_task.t_mem_list,
+ task_cdbs = transport_allocate_tasks(cmd,
+ cmd->t_task_lba,
+ transport_cmd_get_valid_sectors(cmd),
+ cmd->data_direction, &cmd->t_mem_list,
set_counts);
if (!(task_cdbs)) {
cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
return PYX_TRANSPORT_LU_COMM_FAILURE;
}
- cmd->t_task.t_task_cdbs += task_cdbs;
+ cmd->t_task_list_num = task_cdbs;
#if 0
printk(KERN_INFO "data_length: %u, LBA: %llu t_tasks_sectors:"
" %u, t_task_cdbs: %u\n", obj_ptr, cmd->data_length,
- cmd->t_task.t_task_lba, cmd->t_task.t_tasks_sectors,
- cmd->t_task.t_task_cdbs);
+ cmd->t_task_lba, cmd->t_tasks_sectors,
+ cmd->t_task_cdbs);
#endif
}
- atomic_set(&cmd->t_task.t_task_cdbs_left, task_cdbs);
- atomic_set(&cmd->t_task.t_task_cdbs_ex_left, task_cdbs);
- atomic_set(&cmd->t_task.t_task_cdbs_timeout_left, task_cdbs);
+ atomic_set(&cmd->t_task_cdbs_left, task_cdbs);
+ atomic_set(&cmd->t_task_cdbs_ex_left, task_cdbs);
+ atomic_set(&cmd->t_task_cdbs_timeout_left, task_cdbs);
return 0;
}
static int
-transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size)
+transport_generic_get_mem(struct se_cmd *cmd, u32 length)
{
- unsigned char *buf;
struct se_mem *se_mem;
/*
}
/* #warning FIXME Allocate contigous pages for struct se_mem elements */
- se_mem->se_page = alloc_pages(GFP_KERNEL, 0);
+ se_mem->se_page = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
if (!(se_mem->se_page)) {
printk(KERN_ERR "alloc_pages() failed\n");
goto out;
}
- buf = kmap_atomic(se_mem->se_page, KM_IRQ0);
- if (!(buf)) {
- printk(KERN_ERR "kmap_atomic() failed\n");
- goto out;
- }
INIT_LIST_HEAD(&se_mem->se_list);
- se_mem->se_len = (length > dma_size) ? dma_size : length;
- memset(buf, 0, se_mem->se_len);
- kunmap_atomic(buf, KM_IRQ0);
-
- list_add_tail(&se_mem->se_list, &cmd->t_task.t_mem_list);
- cmd->t_task.t_tasks_se_num++;
+ se_mem->se_len = min_t(u32, length, PAGE_SIZE);
+ list_add_tail(&se_mem->se_list, &cmd->t_mem_list);
+ cmd->t_tasks_se_num++;
DEBUG_MEM("Allocated struct se_mem page(%p) Length(%u)"
" Offset(%u)\n", se_mem->se_page, se_mem->se_len,
}
DEBUG_MEM("Allocated total struct se_mem elements(%u)\n",
- cmd->t_task.t_tasks_se_num);
+ cmd->t_tasks_se_num);
return 0;
out:
sg_length = se_mem->se_len;
if (!(list_is_last(&se_mem->se_list,
- &se_cmd->t_task.t_mem_list)))
+ &se_cmd->t_mem_list)))
se_mem = list_entry(se_mem->se_list.next,
struct se_mem, se_list);
} else {
sg_length = (se_mem->se_len - task_offset);
if (!(list_is_last(&se_mem->se_list,
- &se_cmd->t_task.t_mem_list)))
+ &se_cmd->t_mem_list)))
se_mem = list_entry(se_mem->se_list.next,
struct se_mem, se_list);
}
* Setup task->task_sg_bidi for SCSI READ payload for
* TCM/pSCSI passthrough if present for BIDI-COMMAND
*/
- if (!list_empty(&se_cmd->t_task.t_mem_bidi_list) &&
+ if (!list_empty(&se_cmd->t_mem_bidi_list) &&
(se_dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)) {
task->task_sg_bidi = kzalloc(task_sg_num_padded *
sizeof(struct scatterlist), GFP_KERNEL);
return task->task_sg_num;
}
-static inline int transport_set_tasks_sectors_disk(
- struct se_task *task,
+/* Reduce sectors if they are too long for the device */
+static inline sector_t transport_limit_task_sectors(
struct se_device *dev,
unsigned long long lba,
- u32 sectors,
- int *max_sectors_set)
+ sector_t sectors)
{
- if ((lba + sectors) > transport_dev_end_lba(dev)) {
- task->task_sectors = ((transport_dev_end_lba(dev) - lba) + 1);
+ sectors = min_t(sector_t, sectors, dev->se_sub_dev->se_dev_attrib.max_sectors);
- if (task->task_sectors > dev->se_sub_dev->se_dev_attrib.max_sectors) {
- task->task_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;
- *max_sectors_set = 1;
- }
- } else {
- if (sectors > dev->se_sub_dev->se_dev_attrib.max_sectors) {
- task->task_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;
- *max_sectors_set = 1;
- } else
- task->task_sectors = sectors;
- }
+ if (dev->transport->get_device_type(dev) == TYPE_DISK)
+ if ((lba + sectors) > transport_dev_end_lba(dev))
+ sectors = ((transport_dev_end_lba(dev) - lba) + 1);
- return 0;
-}
-
-static inline int transport_set_tasks_sectors_non_disk(
- struct se_task *task,
- struct se_device *dev,
- unsigned long long lba,
- u32 sectors,
- int *max_sectors_set)
-{
- if (sectors > dev->se_sub_dev->se_dev_attrib.max_sectors) {
- task->task_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;
- *max_sectors_set = 1;
- } else
- task->task_sectors = sectors;
-
- return 0;
-}
-
-static inline int transport_set_tasks_sectors(
- struct se_task *task,
- struct se_device *dev,
- unsigned long long lba,
- u32 sectors,
- int *max_sectors_set)
-{
- return (dev->transport->get_device_type(dev) == TYPE_DISK) ?
- transport_set_tasks_sectors_disk(task, dev, lba, sectors,
- max_sectors_set) :
- transport_set_tasks_sectors_non_disk(task, dev, lba, sectors,
- max_sectors_set);
+ return sectors;
}
/*
static int transport_map_sg_to_mem(
struct se_cmd *cmd,
struct list_head *se_mem_list,
- struct scatterlist *sg,
- u32 *sg_count)
+ struct scatterlist *sg)
{
struct se_mem *se_mem;
u32 cmd_size = cmd->data_length;
+ int sg_count = 0;
WARN_ON(!sg);
se_mem->se_len = cmd_size;
cmd_size -= se_mem->se_len;
- (*sg_count)++;
+ sg_count++;
DEBUG_MEM("sg_to_mem: sg_count: %u cmd_size: %u\n",
sg_count, cmd_size);
DEBUG_MEM("task[0] - Mapped(%u) struct scatterlist segments\n", sg_count);
- return 0;
+ return sg_count;
}
/* transport_map_mem_to_sg():
int transport_map_mem_to_sg(
struct se_task *task,
struct list_head *se_mem_list,
- void *in_mem,
+ struct scatterlist *sg,
struct se_mem *in_se_mem,
struct se_mem **out_se_mem,
u32 *se_mem_cnt,
{
struct se_cmd *se_cmd = task->task_se_cmd;
struct se_mem *se_mem = in_se_mem;
- struct scatterlist *sg = (struct scatterlist *)in_mem;
u32 task_size = task->task_size, sg_no = 0;
if (!sg) {
while (task_size != 0) {
/*
- * Setup the contigious array of scatterlists for
+ * Setup the contiguous array of scatterlists for
* this struct se_task.
*/
sg_assign_page(sg, se_mem->se_page);
sg->length = se_mem->se_len;
if (!(list_is_last(&se_mem->se_list,
- &se_cmd->t_task.t_mem_list))) {
+ &se_cmd->t_mem_list))) {
se_mem = list_entry(se_mem->se_list.next,
struct se_mem, se_list);
(*se_mem_cnt)++;
sg->length = (se_mem->se_len - *task_offset);
if (!(list_is_last(&se_mem->se_list,
- &se_cmd->t_task.t_mem_list))) {
+ &se_cmd->t_mem_list))) {
se_mem = list_entry(se_mem->se_list.next,
struct se_mem, se_list);
(*se_mem_cnt)++;
}
/*
* Walk the struct se_task list and setup scatterlist chains
- * for each contiguosly allocated struct se_task->task_sg[].
+ * for each contiguously allocated struct se_task->task_sg[].
*/
- list_for_each_entry(task, &cmd->t_task.t_task_list, t_list) {
+ list_for_each_entry(task, &cmd->t_task_list, t_list) {
if (!(task->task_sg) || !(task->task_padded_sg))
continue;
* Either add chain or mark end of scatterlist
*/
if (!(list_is_last(&task->t_list,
- &cmd->t_task.t_task_list))) {
+ &cmd->t_task_list))) {
/*
* Clear existing SGL termination bit set in
* transport_init_task_sg(), see sg_mark_end()
/*
* Check for single task..
*/
- if (!(list_is_last(&task->t_list, &cmd->t_task.t_task_list))) {
+ if (!(list_is_last(&task->t_list, &cmd->t_task_list))) {
/*
* Clear existing SGL termination bit set in
* transport_init_task_sg(), see sg_mark_end()
* Setup the starting pointer and total t_tasks_sg_linked_no including
* padding SGs for linking and to mark the end.
*/
- cmd->t_task.t_tasks_sg_chained = sg_first;
- cmd->t_task.t_tasks_sg_chained_no = sg_count;
+ cmd->t_tasks_sg_chained = sg_first;
+ cmd->t_tasks_sg_chained_no = sg_count;
- DEBUG_CMD_M("Setup cmd: %p cmd->t_task.t_tasks_sg_chained: %p and"
- " t_tasks_sg_chained_no: %u\n", cmd, cmd->t_task.t_tasks_sg_chained,
- cmd->t_task.t_tasks_sg_chained_no);
+ DEBUG_CMD_M("Setup cmd: %p cmd->t_tasks_sg_chained: %p and"
+ " t_tasks_sg_chained_no: %u\n", cmd, cmd->t_tasks_sg_chained,
+ cmd->t_tasks_sg_chained_no);
- for_each_sg(cmd->t_task.t_tasks_sg_chained, sg,
- cmd->t_task.t_tasks_sg_chained_no, i) {
+ for_each_sg(cmd->t_tasks_sg_chained, sg,
+ cmd->t_tasks_sg_chained_no, i) {
DEBUG_CMD_M("SG[%d]: %p page: %p length: %d offset: %d\n",
i, sg, sg_page(sg), sg->length, sg->offset);
in_mem, in_se_mem, out_se_mem, se_mem_cnt,
task_offset_in);
if (ret == 0)
- task->task_se_cmd->t_task.t_tasks_se_num += *se_mem_cnt;
+ task->task_se_cmd->t_tasks_se_num += *se_mem_cnt;
return ret;
}
task_offset_in);
}
-static u32 transport_generic_get_cdb_count(
+/*
+ * Break up cmd into chunks transport can handle
+ */
+static u32 transport_allocate_tasks(
struct se_cmd *cmd,
unsigned long long lba,
u32 sectors,
{
unsigned char *cdb = NULL;
struct se_task *task;
- struct se_mem *se_mem = NULL, *se_mem_lout = NULL;
- struct se_mem *se_mem_bidi = NULL, *se_mem_bidi_lout = NULL;
+ struct se_mem *se_mem = NULL;
+ struct se_mem *se_mem_lout = NULL;
+ struct se_mem *se_mem_bidi = NULL;
+ struct se_mem *se_mem_bidi_lout = NULL;
struct se_device *dev = cmd->se_dev;
- int max_sectors_set = 0, ret;
- u32 task_offset_in = 0, se_mem_cnt = 0, se_mem_bidi_cnt = 0, task_cdbs = 0;
+ int ret;
+ u32 task_offset_in = 0;
+ u32 se_mem_cnt = 0;
+ u32 se_mem_bidi_cnt = 0;
+ u32 task_cdbs = 0;
- if (!mem_list) {
- printk(KERN_ERR "mem_list is NULL in transport_generic_get"
- "_cdb_count()\n");
- return 0;
- }
+ BUG_ON(!mem_list);
/*
* While using RAMDISK_DR backstores is the only case where
* mem_list will ever be empty at this point.
* Check for extra se_mem_bidi mapping for BIDI-COMMANDs to
* struct se_task->task_sg_bidi for TCM/pSCSI passthrough operation
*/
- if (!list_empty(&cmd->t_task.t_mem_bidi_list) &&
+ if (!list_empty(&cmd->t_mem_bidi_list) &&
(dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV))
- se_mem_bidi = list_first_entry(&cmd->t_task.t_mem_bidi_list,
+ se_mem_bidi = list_first_entry(&cmd->t_mem_bidi_list,
struct se_mem, se_list);
while (sectors) {
+ sector_t limited_sectors;
+
DEBUG_VOL("ITT[0x%08x] LBA(%llu) SectorsLeft(%u) EOBJ(%llu)\n",
cmd->se_tfo->get_task_tag(cmd), lba, sectors,
transport_dev_end_lba(dev));
+ limited_sectors = transport_limit_task_sectors(dev, lba, sectors);
+ if (!limited_sectors)
+ break;
+
task = transport_generic_get_task(cmd, data_direction);
- if (!(task))
+ if (!task)
goto out;
- transport_set_tasks_sectors(task, dev, lba, sectors,
- &max_sectors_set);
-
task->task_lba = lba;
+ task->task_sectors = limited_sectors;
lba += task->task_sectors;
sectors -= task->task_sectors;
task->task_size = (task->task_sectors *
dev->se_sub_dev->se_dev_attrib.block_size);
cdb = dev->transport->get_cdb(task);
- if ((cdb)) {
- memcpy(cdb, cmd->t_task.t_task_cdb,
- scsi_command_size(cmd->t_task.t_task_cdb));
- cmd->transport_split_cdb(task->task_lba,
- &task->task_sectors, cdb);
- }
+ /* Should be part of task, can't fail */
+ BUG_ON(!cdb);
+
+ memcpy(cdb, cmd->t_task_cdb,
+ scsi_command_size(cmd->t_task_cdb));
+
+ /* Update new cdb with updated lba/sectors */
+ cmd->transport_split_cdb(task->task_lba,
+ &task->task_sectors, cdb);
/*
* Perform the SE OBJ plugin and/or Transport plugin specific
- * mapping for cmd->t_task.t_mem_list. And setup the
+ * mapping for cmd->t_mem_list. And setup the
* task->task_sg and if necessary task->task_sg_bidi
*/
ret = transport_do_se_mem_map(dev, task, mem_list,
se_mem = se_mem_lout;
/*
- * Setup the cmd->t_task.t_mem_bidi_list -> task->task_sg_bidi
+ * Setup the cmd->t_mem_bidi_list -> task->task_sg_bidi
* mapping for SCSI READ for BIDI-COMMAND passthrough with TCM/pSCSI
*
* Note that the first call to transport_do_se_mem_map() above will
*/
if (task->task_sg_bidi != NULL) {
ret = transport_do_se_mem_map(dev, task,
- &cmd->t_task.t_mem_bidi_list, NULL,
+ &cmd->t_mem_bidi_list, NULL,
se_mem_bidi, &se_mem_bidi_lout, &se_mem_bidi_cnt,
&task_offset_in);
if (ret < 0)
DEBUG_VOL("Incremented task_cdbs(%u) task->task_sg_num(%u)\n",
task_cdbs, task->task_sg_num);
-
- if (max_sectors_set) {
- max_sectors_set = 0;
- continue;
- }
-
- if (!sectors)
- break;
}
if (set_counts) {
- atomic_inc(&cmd->t_task.t_fe_count);
- atomic_inc(&cmd->t_task.t_se_count);
+ atomic_inc(&cmd->t_fe_count);
+ atomic_inc(&cmd->t_se_count);
}
DEBUG_VOL("ITT[0x%08x] total %s cdbs(%u)\n",
return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES;
cdb = dev->transport->get_cdb(task);
- if (cdb)
- memcpy(cdb, cmd->t_task.t_task_cdb,
- scsi_command_size(cmd->t_task.t_task_cdb));
+ BUG_ON(!cdb);
+ memcpy(cdb, cmd->t_task_cdb,
+ scsi_command_size(cmd->t_task_cdb));
task->task_size = cmd->data_length;
task->task_sg_num =
(cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) ? 1 : 0;
- atomic_inc(&cmd->t_task.t_fe_count);
- atomic_inc(&cmd->t_task.t_se_count);
+ atomic_inc(&cmd->t_fe_count);
+ atomic_inc(&cmd->t_se_count);
if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) {
struct se_mem *se_mem = NULL, *se_mem_lout = NULL;
u32 se_mem_cnt = 0, task_offset = 0;
- if (!list_empty(&cmd->t_task.t_mem_list))
- se_mem = list_first_entry(&cmd->t_task.t_mem_list,
+ if (!list_empty(&cmd->t_mem_list))
+ se_mem = list_first_entry(&cmd->t_mem_list,
struct se_mem, se_list);
ret = transport_do_se_mem_map(dev, task,
- &cmd->t_task.t_mem_list, NULL, se_mem,
+ &cmd->t_mem_list, NULL, se_mem,
&se_mem_lout, &se_mem_cnt, &task_offset);
if (ret < 0)
return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES;
/*
* Generate struct se_task(s) and/or their payloads for this CDB.
*/
-static int transport_generic_new_cmd(struct se_cmd *cmd)
+int transport_generic_new_cmd(struct se_cmd *cmd)
{
- struct se_portal_group *se_tpg;
struct se_task *task;
struct se_device *dev = cmd->se_dev;
int ret = 0;
* Determine is the TCM fabric module has already allocated physical
* memory, and is directly calling transport_generic_map_mem_to_cmd()
* to setup beforehand the linked list of physical memory at
- * cmd->t_task.t_mem_list of struct se_mem->se_page
+ * cmd->t_mem_list of struct se_mem->se_page
*/
if (!(cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC)) {
ret = transport_allocate_resources(cmd);
return ret;
}
- ret = transport_get_sectors(cmd);
- if (ret < 0)
- return ret;
-
ret = transport_new_cmd_obj(cmd);
if (ret < 0)
return ret;
- /*
- * Determine if the calling TCM fabric module is talking to
- * Linux/NET via kernel sockets and needs to allocate a
- * struct iovec array to complete the struct se_cmd
- */
- se_tpg = cmd->se_lun->lun_sep->sep_tpg;
- if (se_tpg->se_tpg_tfo->alloc_cmd_iovecs != NULL) {
- ret = se_tpg->se_tpg_tfo->alloc_cmd_iovecs(cmd);
- if (ret < 0)
- return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES;
- }
-
if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
- list_for_each_entry(task, &cmd->t_task.t_task_list, t_list) {
+ list_for_each_entry(task, &cmd->t_task_list, t_list) {
if (atomic_read(&task->task_sent))
continue;
if (!dev->transport->map_task_SG)
}
/*
- * For WRITEs, let the iSCSI Target RX Thread know its buffer is ready..
+ * For WRITEs, let the fabric know its buffer is ready..
* This WRITE struct se_cmd (and all of its associated struct se_task's)
* will be added to the struct se_device execution queue after its WRITE
* data has arrived. (ie: It gets handled by the transport processing
transport_execute_tasks(cmd);
return 0;
}
+EXPORT_SYMBOL(transport_generic_new_cmd);
/* transport_generic_process_write():
*
* original EDTL
*/
if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
- if (!cmd->t_task.t_tasks_se_num) {
+ if (!cmd->t_tasks_se_num) {
unsigned char *dst, *buf =
- (unsigned char *)cmd->t_task.t_task_buf;
+ (unsigned char *)cmd->t_task_buf;
dst = kzalloc(cmd->cmd_spdtl), GFP_KERNEL);
if (!(dst)) {
}
memcpy(dst, buf, cmd->cmd_spdtl);
- kfree(cmd->t_task.t_task_buf);
- cmd->t_task.t_task_buf = dst;
+ kfree(cmd->t_task_buf);
+ cmd->t_task_buf = dst;
} else {
struct scatterlist *sg =
- (struct scatterlist *sg)cmd->t_task.t_task_buf;
+ (struct scatterlist *sg)cmd->t_task_buf;
struct scatterlist *orig_sg;
orig_sg = kzalloc(sizeof(struct scatterlist) *
- cmd->t_task.t_tasks_se_num,
+ cmd->t_tasks_se_num,
GFP_KERNEL))) {
if (!(orig_sg)) {
printk(KERN_ERR "Unable to allocate memory"
return;
}
- memcpy(orig_sg, cmd->t_task.t_task_buf,
+ memcpy(orig_sg, cmd->t_task_buf,
sizeof(struct scatterlist) *
- cmd->t_task.t_tasks_se_num);
+ cmd->t_tasks_se_num);
cmd->data_length = cmd->cmd_spdtl;
/*
unsigned long flags;
int ret;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
cmd->t_state = TRANSPORT_WRITE_PENDING;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
/*
* For the TCM control CDBs using a contiguous buffer, do the memcpy
* from the passed Linux/SCSI struct scatterlist located at
- * se_cmd->t_task.t_task_pt_buf to the contiguous buffer at
- * se_cmd->t_task.t_task_buf.
+ * se_cmd->t_task_pt_sgl to the contiguous buffer at
+ * se_cmd->t_task_buf.
*/
if (cmd->se_cmd_flags & SCF_PASSTHROUGH_CONTIG_TO_SG)
- transport_memcpy_read_contig(cmd,
- cmd->t_task.t_task_buf,
- cmd->t_task.t_task_pt_sgl);
+ sg_copy_to_buffer(cmd->t_task_pt_sgl,
+ cmd->t_task_pt_sgl_num,
+ cmd->t_task_buf,
+ cmd->data_length);
/*
* Clear the se_cmd for WRITE_PENDING status in order to set
- * cmd->t_task.t_transport_active=0 so that transport_generic_handle_data
+ * cmd->t_transport_active=0 so that transport_generic_handle_data
* can be called from HW target mode interrupt code. This is safe
* to be called with transport_off=1 before the cmd->se_tfo->write_pending
* because the se_cmd->se_lun pointer is not being cleared.
* If the frontend has already requested this struct se_cmd to
* be stopped, we can safely ignore this struct se_cmd.
*/
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- if (atomic_read(&cmd->t_task.t_transport_stop)) {
- atomic_set(&cmd->t_task.transport_lun_stop, 0);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ if (atomic_read(&cmd->t_transport_stop)) {
+ atomic_set(&cmd->transport_lun_stop, 0);
DEBUG_TRANSPORT_S("ConfigFS ITT[0x%08x] - t_transport_stop =="
" TRUE, skipping\n", cmd->se_tfo->get_task_tag(cmd));
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_cmd_check_stop(cmd, 1, 0);
return -EPERM;
}
- atomic_set(&cmd->t_task.transport_lun_fe_stop, 1);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ atomic_set(&cmd->transport_lun_fe_stop, 1);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
wake_up_interruptible(&cmd->se_dev->dev_queue_obj.thread_wq);
ret = transport_stop_tasks_for_cmd(cmd);
DEBUG_TRANSPORT_S("ConfigFS: cmd: %p t_task_cdbs: %d stop tasks ret:"
- " %d\n", cmd, cmd->t_task.t_task_cdbs, ret);
+ " %d\n", cmd, cmd->t_task_cdbs, ret);
if (!ret) {
DEBUG_TRANSPORT_S("ConfigFS: ITT[0x%08x] - stopping cmd....\n",
cmd->se_tfo->get_task_tag(cmd));
- wait_for_completion(&cmd->t_task.transport_lun_stop_comp);
+ wait_for_completion(&cmd->transport_lun_stop_comp);
DEBUG_TRANSPORT_S("ConfigFS: ITT[0x%08x] - stopped cmd....\n",
cmd->se_tfo->get_task_tag(cmd));
}
struct se_cmd, se_lun_node);
list_del(&cmd->se_lun_node);
- atomic_set(&cmd->t_task.transport_lun_active, 0);
+ atomic_set(&cmd->transport_lun_active, 0);
/*
* This will notify iscsi_target_transport.c:
* transport_cmd_check_stop() that a LUN shutdown is in
* progress for the iscsi_cmd_t.
*/
- spin_lock(&cmd->t_task.t_state_lock);
- DEBUG_CLEAR_L("SE_LUN[%d] - Setting cmd->t_task.transport"
+ spin_lock(&cmd->t_state_lock);
+ DEBUG_CLEAR_L("SE_LUN[%d] - Setting cmd->transport"
"_lun_stop for ITT: 0x%08x\n",
cmd->se_lun->unpacked_lun,
cmd->se_tfo->get_task_tag(cmd));
- atomic_set(&cmd->t_task.transport_lun_stop, 1);
- spin_unlock(&cmd->t_task.t_state_lock);
+ atomic_set(&cmd->transport_lun_stop, 1);
+ spin_unlock(&cmd->t_state_lock);
spin_unlock_irqrestore(&lun->lun_cmd_lock, lun_flags);
cmd->se_lun->unpacked_lun,
cmd->se_tfo->get_task_tag(cmd));
- spin_lock_irqsave(&cmd->t_task.t_state_lock, cmd_flags);
- if (!(atomic_read(&cmd->t_task.transport_dev_active))) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, cmd_flags);
+ spin_lock_irqsave(&cmd->t_state_lock, cmd_flags);
+ if (!(atomic_read(&cmd->transport_dev_active))) {
+ spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags);
goto check_cond;
}
- atomic_set(&cmd->t_task.transport_dev_active, 0);
+ atomic_set(&cmd->transport_dev_active, 0);
transport_all_task_dev_remove_state(cmd);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, cmd_flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags);
transport_free_dev_tasks(cmd);
/*
* be released, notify the waiting thread now that LU has
* finished accessing it.
*/
- spin_lock_irqsave(&cmd->t_task.t_state_lock, cmd_flags);
- if (atomic_read(&cmd->t_task.transport_lun_fe_stop)) {
+ spin_lock_irqsave(&cmd->t_state_lock, cmd_flags);
+ if (atomic_read(&cmd->transport_lun_fe_stop)) {
DEBUG_CLEAR_L("SE_LUN[%d] - Detected FE stop for"
" struct se_cmd: %p ITT: 0x%08x\n",
lun->unpacked_lun,
cmd, cmd->se_tfo->get_task_tag(cmd));
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
+ spin_unlock_irqrestore(&cmd->t_state_lock,
cmd_flags);
transport_cmd_check_stop(cmd, 1, 0);
- complete(&cmd->t_task.transport_lun_fe_stop_comp);
+ complete(&cmd->transport_lun_fe_stop_comp);
spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
continue;
}
DEBUG_CLEAR_L("SE_LUN[%d] - ITT: 0x%08x finished processing\n",
lun->unpacked_lun, cmd->se_tfo->get_task_tag(cmd));
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, cmd_flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags);
spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
}
spin_unlock_irqrestore(&lun->lun_cmd_lock, lun_flags);
if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_tmr_req))
return;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
/*
* If we are already stopped due to an external event (ie: LUN shutdown)
* sleep until the connection can have the passed struct se_cmd back.
- * The cmd->t_task.transport_lun_stopped_sem will be upped by
+ * The cmd->transport_lun_stopped_sem will be upped by
* transport_clear_lun_from_sessions() once the ConfigFS context caller
* has completed its operation on the struct se_cmd.
*/
- if (atomic_read(&cmd->t_task.transport_lun_stop)) {
+ if (atomic_read(&cmd->transport_lun_stop)) {
DEBUG_TRANSPORT_S("wait_for_tasks: Stopping"
" wait_for_completion(&cmd->t_tasktransport_lun_fe"
* We go ahead and up transport_lun_stop_comp just to be sure
* here.
*/
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
- complete(&cmd->t_task.transport_lun_stop_comp);
- wait_for_completion(&cmd->t_task.transport_lun_fe_stop_comp);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+ complete(&cmd->transport_lun_stop_comp);
+ wait_for_completion(&cmd->transport_lun_fe_stop_comp);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
transport_all_task_dev_remove_state(cmd);
/*
"stop_comp); for ITT: 0x%08x\n",
cmd->se_tfo->get_task_tag(cmd));
- atomic_set(&cmd->t_task.transport_lun_stop, 0);
+ atomic_set(&cmd->transport_lun_stop, 0);
}
- if (!atomic_read(&cmd->t_task.t_transport_active) ||
- atomic_read(&cmd->t_task.t_transport_aborted))
+ if (!atomic_read(&cmd->t_transport_active) ||
+ atomic_read(&cmd->t_transport_aborted))
goto remove;
- atomic_set(&cmd->t_task.t_transport_stop, 1);
+ atomic_set(&cmd->t_transport_stop, 1);
DEBUG_TRANSPORT_S("wait_for_tasks: Stopping %p ITT: 0x%08x"
" i_state: %d, t_state/def_t_state: %d/%d, t_transport_stop"
cmd->se_tfo->get_cmd_state(cmd), cmd->t_state,
cmd->deferred_t_state);
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
wake_up_interruptible(&cmd->se_dev->dev_queue_obj.thread_wq);
- wait_for_completion(&cmd->t_task.t_transport_stop_comp);
+ wait_for_completion(&cmd->t_transport_stop_comp);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- atomic_set(&cmd->t_task.t_transport_active, 0);
- atomic_set(&cmd->t_task.t_transport_stop, 0);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ atomic_set(&cmd->t_transport_active, 0);
+ atomic_set(&cmd->t_transport_stop, 0);
DEBUG_TRANSPORT_S("wait_for_tasks: Stopped wait_for_compltion("
- "&cmd->t_task.t_transport_stop_comp) for ITT: 0x%08x\n",
+ "&cmd->t_transport_stop_comp) for ITT: 0x%08x\n",
cmd->se_tfo->get_task_tag(cmd));
remove:
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
if (!remove_cmd)
return;
int offset;
u8 asc = 0, ascq = 0;
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return 0;
}
cmd->se_cmd_flags |= SCF_SENT_CHECK_CONDITION;
- spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
+ spin_unlock_irqrestore(&cmd->t_state_lock, flags);
if (!reason && from_transport)
goto after_reason;
{
int ret = 0;
- if (atomic_read(&cmd->t_task.t_transport_aborted) != 0) {
+ if (atomic_read(&cmd->t_transport_aborted) != 0) {
if (!(send_status) ||
(cmd->se_cmd_flags & SCF_SENT_DELAYED_TAS))
return 1;
#if 0
printk(KERN_INFO "Sending delayed SAM_STAT_TASK_ABORTED"
" status for CDB: 0x%02x ITT: 0x%08x\n",
- cmd->t_task.t_task_cdb[0],
+ cmd->t_task_cdb[0],
cmd->se_tfo->get_task_tag(cmd));
#endif
cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS;
*/
if (cmd->data_direction == DMA_TO_DEVICE) {
if (cmd->se_tfo->write_pending_status(cmd) != 0) {
- atomic_inc(&cmd->t_task.t_transport_aborted);
+ atomic_inc(&cmd->t_transport_aborted);
smp_mb__after_atomic_inc();
cmd->scsi_status = SAM_STAT_TASK_ABORTED;
transport_new_cmd_failure(cmd);
cmd->scsi_status = SAM_STAT_TASK_ABORTED;
#if 0
printk(KERN_INFO "Setting SAM_STAT_TASK_ABORTED status for CDB: 0x%02x,"
- " ITT: 0x%08x\n", cmd->t_task.t_task_cdb[0],
+ " ITT: 0x%08x\n", cmd->t_task_cdb[0],
cmd->se_tfo->get_task_tag(cmd));
#endif
cmd->se_tfo->queue_status(cmd);
*/
int transport_generic_do_tmr(struct se_cmd *cmd)
{
- struct se_cmd *ref_cmd;
struct se_device *dev = cmd->se_dev;
struct se_tmr_req *tmr = cmd->se_tmr_req;
int ret;
switch (tmr->function) {
case TMR_ABORT_TASK:
- ref_cmd = tmr->ref_cmd;
tmr->response = TMR_FUNCTION_REJECTED;
break;
case TMR_ABORT_TASK_SET:
spin_unlock_irqrestore(&dev->execute_task_lock, flags);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
DEBUG_DO("PT: cmd: %p task: %p ITT/CmdSN: 0x%08x/0x%08x,"
" i_state/def_i_state: %d/%d, t_state/def_t_state:"
cmd->se_tfo->get_task_tag(cmd), cmd->cmd_sn,
cmd->se_tfo->get_cmd_state(cmd), cmd->deferred_i_state,
cmd->t_state, cmd->deferred_t_state,
- cmd->t_task.t_task_cdb[0]);
+ cmd->t_task_cdb[0]);
DEBUG_DO("PT: ITT[0x%08x] - t_task_cdbs: %d t_task_cdbs_left:"
" %d t_task_cdbs_sent: %d -- t_transport_active: %d"
" t_transport_stop: %d t_transport_sent: %d\n",
cmd->se_tfo->get_task_tag(cmd),
- cmd->t_task.t_task_cdbs,
- atomic_read(&cmd->t_task.t_task_cdbs_left),
- atomic_read(&cmd->t_task.t_task_cdbs_sent),
- atomic_read(&cmd->t_task.t_transport_active),
- atomic_read(&cmd->t_task.t_transport_stop),
- atomic_read(&cmd->t_task.t_transport_sent));
+ cmd->t_task_cdbs,
+ atomic_read(&cmd->t_task_cdbs_left),
+ atomic_read(&cmd->t_task_cdbs_sent),
+ atomic_read(&cmd->t_transport_active),
+ atomic_read(&cmd->t_transport_stop),
+ atomic_read(&cmd->t_transport_sent));
if (atomic_read(&task->task_active)) {
atomic_set(&task->task_stop, 1);
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
DEBUG_DO("Waiting for task: %p to shutdown for dev:"
" %p\n", task, dev);
DEBUG_DO("Completed task: %p shutdown for dev: %p\n",
task, dev);
- spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
- atomic_dec(&cmd->t_task.t_task_cdbs_left);
+ spin_lock_irqsave(&cmd->t_state_lock, flags);
+ atomic_dec(&cmd->t_task_cdbs_left);
atomic_set(&task->task_active, 0);
atomic_set(&task->task_stop, 0);
}
__transport_stop_task_timer(task, &flags);
- if (!(atomic_dec_and_test(&cmd->t_task.t_task_cdbs_ex_left))) {
+ if (!(atomic_dec_and_test(&cmd->t_task_cdbs_ex_left))) {
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
DEBUG_DO("Skipping task: %p, dev: %p for"
" t_task_cdbs_ex_left: %d\n", task, dev,
- atomic_read(&cmd->t_task.t_task_cdbs_ex_left));
+ atomic_read(&cmd->t_task_cdbs_ex_left));
spin_lock_irqsave(&dev->execute_task_lock, flags);
continue;
}
- if (atomic_read(&cmd->t_task.t_transport_active)) {
+ if (atomic_read(&cmd->t_transport_active)) {
DEBUG_DO("got t_transport_active = 1 for task: %p, dev:"
" %p\n", task, dev);
- if (atomic_read(&cmd->t_task.t_fe_count)) {
+ if (atomic_read(&cmd->t_fe_count)) {
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
transport_send_check_condition_and_sense(
cmd, TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE,
0);
transport_cmd_check_stop(cmd, 1, 0);
} else {
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
transport_remove_cmd_from_queue(cmd,
&cmd->se_dev->dev_queue_obj);
DEBUG_DO("Got t_transport_active = 0 for task: %p, dev: %p\n",
task, dev);
- if (atomic_read(&cmd->t_task.t_fe_count)) {
+ if (atomic_read(&cmd->t_fe_count)) {
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
transport_send_check_condition_and_sense(cmd,
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
transport_remove_cmd_from_queue(cmd,
transport_cmd_check_stop(cmd, 1, 0);
} else {
spin_unlock_irqrestore(
- &cmd->t_task.t_state_lock, flags);
+ &cmd->t_state_lock, flags);
transport_remove_cmd_from_queue(cmd,
&cmd->se_dev->dev_queue_obj);
DEBUG_DO("From Device Queue: cmd: %p t_state: %d\n",
cmd, cmd->t_state);
- if (atomic_read(&cmd->t_task.t_fe_count)) {
+ if (atomic_read(&cmd->t_fe_count)) {
transport_send_check_condition_and_sense(cmd,
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);