Commit 5951146d authored by Andy Grover's avatar Andy Grover Committed by Nicholas Bellinger

target: More core cleanups from AGrover (round 2)

This patch contains the squashed version of second round of target core
cleanups and simplifications and Andy and Co.   It also contains a handful
of fixes to address bugs the original series and other minor cleanups.

Here is the condensed shortlog:

target: Remove unneeded casts to void*
target: Rename get_lun_for_{cmd,tmr} to lookup_{cmd,tmr}_lun
target: Make t_task a member of se_cmd, not a pointer
target: Handle functions returning "-2"
target: Use cmd->se_dev over cmd->se_lun->lun_se_dev
target: Embed qr in struct se_cmd
target: Replace embedded struct se_queue_req with a list_head
target: Rename list_heads that are nodes in struct se_cmd to "*_node"
target: Fold transport_device_setup_cmd() into lookup_{tmr,cmd}_lun()
target: Make t_mem_list and t_mem_list_bidi members of t_task
target: Add comment & cleanup transport_map_sg_to_mem()
target: Remove unneeded checks in transport_free_pages()

(Roland: Fix se_queue_req removal leftovers OOPs)
(nab: Fix transport_lookup_tmr_lun failure case)
(nab: Fix list_empty(&cmd->t_task.t_mem_bidi_list) inversion bugs)
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent f22c1196
......@@ -118,17 +118,16 @@ static struct se_cmd *tcm_loop_allocate_core_cmd(
* Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi
*/
if (scsi_bidi_cmnd(sc))
se_cmd->t_task->t_tasks_bidi = 1;
se_cmd->t_task.t_tasks_bidi = 1;
/*
* Locate the struct se_lun pointer and attach it to struct se_cmd
*/
if (transport_get_lun_for_cmd(se_cmd, tl_cmd->sc->device->lun) < 0) {
if (transport_lookup_cmd_lun(se_cmd, tl_cmd->sc->device->lun) < 0) {
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
set_host_byte(sc, DID_NO_CONNECT);
return NULL;
}
transport_device_setup_cmd(se_cmd);
return se_cmd;
}
......@@ -143,17 +142,17 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
struct tcm_loop_cmd, tl_se_cmd);
struct scsi_cmnd *sc = tl_cmd->sc;
void *mem_ptr, *mem_bidi_ptr = NULL;
u32 sg_no_bidi = 0;
struct scatterlist *sgl_bidi = NULL;
u32 sgl_bidi_count = 0;
int ret;
/*
* Allocate the necessary tasks to complete the received CDB+data
*/
ret = transport_generic_allocate_tasks(se_cmd, tl_cmd->sc->cmnd);
if (ret == -1) {
ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd);
if (ret == -ENOMEM) {
/* Out of Resources */
return PYX_TRANSPORT_LU_COMM_FAILURE;
} else if (ret == -2) {
} else if (ret == -EINVAL) {
/*
* Handle case for SAM_STAT_RESERVATION_CONFLICT
*/
......@@ -165,35 +164,24 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
*/
return PYX_TRANSPORT_USE_SENSE_REASON;
}
/*
* Setup the struct scatterlist memory from the received
* struct scsi_cmnd.
*/
if (scsi_sg_count(sc)) {
se_cmd->se_cmd_flags |= SCF_PASSTHROUGH_SG_TO_MEM;
mem_ptr = (void *)scsi_sglist(sc);
/*
* For BIDI commands, pass in the extra READ buffer
* to transport_generic_map_mem_to_cmd() below..
*/
if (se_cmd->t_task->t_tasks_bidi) {
if (se_cmd->t_task.t_tasks_bidi) {
struct scsi_data_buffer *sdb = scsi_in(sc);
mem_bidi_ptr = (void *)sdb->table.sgl;
sg_no_bidi = sdb->table.nents;
}
} else {
/*
* Used for DMA_NONE
*/
mem_ptr = NULL;
sgl_bidi = sdb->table.sgl;
sgl_bidi_count = sdb->table.nents;
}
/*
* Map the SG memory into struct se_mem->page linked list using the same
* physical memory at sg->page_link.
*/
ret = transport_generic_map_mem_to_cmd(se_cmd, mem_ptr,
scsi_sg_count(sc), mem_bidi_ptr, sg_no_bidi);
ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc),
scsi_sg_count(sc), sgl_bidi, sgl_bidi_count);
if (ret < 0)
return PYX_TRANSPORT_LU_COMM_FAILURE;
......@@ -384,14 +372,14 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
/*
* Allocate the LUN_RESET TMR
*/
se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr,
se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, tl_tmr,
TMR_LUN_RESET);
if (IS_ERR(se_cmd->se_tmr_req))
goto release;
/*
* Locate the underlying TCM struct se_lun from sc->device->lun
*/
if (transport_get_lun_for_tmr(se_cmd, sc->device->lun) < 0)
if (transport_lookup_tmr_lun(se_cmd, sc->device->lun) < 0)
goto release;
/*
* Queue the TMR to TCM Core and sleep waiting for tcm_loop_queue_tm_rsp()
......@@ -904,7 +892,7 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)
((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
(se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) {
memcpy((void *)sc->sense_buffer, (void *)se_cmd->sense_buffer,
memcpy(sc->sense_buffer, se_cmd->sense_buffer,
SCSI_SENSE_BUFFERSIZE);
sc->result = SAM_STAT_CHECK_CONDITION;
set_driver_byte(sc, DRIVER_SENSE);
......@@ -1054,7 +1042,7 @@ static int tcm_loop_make_nexus(
* transport_register_session()
*/
__transport_register_session(se_tpg, tl_nexus->se_sess->se_node_acl,
tl_nexus->se_sess, (void *)tl_nexus);
tl_nexus->se_sess, tl_nexus);
tl_tpg->tl_hba->tl_nexus = tl_nexus;
printk(KERN_INFO "TCM_Loop_ConfigFS: Established I_T Nexus to emulated"
" %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba),
......@@ -1242,7 +1230,7 @@ struct se_portal_group *tcm_loop_make_naa_tpg(
* Register the tl_tpg as a emulated SAS TCM Target Endpoint
*/
ret = core_tpg_register(&tcm_loop_fabric_configfs->tf_ops,
wwn, &tl_tpg->tl_se_tpg, (void *)tl_tpg,
wwn, &tl_tpg->tl_se_tpg, tl_tpg,
TRANSPORT_TPG_TYPE_NORMAL);
if (ret < 0)
return ERR_PTR(-ENOMEM);
......
......@@ -61,11 +61,11 @@ struct t10_alua_lu_gp *default_lu_gp;
*/
int core_emulate_report_target_port_groups(struct se_cmd *cmd)
{
struct se_subsystem_dev *su_dev = cmd->se_lun->lun_se_dev->se_sub_dev;
struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
struct se_port *port;
struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
u32 rd_len = 0, off = 4; /* Skip over RESERVED area to first
Target port group descriptor */
......@@ -151,13 +151,13 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd)
*/
int core_emulate_set_target_port_groups(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct se_port *port, *l_port = cmd->se_lun->lun_sep;
struct se_node_acl *nacl = cmd->se_sess->se_node_acl;
struct t10_alua_tg_pt_gp *tg_pt_gp = NULL, *l_tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, *l_tg_pt_gp_mem;
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
unsigned char *ptr = &buf[4]; /* Skip over RESERVED area in header */
u32 len = 4; /* Skip over RESERVED area in header */
int alua_access_state, primary = 0, rc;
......
......@@ -65,8 +65,8 @@ static int
target_emulate_inquiry_std(struct se_cmd *cmd)
{
struct se_lun *lun = cmd->se_lun;
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
/*
* Make sure we at least have 6 bytes of INQUIRY response
......@@ -128,7 +128,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
* Registered Extended LUN WWN has been set via ConfigFS
* during device creation/restart.
*/
if (cmd->se_lun->lun_se_dev->se_sub_dev->su_dev_flags &
if (cmd->se_dev->se_sub_dev->su_dev_flags &
SDF_EMULATED_VPD_UNIT_SERIAL) {
buf[3] = 3;
buf[5] = 0x80;
......@@ -143,7 +143,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
u16 len = 0;
buf[1] = 0x80;
......@@ -176,7 +176,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
struct se_lun *lun = cmd->se_lun;
struct se_port *port = NULL;
struct se_portal_group *tpg = NULL;
......@@ -477,7 +477,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
buf[5] = 0x07;
/* If WriteCache emulation is enabled, set V_SUP */
if (cmd->se_lun->lun_se_dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0)
if (cmd->se_dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0)
buf[6] = 0x01;
return 0;
}
......@@ -486,7 +486,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
int have_tp = 0;
/*
......@@ -568,7 +568,7 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
/*
* From sbc3r22 section 6.5.4 Thin Provisioning VPD page:
......@@ -620,9 +620,9 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_inquiry(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
unsigned char *cdb = cmd->t_task->t_task_cdb;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
unsigned char *cdb = cmd->t_task.t_task_cdb;
if (!(cdb[1] & 0x1))
return target_emulate_inquiry_std(cmd);
......@@ -665,8 +665,8 @@ target_emulate_inquiry(struct se_cmd *cmd)
static int
target_emulate_readcapacity(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
unsigned long long blocks_long = dev->transport->get_blocks(dev);
u32 blocks;
......@@ -695,8 +695,8 @@ target_emulate_readcapacity(struct se_cmd *cmd)
static int
target_emulate_readcapacity_16(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
unsigned long long blocks = dev->transport->get_blocks(dev);
buf[0] = (blocks >> 56) & 0xff;
......@@ -830,9 +830,9 @@ target_modesense_dpofua(unsigned char *buf, int type)
static int
target_emulate_modesense(struct se_cmd *cmd, int ten)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
char *cdb = cmd->t_task->t_task_cdb;
unsigned char *rbuf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
char *cdb = cmd->t_task.t_task_cdb;
unsigned char *rbuf = cmd->t_task.t_task_buf;
int type = dev->transport->get_device_type(dev);
int offset = (ten) ? 8 : 4;
int length = 0;
......@@ -903,8 +903,8 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
static int
target_emulate_request_sense(struct se_cmd *cmd)
{
unsigned char *cdb = cmd->t_task->t_task_cdb;
unsigned char *buf = cmd->t_task->t_task_buf;
unsigned char *cdb = cmd->t_task.t_task_cdb;
unsigned char *buf = cmd->t_task.t_task_buf;
u8 ua_asc = 0, ua_ascq = 0;
if (cdb[1] & 0x01) {
......@@ -964,9 +964,9 @@ static int
target_emulate_unmap(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf, *ptr = NULL;
unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf, *ptr = NULL;
unsigned char *cdb = &cmd->t_task.t_task_cdb[0];
sector_t lba;
unsigned int size = cmd->data_length, range;
int ret, offset;
......@@ -1011,8 +1011,8 @@ static int
target_emulate_write_same(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
sector_t lba = cmd->t_task->t_task_lba;
struct se_device *dev = cmd->se_dev;
sector_t lba = cmd->t_task.t_task_lba;
unsigned int range;
int ret;
......@@ -1036,11 +1036,11 @@ int
transport_emulate_control_cdb(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
unsigned short service_action;
int ret = 0;
switch (cmd->t_task->t_task_cdb[0]) {
switch (cmd->t_task.t_task_cdb[0]) {
case INQUIRY:
ret = target_emulate_inquiry(cmd);
break;
......@@ -1054,13 +1054,13 @@ transport_emulate_control_cdb(struct se_task *task)
ret = target_emulate_modesense(cmd, 1);
break;
case SERVICE_ACTION_IN:
switch (cmd->t_task->t_task_cdb[1] & 0x1f) {
switch (cmd->t_task.t_task_cdb[1] & 0x1f) {
case SAI_READ_CAPACITY_16:
ret = target_emulate_readcapacity_16(cmd);
break;
default:
printk(KERN_ERR "Unsupported SA: 0x%02x\n",
cmd->t_task->t_task_cdb[1] & 0x1f);
cmd->t_task.t_task_cdb[1] & 0x1f);
return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
}
break;
......@@ -1085,7 +1085,7 @@ transport_emulate_control_cdb(struct se_task *task)
break;
case VARIABLE_LENGTH_CMD:
service_action =
get_unaligned_be16(&cmd->t_task->t_task_cdb[8]);
get_unaligned_be16(&cmd->t_task.t_task_cdb[8]);
switch (service_action) {
case WRITE_SAME_32:
if (!dev->transport->do_discard) {
......@@ -1124,7 +1124,7 @@ transport_emulate_control_cdb(struct se_task *task)
break;
default:
printk(KERN_ERR "Unsupported SCSI Opcode: 0x%02x for %s\n",
cmd->t_task->t_task_cdb[0], dev->transport->name);
cmd->t_task.t_task_cdb[0], dev->transport->name);
return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
}
......
......@@ -2037,7 +2037,7 @@ static ssize_t target_core_dev_show(struct config_item *item,
if (!(tc_attr->show))
return -EINVAL;
return tc_attr->show((void *)se_dev, page);
return tc_attr->show(se_dev, page);
}
static ssize_t target_core_dev_store(struct config_item *item,
......@@ -2053,7 +2053,7 @@ static ssize_t target_core_dev_store(struct config_item *item,
if (!(tc_attr->store))
return -EINVAL;
return tc_attr->store((void *)se_dev, page, count);
return tc_attr->store(se_dev, page, count);
}
static struct configfs_item_operations target_core_dev_item_ops = {
......
......@@ -59,15 +59,12 @@ static struct se_subsystem_dev *lun0_su_dev;
/* not static, needed by tpg.c */
struct se_device *g_lun0_dev;
int transport_get_lun_for_cmd(
struct se_cmd *se_cmd,
u32 unpacked_lun)
int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
{
struct se_dev_entry *deve;
struct se_lun *se_lun = NULL;
struct se_session *se_sess = se_cmd->se_sess;
struct se_device *dev;
unsigned long flags;
int read_only = 0;
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
......@@ -76,46 +73,42 @@ int transport_get_lun_for_cmd(
}
spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
deve = se_cmd->se_deve =
&se_sess->se_node_acl->device_list[unpacked_lun];
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
if (se_cmd) {
se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun];
if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
struct se_dev_entry *deve = se_cmd->se_deve;
deve->total_cmds++;
deve->total_bytes += se_cmd->data_length;
if (se_cmd->data_direction == DMA_TO_DEVICE) {
if (deve->lun_flags &
TRANSPORT_LUNFLAGS_READ_ONLY) {
read_only = 1;
goto out;
if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
(deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) {
se_cmd->scsi_sense_reason = TCM_WRITE_PROTECTED;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
printk("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
" Access for 0x%08x\n",
se_cmd->se_tfo->get_fabric_name(),
unpacked_lun);
spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
return -EACCES;
}
if (se_cmd->data_direction == DMA_TO_DEVICE)
deve->write_bytes += se_cmd->data_length;
} else if (se_cmd->data_direction ==
DMA_FROM_DEVICE) {
else if (se_cmd->data_direction == DMA_FROM_DEVICE)
deve->read_bytes += se_cmd->data_length;
}
}
deve->deve_cmds++;
se_lun = se_cmd->se_lun = deve->se_lun;
se_lun = deve->se_lun;
se_cmd->se_lun = deve->se_lun;
se_cmd->pr_res_key = deve->pr_res_key;
se_cmd->orig_fe_lun = unpacked_lun;
se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
}
out:
spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
if (!se_lun) {
if (read_only) {
se_cmd->scsi_sense_reason = TCM_WRITE_PROTECTED;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
printk("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
" Access for 0x%08x\n",
se_cmd->se_tfo->get_fabric_name(),
unpacked_lun);
return -EACCES;
} else {
/*
* Use the se_portal_group->tpg_virt_lun0 to allow for
* REPORT_LUNS, et al to be returned when no active
......@@ -139,28 +132,28 @@ int transport_get_lun_for_cmd(
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -EACCES;
}
#if 0
printk("TARGET_CORE[%s]: Using virtual LUN0! :-)\n",
se_cmd->se_tfo->get_fabric_name());
#endif
se_lun = se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0;
se_lun = &se_sess->se_tpg->tpg_virt_lun0;
se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0;
se_cmd->orig_fe_lun = 0;
se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
}
}
/*
* Determine if the struct se_lun is online.
* FIXME: Check for LUN_RESET + UNIT Attention
*/
/* #warning FIXME: Check for LUN_RESET + UNIT Attention */
if (se_dev_check_online(se_lun->lun_se_dev) != 0) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -ENODEV;
}
{
struct se_device *dev = se_lun->lun_se_dev;
/* Directly associate cmd with se_dev */
se_cmd->se_dev = se_lun->lun_se_dev;
/* TODO: get rid of this and use atomics for stats */
dev = se_lun->lun_se_dev;
spin_lock_irq(&dev->stats_lock);
dev->num_cmds++;
if (se_cmd->data_direction == DMA_TO_DEVICE)
......@@ -168,30 +161,22 @@ int transport_get_lun_for_cmd(
else if (se_cmd->data_direction == DMA_FROM_DEVICE)
dev->read_bytes += se_cmd->data_length;
spin_unlock_irq(&dev->stats_lock);
}
/*
* Add the iscsi_cmd_t to the struct se_lun's cmd list. This list is used
* for tracking state of struct se_cmds during LUN shutdown events.
*/
spin_lock_irqsave(&se_lun->lun_cmd_lock, flags);
list_add_tail(&se_cmd->se_lun_list, &se_lun->lun_cmd_list);
atomic_set(&se_cmd->t_task->transport_lun_active, 1);
#if 0
printk(KERN_INFO "Adding ITT: 0x%08x to LUN LIST[%d]\n",
se_cmd->se_tfo->get_task_tag(se_cmd), se_lun->unpacked_lun);
#endif
list_add_tail(&se_cmd->se_lun_node, &se_lun->lun_cmd_list);
atomic_set(&se_cmd->t_task.transport_lun_active, 1);
spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags);
return 0;
}
EXPORT_SYMBOL(transport_get_lun_for_cmd);
EXPORT_SYMBOL(transport_lookup_cmd_lun);
int transport_get_lun_for_tmr(
struct se_cmd *se_cmd,
u32 unpacked_lun)
int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
{
struct se_device *dev = NULL;
struct se_dev_entry *deve;
struct se_lun *se_lun = NULL;
struct se_session *se_sess = se_cmd->se_sess;
......@@ -204,15 +189,16 @@ int transport_get_lun_for_tmr(
}
spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
deve = se_cmd->se_deve =
&se_sess->se_node_acl->device_list[unpacked_lun];
se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun];
deve = se_cmd->se_deve;
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun;
dev = se_lun->lun_se_dev;
se_tmr->tmr_lun = deve->se_lun;
se_cmd->se_lun = deve->se_lun;
se_lun = deve->se_lun;
se_cmd->pr_res_key = deve->pr_res_key;
se_cmd->orig_fe_lun = unpacked_lun;
se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
/* se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; */
se_cmd->se_orig_obj_ptr = se_cmd->se_dev;
}
spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
......@@ -226,21 +212,24 @@ int transport_get_lun_for_tmr(
}
/*
* Determine if the struct se_lun is online.
* FIXME: Check for LUN_RESET + UNIT Attention
*/
/* #warning FIXME: Check for LUN_RESET + UNIT Attention */
if (se_dev_check_online(se_lun->lun_se_dev) != 0) {
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -ENODEV;
}
se_tmr->tmr_dev = dev;
spin_lock(&dev->se_tmr_lock);
list_add_tail(&se_tmr->tmr_list, &dev->dev_tmr_list);
spin_unlock(&dev->se_tmr_lock);
/* Directly associate cmd with se_dev */
se_cmd->se_dev = se_lun->lun_se_dev;
se_tmr->tmr_dev = se_lun->lun_se_dev;
spin_lock(&se_tmr->tmr_dev->se_tmr_lock);
list_add_tail(&se_tmr->tmr_list, &se_tmr->tmr_dev->dev_tmr_list);
spin_unlock(&se_tmr->tmr_dev->se_tmr_lock);
return 0;
}
EXPORT_SYMBOL(transport_get_lun_for_tmr);
EXPORT_SYMBOL(transport_lookup_tmr_lun);
/*
* This function is called from core_scsi3_emulate_pro_register_and_move()
......@@ -667,10 +656,10 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
struct se_lun *se_lun;
struct se_session *se_sess = se_cmd->se_sess;
struct se_task *se_task;
unsigned char *buf = se_cmd->t_task->t_task_buf;
unsigned char *buf = se_cmd->t_task.t_task_buf;
u32 cdb_offset = 0, lun_count = 0, offset = 8, i;
list_for_each_entry(se_task, &se_cmd->t_task->t_task_list, t_list)
list_for_each_entry(se_task, &se_cmd->t_task.t_task_list, t_list)
break;
if (!(se_task)) {
......
......@@ -223,7 +223,7 @@ static struct se_device *fd_create_virtdevice(
dev_limits.queue_depth = FD_DEVICE_QUEUE_DEPTH;
dev = transport_add_device_to_core_hba(hba, &fileio_template,
se_dev, dev_flags, (void *)fd_dev,
se_dev, dev_flags, fd_dev,
&dev_limits, "FILEIO", FD_VERSION);
if (!(dev))
goto fail;
......@@ -279,7 +279,7 @@ fd_alloc_task(struct se_cmd *cmd)
return NULL;
}
fd_req->fd_dev = cmd->se_lun->lun_se_dev->dev_ptr;
fd_req->fd_dev = cmd->se_dev->dev_ptr;
return &fd_req->fd_task;
}
......@@ -377,7 +377,7 @@ static void fd_emulate_sync_cache(struct se_task *task)
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev;
struct fd_dev *fd_dev = dev->dev_ptr;
int immed = (cmd->t_task->t_task_cdb[1] & 0x2);
int immed = (cmd->t_task.t_task_cdb[1] & 0x2);
loff_t start, end;
int ret;
......@@ -391,11 +391,11 @@ static void fd_emulate_sync_cache(struct se_task *task)
/*
* Determine if we will be flushing the entire device.
*/
if (cmd->t_task->t_task_lba == 0 && cmd->data_length == 0) {
if (cmd->t_task.t_task_lba == 0 && cmd->data_length == 0) {
start = 0;
end = LLONG_MAX;
} else {
start = cmd->t_task->t_task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
start = cmd->t_task.t_task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
if (cmd->data_length)
end = start + cmd->data_length;
else
......@@ -475,7 +475,7 @@ static int fd_do_task(struct se_task *task)
if (ret > 0 &&
dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 &&
cmd->t_task->t_tasks_fua) {
cmd->t_task.t_tasks_fua) {
/*
* We might need to be a bit smarter here
* and return some sense data to let the initiator
......
......@@ -74,7 +74,7 @@ static int iblock_attach_hba(struct se_hba *hba, u32 host_id)
ib_host->iblock_host_id = host_id;
hba->hba_ptr = (void *) ib_host;
hba->hba_ptr = ib_host;
printk(KERN_INFO "CORE_HBA[%d] - TCM iBlock HBA Driver %s on"
" Generic Target Core Stack %s\n", hba->hba_id,
......@@ -172,7 +172,7 @@ static struct se_device *iblock_create_virtdevice(
ib_dev->ibd_bd = bd;
dev = transport_add_device_to_core_hba(hba,
&iblock_template, se_dev, dev_flags, (void *)ib_dev,
&iblock_template, se_dev, dev_flags, ib_dev,
&dev_limits, "IBLOCK", IBLOCK_VERSION);
if (!(dev))
goto failed;
......@@ -240,7 +240,7 @@ iblock_alloc_task(struct se_cmd *cmd)
return NULL;
}
ib_req->ib_dev = cmd->se_lun->lun_se_dev->dev_ptr;
ib_req->ib_dev = cmd->se_dev->dev_ptr;
atomic_set(&ib_req->ib_bio_cnt, 0);
return &ib_req->ib_task;
}
......@@ -331,7 +331,7 @@ static void iblock_emulate_sync_cache(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr;
int immed = (cmd->t_task->t_task_cdb[1] & 0x2);
int immed = (cmd->t_task.t_task_cdb[1] & 0x2);
sector_t error_sector;
int ret;
......@@ -400,7 +400,7 @@ static int iblock_do_task(struct se_task *task)
*/
if (dev->se_sub_dev->se_dev_attrib.emulate_write_cache == 0 ||
(dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 &&
task->task_se_cmd->t_task->t_tasks_fua))
task->task_se_cmd->t_task.t_tasks_fua))
rw = WRITE_FUA;
else
rw = WRITE;
......@@ -593,7 +593,7 @@ static struct bio *iblock_get_bio(
DEBUG_IBLOCK("Allocated bio: %p task_size: %u\n", bio, task->task_size);
bio->bi_bdev = ib_dev->ibd_bd;
bio->bi_private = (void *) task;
bio->bi_private = task;
bio->bi_destructor = iblock_bio_destructor;
bio->bi_end_io = &iblock_bio_done;
bio->bi_sector = lba;
......@@ -608,7 +608,7 @@ static struct bio *iblock_get_bio(
static int iblock_map_task_SG(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
struct iblock_dev *ib_dev = task->se_dev->dev_ptr;
struct iblock_req *ib_req = IBLOCK_REQ(task);
struct bio *bio = NULL, *hbio = NULL, *tbio = NULL;
......
This diff is collapsed.
......@@ -72,7 +72,7 @@ static int pscsi_attach_hba(struct se_hba *hba, u32 host_id)
phv->phv_host_id = host_id;
phv->phv_mode = PHV_VIRUTAL_HOST_ID;
hba->hba_ptr = (void *)phv;
hba->hba_ptr = phv;
printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on"
" Generic Target Core Stack %s\n", hba->hba_id,
......@@ -355,7 +355,7 @@ static struct se_device *pscsi_add_device_to_list(
pdv->pdv_sd = sd;
dev = transport_add_device_to_core_hba(hba, &pscsi_template,
se_dev, dev_flags, (void *)pdv,
se_dev, dev_flags, pdv,
&dev_limits, NULL, NULL);
if (!(dev)) {
pdv->pdv_sd = NULL;
......@@ -394,7 +394,7 @@ static void *pscsi_allocate_virtdevice(struct se_hba *hba, const char *name)
pdv->pdv_se_hba = hba;
printk(KERN_INFO "PSCSI: Allocated pdv: %p for %s\n", pdv, name);
return (void *)pdv;
return pdv;
}
/*
......@@ -697,7 +697,7 @@ static int pscsi_transport_complete(struct se_task *task)
if (task->task_se_cmd->se_deve->lun_flags &
TRANSPORT_LUNFLAGS_READ_ONLY) {
unsigned char *buf = task->task_se_cmd->t_task->t_task_buf;
unsigned char *buf = task->task_se_cmd->t_task.t_task_buf;
if (cdb[0] == MODE_SENSE_10) {
if (!(buf[3] & 0x80))
......@@ -763,7 +763,7 @@ static struct se_task *
pscsi_alloc_task(struct se_cmd *cmd)
{
struct pscsi_plugin_task *pt;
unsigned char *cdb = cmd->t_task->t_task_cdb;
unsigned char *cdb = cmd->t_task.t_task_cdb;
pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL);
if (!pt) {
......@@ -776,7 +776,7 @@ pscsi_alloc_task(struct se_cmd *cmd)
* allocate the extended CDB buffer for per struct se_task context
* pt->pscsi_cdb now.
*/
if (cmd->t_task->t_task_cdb != cmd->t_task->__t_task_cdb) {
if (cmd->t_task.t_task_cdb != cmd->t_task.__t_task_cdb) {
pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL);
if (!(pt->pscsi_cdb)) {
......@@ -812,7 +812,7 @@ static inline void pscsi_blk_init_request(
* also set the end_io_data pointer.to struct se_task.
*/
req->end_io = pscsi_req_done;
req->end_io_data = (void *)task;
req->end_io_data = task;
/*
* Load the referenced struct se_task's SCSI CDB into
* include/linux/blkdev.h:struct request->cmd
......@@ -822,7 +822,7 @@ static inline void pscsi_blk_init_request(
/*
* Setup pointer for outgoing sense data.
*/
req->sense = (void *)&pt->pscsi_sense[0];
req->sense = &pt->pscsi_sense[0];
req->sense_len = 0;
}
......@@ -889,7 +889,7 @@ static void pscsi_free_task(struct se_task *task)
* Release the extended CDB allocation from pscsi_alloc_task()
* if one exists.
*/
if (cmd->t_task->t_task_cdb != cmd->t_task->__t_task_cdb)
if (cmd->t_task.t_task_cdb != cmd->t_task.__t_task_cdb)
kfree(pt->pscsi_cdb);
/*
* We do not release the bio(s) here associated with this task, as
......@@ -1266,7 +1266,7 @@ static int pscsi_map_task_non_SG(struct se_task *task)
return 0;
ret = blk_rq_map_kern(pdv->pdv_sd->request_queue,
pt->pscsi_req, cmd->t_task->t_task_buf,
pt->pscsi_req, cmd->t_task.t_task_buf,
task->task_size, GFP_KERNEL);
if (ret < 0) {
printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret);
......
......@@ -66,7 +66,7 @@ static int rd_attach_hba(struct se_hba *hba, u32 host_id)
rd_host->rd_host_id = host_id;
hba->hba_ptr = (void *) rd_host;
hba->hba_ptr = rd_host;
printk(KERN_INFO "CORE_HBA[%d] - TCM Ramdisk HBA Driver %s on"
" Generic Target Core Stack %s\n", hba->hba_id,
......@@ -271,7 +271,7 @@ static struct se_device *rd_create_virtdevice(
dev = transport_add_device_to_core_hba(hba,
(rd_dev->rd_direct) ? &rd_dr_template :
&rd_mcp_template, se_dev, dev_flags, (void *)rd_dev,
&rd_mcp_template, se_dev, dev_flags, rd_dev,
&dev_limits, prod, rev);
if (!(dev))
goto fail;
......@@ -336,7 +336,7 @@ rd_alloc_task(struct se_cmd *cmd)
printk(KERN_ERR "Unable to allocate struct rd_request\n");
return NULL;
}
rd_req->rd_dev = cmd->se_lun->lun_se_dev->dev_ptr;
rd_req->rd_dev = cmd->se_dev->dev_ptr;
return &rd_req->rd_task;
}
......@@ -737,7 +737,7 @@ static int rd_DIRECT_with_offset(
}
out:
task->task_se_cmd->t_task->t_tasks_se_num += *se_mem_cnt;
task->task_se_cmd->t_task.t_tasks_se_num += *se_mem_cnt;
#ifdef DEBUG_RAMDISK_DR
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
*se_mem_cnt);
......@@ -819,7 +819,7 @@ static int rd_DIRECT_without_offset(
}
out:
task->task_se_cmd->t_task->t_tasks_se_num += *se_mem_cnt;
task->task_se_cmd->t_task.t_tasks_se_num += *se_mem_cnt;
#ifdef DEBUG_RAMDISK_DR
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
*se_mem_cnt);
......@@ -880,14 +880,14 @@ static int rd_DIRECT_do_se_mem_map(
* across multiple struct se_task->task_sg[].
*/
ret = transport_init_task_sg(task,
list_entry(cmd->t_task->t_mem_list->next,
list_first_entry(&cmd->t_task.t_mem_list,
struct se_mem, se_list),
task_offset);
if (ret <= 0)
return ret;
return transport_map_mem_to_sg(task, se_mem_list, task->task_sg,
list_entry(cmd->t_task->t_mem_list->next,
list_first_entry(&cmd->t_task.t_mem_list,
struct se_mem, se_list),
out_se_mem, se_mem_cnt, task_offset_in);
}
......
......@@ -113,15 +113,14 @@ int core_tmr_lun_reset(
struct list_head *preempt_and_abort_list,
struct se_cmd *prout_cmd)
{
struct se_cmd *cmd;
struct se_queue_req *qr, *qr_tmp;
struct se_cmd *cmd, *tcmd;
struct se_node_acl *tmr_nacl = NULL;
struct se_portal_group *tmr_tpg = NULL;
struct se_queue_obj *qobj = &dev->dev_queue_obj;
struct se_tmr_req *tmr_p, *tmr_pp;
struct se_task *task, *task_tmp;
unsigned long flags;
int fe_count, state, tas;
int fe_count, tas;
/*
* TASK_ABORTED status bit, this is configurable via ConfigFS
* struct se_device attributes. spc4r17 section 7.4.6 Control mode page
......@@ -179,14 +178,14 @@ int core_tmr_lun_reset(
continue;
spin_unlock(&dev->se_tmr_lock);
spin_lock_irqsave(&cmd->t_task->t_state_lock, flags);
if (!(atomic_read(&cmd->t_task->t_transport_active))) {
spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
if (!(atomic_read(&cmd->t_task.t_transport_active))) {
spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
spin_lock(&dev->se_tmr_lock);
continue;
}
if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) {
spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
spin_lock(&dev->se_tmr_lock);
continue;
}
......@@ -194,7 +193,7 @@ int core_tmr_lun_reset(
" Response: 0x%02x, t_state: %d\n",
(preempt_and_abort_list) ? "Preempt" : "", tmr_p,
tmr_p->function, tmr_p->response, cmd->t_state);
spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
transport_cmd_finish_abort_tmr(cmd);
spin_lock(&dev->se_tmr_lock);
......@@ -230,12 +229,6 @@ int core_tmr_lun_reset(
}
cmd = task->task_se_cmd;
if (!cmd->t_task) {
printk(KERN_ERR "cmd->t_task is NULL for task: %p cmd:"
" %p ITT: 0x%08x\n", task, cmd,
cmd->se_tfo->get_task_tag(cmd));
continue;
}
/*
* For PREEMPT_AND_ABORT usage, only process commands
* with a matching reservation key.
......@@ -254,38 +247,38 @@ int core_tmr_lun_reset(
atomic_set(&task->task_state_active, 0);
spin_unlock_irqrestore(&dev->execute_task_lock, flags);
spin_lock_irqsave(&cmd->t_task->t_state_lock, flags);
spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
DEBUG_LR("LUN_RESET: %s cmd: %p task: %p"
" ITT/CmdSN: 0x%08x/0x%08x, i_state: %d, t_state/"
"def_t_state: %d/%d cdb: 0x%02x\n",
(preempt_and_abort_list) ? "Preempt" : "", cmd, task,
cmd->se_tfo->get_task_tag(cmd), 0,
cmd->se_tfo->get_cmd_state(cmd), cmd->t_state,
cmd->deferred_t_state, cmd->t_task->t_task_cdb[0]);
cmd->deferred_t_state, cmd->t_task.t_task_cdb[0]);
DEBUG_LR("LUN_RESET: ITT[0x%08x] - pr_res_key: 0x%016Lx"
" 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->pr_res_key,
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.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));
if (atomic_read(&task->task_active)) {
atomic_set(&task->task_stop, 1);
spin_unlock_irqrestore(
&cmd->t_task->t_state_lock, flags);
&cmd->t_task.t_state_lock, flags);
DEBUG_LR("LUN_RESET: Waiting for task: %p to shutdown"
" for dev: %p\n", task, dev);
wait_for_completion(&task->task_stop_comp);
DEBUG_LR("LUN_RESET 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_task.t_state_lock, flags);
atomic_dec(&cmd->t_task.t_task_cdbs_left);
atomic_set(&task->task_active, 0);
atomic_set(&task->task_stop, 0);
......@@ -295,24 +288,24 @@ int core_tmr_lun_reset(
}
__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.t_task_cdbs_ex_left))) {
spin_unlock_irqrestore(
&cmd->t_task->t_state_lock, flags);
&cmd->t_task.t_state_lock, flags);
DEBUG_LR("LUN_RESET: 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.t_task_cdbs_ex_left));
spin_lock_irqsave(&dev->execute_task_lock, flags);
continue;
}
fe_count = atomic_read(&cmd->t_task->t_fe_count);
fe_count = atomic_read(&cmd->t_task.t_fe_count);
if (atomic_read(&cmd->t_task->t_transport_active)) {
if (atomic_read(&cmd->t_task.t_transport_active)) {
DEBUG_LR("LUN_RESET: got t_transport_active = 1 for"
" task: %p, t_fe_count: %d dev: %p\n", task,
fe_count, dev);
atomic_set(&cmd->t_task->t_transport_aborted, 1);
spin_unlock_irqrestore(&cmd->t_task->t_state_lock,
atomic_set(&cmd->t_task.t_transport_aborted, 1);
spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
flags);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
......@@ -321,8 +314,8 @@ int core_tmr_lun_reset(
}
DEBUG_LR("LUN_RESET: Got t_transport_active = 0 for task: %p,"
" t_fe_count: %d dev: %p\n", task, fe_count, dev);
atomic_set(&cmd->t_task->t_transport_aborted, 1);
spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
atomic_set(&cmd->t_task.t_transport_aborted, 1);
spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
spin_lock_irqsave(&dev->execute_task_lock, flags);
......@@ -337,20 +330,7 @@ int core_tmr_lun_reset(
* reference, otherwise the struct se_cmd is released.
*/
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
list_for_each_entry_safe(qr, qr_tmp, &qobj->qobj_list, qr_list) {
cmd = (struct se_cmd *)qr->cmd;
if (!(cmd)) {
/*
* Skip these for non PREEMPT_AND_ABORT usage..
*/
if (preempt_and_abort_list != NULL)
continue;
atomic_dec(&qobj->queue_cnt);
list_del(&qr->qr_list);
kfree(qr);
continue;
}
list_for_each_entry_safe(cmd, tcmd, &qobj->qobj_list, se_queue_node) {
/*
* For PREEMPT_AND_ABORT usage, only process commands
* with a matching reservation key.
......@@ -365,18 +345,15 @@ int core_tmr_lun_reset(
if (prout_cmd == cmd)
continue;
atomic_dec(&cmd->t_task->t_transport_queue_active);
atomic_dec(&cmd->t_task.t_transport_queue_active);
atomic_dec(&qobj->queue_cnt);
list_del(&qr->qr_list);
list_del(&cmd->se_queue_node);
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
state = qr->state;
kfree(qr);
DEBUG_LR("LUN_RESET: %s from Device Queue: cmd: %p t_state:"
" %d t_fe_count: %d\n", (preempt_and_abort_list) ?
"Preempt" : "", cmd, state,
atomic_read(&cmd->t_task->t_fe_count));
"Preempt" : "", cmd, cmd->t_state,
atomic_read(&cmd->t_task.t_fe_count));
/*
* Signal that the command has failed via cmd->se_cmd_flags,
* and call TFO->new_cmd_failure() to wakeup any fabric
......@@ -388,7 +365,7 @@ int core_tmr_lun_reset(
transport_new_cmd_failure(cmd);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas,
atomic_read(&cmd->t_task->t_fe_count));
atomic_read(&cmd->t_task.t_fe_count));
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
}
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
......
This diff is collapsed.
......@@ -208,7 +208,7 @@ void core_scsi3_ua_for_check_condition(
u8 *asc,
u8 *ascq)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
struct se_dev_entry *deve;
struct se_session *sess = cmd->se_sess;
struct se_node_acl *nacl;
......@@ -270,7 +270,7 @@ void core_scsi3_ua_for_check_condition(
nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
(dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
"Releasing", dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl,
cmd->orig_fe_lun, cmd->t_task->t_task_cdb[0], *asc, *ascq);
cmd->orig_fe_lun, cmd->t_task.t_task_cdb[0], *asc, *ascq);
}
int core_scsi3_ua_clear_for_request_sense(
......
......@@ -72,12 +72,12 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
caller, cmd, cmd->cdb);
printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
task = se_cmd->t_task;
task = &se_cmd->t_task;
printk(KERN_INFO "%s: cmd %p task %p se_num %u buf %p len %u se_cmd_flags <0x%x>\n",
caller, cmd, task, task->t_tasks_se_num,
task->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags);
if (task->t_mem_list)
list_for_each_entry(mem, task->t_mem_list, se_list)
list_for_each_entry(mem, &task->t_mem_list, se_list)
printk(KERN_INFO "%s: cmd %p mem %p page %p "
"len 0x%x off 0x%x\n",
caller, cmd, mem,
......@@ -262,9 +262,9 @@ int ft_write_pending(struct se_cmd *se_cmd)
* TCM/LIO target
*/
transport_do_task_sg_chain(se_cmd);
cmd->sg = se_cmd->t_task->t_tasks_sg_chained;
cmd->sg = se_cmd->t_task.t_tasks_sg_chained;
cmd->sg_cnt =
se_cmd->t_task->t_tasks_sg_chained_no;
se_cmd->t_task.t_tasks_sg_chained_no;
}
if (cmd->sg && lport->tt.ddp_setup(lport, ep->xid,
cmd->sg, cmd->sg_cnt))
......@@ -438,7 +438,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
switch (fcp->fc_tm_flags) {
case FCP_TMF_LUN_RESET:
cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
if (transport_get_lun_for_tmr(&cmd->se_cmd, cmd->lun) < 0) {
if (transport_lookup_tmr_lun(&cmd->se_cmd, cmd->lun) < 0) {
/*
* Make sure to clean up newly allocated TMR request
* since "unable to handle TMR request because failed
......@@ -637,7 +637,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd);
cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
ret = transport_get_lun_for_cmd(&cmd->se_cmd, cmd->lun);
ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun);
if (ret < 0) {
ft_dump_cmd(cmd, __func__);
transport_send_check_condition_and_sense(&cmd->se_cmd,
......@@ -650,13 +650,13 @@ static void ft_send_cmd(struct ft_cmd *cmd)
FT_IO_DBG("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret);
ft_dump_cmd(cmd, __func__);
if (ret == -1) {
if (ret == -ENOMEM) {
transport_send_check_condition_and_sense(se_cmd,
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
transport_generic_free_cmd(se_cmd, 0, 1, 0);
return;
}
if (ret == -2) {
if (ret == -EINVAL) {
if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
ft_queue_status(se_cmd);
else
......
......@@ -331,7 +331,7 @@ static struct se_portal_group *ft_add_tpg(
transport_init_queue_obj(&tpg->qobj);
ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg,
(void *)tpg, TRANSPORT_TPG_TYPE_NORMAL);
tpg, TRANSPORT_TPG_TYPE_NORMAL);
if (ret < 0) {
kfree(tpg);
return NULL;
......
......@@ -90,15 +90,14 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
lport = ep->lp;
cmd->seq = lport->tt.seq_start_next(cmd->seq);
task = se_cmd->t_task;
BUG_ON(!task);
task = &se_cmd->t_task;
remaining = se_cmd->data_length;
/*
* Setup to use first mem list entry if any.
*/
if (task->t_tasks_se_num) {
mem = list_first_entry(task->t_mem_list,
mem = list_first_entry(&task->t_mem_list,
struct se_mem, se_list);
mem_len = mem->se_len;
mem_off = mem->se_off;
......@@ -236,8 +235,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
u32 f_ctl;
void *buf;
task = se_cmd->t_task;
BUG_ON(!task);
task = &se_cmd->t_task;
fh = fc_frame_header_get(fp);
if (!(ntoh24(fh->fh_f_ctl) & FC_FC_REL_OFF))
......@@ -315,7 +313,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
* Setup to use first mem list entry if any.
*/
if (task->t_tasks_se_num) {
mem = list_first_entry(task->t_mem_list,
mem = list_first_entry(&task->t_mem_list,
struct se_mem, se_list);
mem_len = mem->se_len;
mem_off = mem->se_off;
......
......@@ -123,7 +123,7 @@ enum se_cmd_flags_table {
SCF_SENT_DELAYED_TAS = 0x00020000,
SCF_ALUA_NON_OPTIMIZED = 0x00040000,
SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
SCF_PASSTHROUGH_SG_TO_MEM = 0x00100000,
SCF_UNUSED = 0x00100000,
SCF_PASSTHROUGH_CONTIG_TO_SG = 0x00200000,
SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,
SCF_EMULATE_SYNC_CACHE = 0x00800000,
......@@ -452,9 +452,9 @@ struct se_transport_task {
* and other HW target mode fabric modules.
*/
struct scatterlist *t_task_pt_sgl;
struct list_head *t_mem_list;
struct list_head t_mem_list;
/* Used for BIDI READ */
struct list_head *t_mem_bidi_list;
struct list_head t_mem_bidi_list;
struct list_head t_task_list;
} ____cacheline_aligned;
......@@ -523,9 +523,9 @@ struct se_cmd {
atomic_t transport_sent;
/* Used for sense data */
void *sense_buffer;
struct list_head se_delayed_list;
struct list_head se_ordered_list;
struct list_head se_lun_list;
struct list_head se_delayed_node;
struct list_head se_ordered_node;
struct list_head se_lun_node;
struct se_device *se_dev;
struct se_dev_entry *se_deve;
struct se_device *se_obj_ptr;
......@@ -534,9 +534,8 @@ struct se_cmd {
/* Only used for internal passthrough and legacy TCM fabric modules */
struct se_session *se_sess;
struct se_tmr_req *se_tmr_req;
/* t_task is setup to t_task_backstore in transport_init_se_cmd() */
struct se_transport_task *t_task;
struct se_transport_task t_task_backstore;
struct se_transport_task t_task;
struct list_head se_queue_node;
struct target_core_fabric_ops *se_tfo;
int (*transport_emulate_cdb)(struct se_cmd *);
void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);
......
#ifndef TARGET_CORE_DEVICE_H
#define TARGET_CORE_DEVICE_H
extern int transport_get_lun_for_cmd(struct se_cmd *, u32);
extern int transport_get_lun_for_tmr(struct se_cmd *, u32);
extern int transport_lookup_cmd_lun(struct se_cmd *, u32);
extern int transport_lookup_tmr_lun(struct se_cmd *, u32);
extern struct se_dev_entry *core_get_se_deve_from_rtpi(
struct se_node_acl *, u16);
extern int core_free_device_list_for_node(struct se_node_acl *,
......
......@@ -159,7 +159,6 @@ extern struct se_device *transport_add_device_to_core_hba(struct se_hba *,
struct se_subsystem_dev *, u32,
void *, struct se_dev_limits *,
const char *, const char *);
extern void transport_device_setup_cmd(struct se_cmd *);
extern void transport_init_se_cmd(struct se_cmd *,
struct target_core_fabric_ops *,
struct se_session *, u32, int, int,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment