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: Andy Grover <agrover@redhat.com> Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
f22c119683
commit
5951146dea
19 changed files with 769 additions and 949 deletions
|
@ -118,17 +118,16 @@ static struct se_cmd *tcm_loop_allocate_core_cmd(
|
||||||
* Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi
|
* Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi
|
||||||
*/
|
*/
|
||||||
if (scsi_bidi_cmnd(sc))
|
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
|
* 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);
|
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
|
||||||
set_host_byte(sc, DID_NO_CONNECT);
|
set_host_byte(sc, DID_NO_CONNECT);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
transport_device_setup_cmd(se_cmd);
|
|
||||||
return 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_cmd = container_of(se_cmd,
|
||||||
struct tcm_loop_cmd, tl_se_cmd);
|
struct tcm_loop_cmd, tl_se_cmd);
|
||||||
struct scsi_cmnd *sc = tl_cmd->sc;
|
struct scsi_cmnd *sc = tl_cmd->sc;
|
||||||
void *mem_ptr, *mem_bidi_ptr = NULL;
|
struct scatterlist *sgl_bidi = NULL;
|
||||||
u32 sg_no_bidi = 0;
|
u32 sgl_bidi_count = 0;
|
||||||
int ret;
|
int ret;
|
||||||
/*
|
/*
|
||||||
* Allocate the necessary tasks to complete the received CDB+data
|
* Allocate the necessary tasks to complete the received CDB+data
|
||||||
*/
|
*/
|
||||||
ret = transport_generic_allocate_tasks(se_cmd, tl_cmd->sc->cmnd);
|
ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd);
|
||||||
if (ret == -1) {
|
if (ret == -ENOMEM) {
|
||||||
/* Out of Resources */
|
/* Out of Resources */
|
||||||
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
||||||
} else if (ret == -2) {
|
} else if (ret == -EINVAL) {
|
||||||
/*
|
/*
|
||||||
* Handle case for SAM_STAT_RESERVATION_CONFLICT
|
* 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;
|
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) {
|
|
||||||
struct scsi_data_buffer *sdb = scsi_in(sc);
|
|
||||||
|
|
||||||
mem_bidi_ptr = (void *)sdb->table.sgl;
|
/*
|
||||||
sg_no_bidi = sdb->table.nents;
|
* For BIDI commands, pass in the extra READ buffer
|
||||||
}
|
* to transport_generic_map_mem_to_cmd() below..
|
||||||
} else {
|
*/
|
||||||
/*
|
if (se_cmd->t_task.t_tasks_bidi) {
|
||||||
* Used for DMA_NONE
|
struct scsi_data_buffer *sdb = scsi_in(sc);
|
||||||
*/
|
|
||||||
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
|
* Map the SG memory into struct se_mem->page linked list using the same
|
||||||
* physical memory at sg->page_link.
|
* physical memory at sg->page_link.
|
||||||
*/
|
*/
|
||||||
ret = transport_generic_map_mem_to_cmd(se_cmd, mem_ptr,
|
ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc),
|
||||||
scsi_sg_count(sc), mem_bidi_ptr, sg_no_bidi);
|
scsi_sg_count(sc), sgl_bidi, sgl_bidi_count);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
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
|
* 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);
|
TMR_LUN_RESET);
|
||||||
if (IS_ERR(se_cmd->se_tmr_req))
|
if (IS_ERR(se_cmd->se_tmr_req))
|
||||||
goto release;
|
goto release;
|
||||||
/*
|
/*
|
||||||
* Locate the underlying TCM struct se_lun from sc->device->lun
|
* 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;
|
goto release;
|
||||||
/*
|
/*
|
||||||
* Queue the TMR to TCM Core and sleep waiting for tcm_loop_queue_tm_rsp()
|
* 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_TRANSPORT_TASK_SENSE) ||
|
||||||
(se_cmd->se_cmd_flags & SCF_EMULATED_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);
|
SCSI_SENSE_BUFFERSIZE);
|
||||||
sc->result = SAM_STAT_CHECK_CONDITION;
|
sc->result = SAM_STAT_CHECK_CONDITION;
|
||||||
set_driver_byte(sc, DRIVER_SENSE);
|
set_driver_byte(sc, DRIVER_SENSE);
|
||||||
|
@ -1054,7 +1042,7 @@ static int tcm_loop_make_nexus(
|
||||||
* transport_register_session()
|
* transport_register_session()
|
||||||
*/
|
*/
|
||||||
__transport_register_session(se_tpg, tl_nexus->se_sess->se_node_acl,
|
__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;
|
tl_tpg->tl_hba->tl_nexus = tl_nexus;
|
||||||
printk(KERN_INFO "TCM_Loop_ConfigFS: Established I_T Nexus to emulated"
|
printk(KERN_INFO "TCM_Loop_ConfigFS: Established I_T Nexus to emulated"
|
||||||
" %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba),
|
" %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
|
* Register the tl_tpg as a emulated SAS TCM Target Endpoint
|
||||||
*/
|
*/
|
||||||
ret = core_tpg_register(&tcm_loop_fabric_configfs->tf_ops,
|
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);
|
TRANSPORT_TPG_TYPE_NORMAL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ERR_PTR(-ENOMEM);
|
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)
|
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 se_port *port;
|
||||||
struct t10_alua_tg_pt_gp *tg_pt_gp;
|
struct t10_alua_tg_pt_gp *tg_pt_gp;
|
||||||
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
|
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
|
u32 rd_len = 0, off = 4; /* Skip over RESERVED area to first
|
||||||
Target port group descriptor */
|
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)
|
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_subsystem_dev *su_dev = dev->se_sub_dev;
|
||||||
struct se_port *port, *l_port = cmd->se_lun->lun_sep;
|
struct se_port *port, *l_port = cmd->se_lun->lun_sep;
|
||||||
struct se_node_acl *nacl = cmd->se_sess->se_node_acl;
|
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 *tg_pt_gp = NULL, *l_tg_pt_gp;
|
||||||
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, *l_tg_pt_gp_mem;
|
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 */
|
unsigned char *ptr = &buf[4]; /* Skip over RESERVED area in header */
|
||||||
u32 len = 4; /* Skip over RESERVED area in header */
|
u32 len = 4; /* Skip over RESERVED area in header */
|
||||||
int alua_access_state, primary = 0, rc;
|
int alua_access_state, primary = 0, rc;
|
||||||
|
|
|
@ -65,8 +65,8 @@ static int
|
||||||
target_emulate_inquiry_std(struct se_cmd *cmd)
|
target_emulate_inquiry_std(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_lun *lun = cmd->se_lun;
|
struct se_lun *lun = cmd->se_lun;
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
unsigned char *buf = cmd->t_task->t_task_buf;
|
unsigned char *buf = cmd->t_task.t_task_buf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we at least have 6 bytes of INQUIRY response
|
* 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
|
* Registered Extended LUN WWN has been set via ConfigFS
|
||||||
* during device creation/restart.
|
* 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) {
|
SDF_EMULATED_VPD_UNIT_SERIAL) {
|
||||||
buf[3] = 3;
|
buf[3] = 3;
|
||||||
buf[5] = 0x80;
|
buf[5] = 0x80;
|
||||||
|
@ -143,7 +143,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
|
||||||
static int
|
static int
|
||||||
target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
|
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;
|
u16 len = 0;
|
||||||
|
|
||||||
buf[1] = 0x80;
|
buf[1] = 0x80;
|
||||||
|
@ -176,7 +176,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
|
||||||
static int
|
static int
|
||||||
target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
|
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_lun *lun = cmd->se_lun;
|
||||||
struct se_port *port = NULL;
|
struct se_port *port = NULL;
|
||||||
struct se_portal_group *tpg = 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;
|
buf[5] = 0x07;
|
||||||
|
|
||||||
/* If WriteCache emulation is enabled, set V_SUP */
|
/* 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;
|
buf[6] = 0x01;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
|
||||||
static int
|
static int
|
||||||
target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
|
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;
|
int have_tp = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -568,7 +568,7 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
|
||||||
static int
|
static int
|
||||||
target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
|
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:
|
* 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
|
static int
|
||||||
target_emulate_inquiry(struct se_cmd *cmd)
|
target_emulate_inquiry(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
unsigned char *buf = cmd->t_task->t_task_buf;
|
unsigned char *buf = cmd->t_task.t_task_buf;
|
||||||
unsigned char *cdb = cmd->t_task->t_task_cdb;
|
unsigned char *cdb = cmd->t_task.t_task_cdb;
|
||||||
|
|
||||||
if (!(cdb[1] & 0x1))
|
if (!(cdb[1] & 0x1))
|
||||||
return target_emulate_inquiry_std(cmd);
|
return target_emulate_inquiry_std(cmd);
|
||||||
|
@ -665,8 +665,8 @@ target_emulate_inquiry(struct se_cmd *cmd)
|
||||||
static int
|
static int
|
||||||
target_emulate_readcapacity(struct se_cmd *cmd)
|
target_emulate_readcapacity(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
unsigned char *buf = cmd->t_task->t_task_buf;
|
unsigned char *buf = cmd->t_task.t_task_buf;
|
||||||
unsigned long long blocks_long = dev->transport->get_blocks(dev);
|
unsigned long long blocks_long = dev->transport->get_blocks(dev);
|
||||||
u32 blocks;
|
u32 blocks;
|
||||||
|
|
||||||
|
@ -695,8 +695,8 @@ target_emulate_readcapacity(struct se_cmd *cmd)
|
||||||
static int
|
static int
|
||||||
target_emulate_readcapacity_16(struct se_cmd *cmd)
|
target_emulate_readcapacity_16(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
unsigned char *buf = cmd->t_task->t_task_buf;
|
unsigned char *buf = cmd->t_task.t_task_buf;
|
||||||
unsigned long long blocks = dev->transport->get_blocks(dev);
|
unsigned long long blocks = dev->transport->get_blocks(dev);
|
||||||
|
|
||||||
buf[0] = (blocks >> 56) & 0xff;
|
buf[0] = (blocks >> 56) & 0xff;
|
||||||
|
@ -830,9 +830,9 @@ target_modesense_dpofua(unsigned char *buf, int type)
|
||||||
static int
|
static int
|
||||||
target_emulate_modesense(struct se_cmd *cmd, int ten)
|
target_emulate_modesense(struct se_cmd *cmd, int ten)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
char *cdb = cmd->t_task->t_task_cdb;
|
char *cdb = cmd->t_task.t_task_cdb;
|
||||||
unsigned char *rbuf = cmd->t_task->t_task_buf;
|
unsigned char *rbuf = cmd->t_task.t_task_buf;
|
||||||
int type = dev->transport->get_device_type(dev);
|
int type = dev->transport->get_device_type(dev);
|
||||||
int offset = (ten) ? 8 : 4;
|
int offset = (ten) ? 8 : 4;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
@ -903,8 +903,8 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
|
||||||
static int
|
static int
|
||||||
target_emulate_request_sense(struct se_cmd *cmd)
|
target_emulate_request_sense(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
unsigned char *cdb = cmd->t_task->t_task_cdb;
|
unsigned char *cdb = cmd->t_task.t_task_cdb;
|
||||||
unsigned char *buf = cmd->t_task->t_task_buf;
|
unsigned char *buf = cmd->t_task.t_task_buf;
|
||||||
u8 ua_asc = 0, ua_ascq = 0;
|
u8 ua_asc = 0, ua_ascq = 0;
|
||||||
|
|
||||||
if (cdb[1] & 0x01) {
|
if (cdb[1] & 0x01) {
|
||||||
|
@ -964,9 +964,9 @@ static int
|
||||||
target_emulate_unmap(struct se_task *task)
|
target_emulate_unmap(struct se_task *task)
|
||||||
{
|
{
|
||||||
struct se_cmd *cmd = task->task_se_cmd;
|
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 char *buf = cmd->t_task->t_task_buf, *ptr = NULL;
|
unsigned char *buf = cmd->t_task.t_task_buf, *ptr = NULL;
|
||||||
unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
|
unsigned char *cdb = &cmd->t_task.t_task_cdb[0];
|
||||||
sector_t lba;
|
sector_t lba;
|
||||||
unsigned int size = cmd->data_length, range;
|
unsigned int size = cmd->data_length, range;
|
||||||
int ret, offset;
|
int ret, offset;
|
||||||
|
@ -1011,8 +1011,8 @@ static int
|
||||||
target_emulate_write_same(struct se_task *task)
|
target_emulate_write_same(struct se_task *task)
|
||||||
{
|
{
|
||||||
struct se_cmd *cmd = task->task_se_cmd;
|
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;
|
||||||
sector_t lba = cmd->t_task->t_task_lba;
|
sector_t lba = cmd->t_task.t_task_lba;
|
||||||
unsigned int range;
|
unsigned int range;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1036,11 +1036,11 @@ int
|
||||||
transport_emulate_control_cdb(struct se_task *task)
|
transport_emulate_control_cdb(struct se_task *task)
|
||||||
{
|
{
|
||||||
struct se_cmd *cmd = task->task_se_cmd;
|
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;
|
unsigned short service_action;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
switch (cmd->t_task->t_task_cdb[0]) {
|
switch (cmd->t_task.t_task_cdb[0]) {
|
||||||
case INQUIRY:
|
case INQUIRY:
|
||||||
ret = target_emulate_inquiry(cmd);
|
ret = target_emulate_inquiry(cmd);
|
||||||
break;
|
break;
|
||||||
|
@ -1054,13 +1054,13 @@ transport_emulate_control_cdb(struct se_task *task)
|
||||||
ret = target_emulate_modesense(cmd, 1);
|
ret = target_emulate_modesense(cmd, 1);
|
||||||
break;
|
break;
|
||||||
case SERVICE_ACTION_IN:
|
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:
|
case SAI_READ_CAPACITY_16:
|
||||||
ret = target_emulate_readcapacity_16(cmd);
|
ret = target_emulate_readcapacity_16(cmd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR "Unsupported SA: 0x%02x\n",
|
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;
|
return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1085,7 +1085,7 @@ transport_emulate_control_cdb(struct se_task *task)
|
||||||
break;
|
break;
|
||||||
case VARIABLE_LENGTH_CMD:
|
case VARIABLE_LENGTH_CMD:
|
||||||
service_action =
|
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) {
|
switch (service_action) {
|
||||||
case WRITE_SAME_32:
|
case WRITE_SAME_32:
|
||||||
if (!dev->transport->do_discard) {
|
if (!dev->transport->do_discard) {
|
||||||
|
@ -1124,7 +1124,7 @@ transport_emulate_control_cdb(struct se_task *task)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR "Unsupported SCSI Opcode: 0x%02x for %s\n",
|
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;
|
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))
|
if (!(tc_attr->show))
|
||||||
return -EINVAL;
|
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,
|
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))
|
if (!(tc_attr->store))
|
||||||
return -EINVAL;
|
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 = {
|
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 */
|
/* not static, needed by tpg.c */
|
||||||
struct se_device *g_lun0_dev;
|
struct se_device *g_lun0_dev;
|
||||||
|
|
||||||
int transport_get_lun_for_cmd(
|
int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
|
||||||
struct se_cmd *se_cmd,
|
|
||||||
u32 unpacked_lun)
|
|
||||||
{
|
{
|
||||||
struct se_dev_entry *deve;
|
|
||||||
struct se_lun *se_lun = NULL;
|
struct se_lun *se_lun = NULL;
|
||||||
struct se_session *se_sess = se_cmd->se_sess;
|
struct se_session *se_sess = se_cmd->se_sess;
|
||||||
|
struct se_device *dev;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int read_only = 0;
|
|
||||||
|
|
||||||
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
|
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
|
||||||
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
|
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
|
||||||
|
@ -76,91 +73,87 @@ int transport_get_lun_for_cmd(
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
|
spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
|
||||||
deve = se_cmd->se_deve =
|
se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun];
|
||||||
&se_sess->se_node_acl->device_list[unpacked_lun];
|
if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
|
||||||
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
|
struct se_dev_entry *deve = se_cmd->se_deve;
|
||||||
if (se_cmd) {
|
|
||||||
deve->total_cmds++;
|
|
||||||
deve->total_bytes += se_cmd->data_length;
|
|
||||||
|
|
||||||
if (se_cmd->data_direction == DMA_TO_DEVICE) {
|
deve->total_cmds++;
|
||||||
if (deve->lun_flags &
|
deve->total_bytes += se_cmd->data_length;
|
||||||
TRANSPORT_LUNFLAGS_READ_ONLY) {
|
|
||||||
read_only = 1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
deve->write_bytes += se_cmd->data_length;
|
|
||||||
} 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;
|
if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
|
||||||
se_cmd->pr_res_key = deve->pr_res_key;
|
(deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) {
|
||||||
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->scsi_sense_reason = TCM_WRITE_PROTECTED;
|
||||||
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
||||||
printk("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
|
printk("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
|
||||||
" Access for 0x%08x\n",
|
" Access for 0x%08x\n",
|
||||||
se_cmd->se_tfo->get_fabric_name(),
|
se_cmd->se_tfo->get_fabric_name(),
|
||||||
unpacked_lun);
|
unpacked_lun);
|
||||||
|
spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Use the se_portal_group->tpg_virt_lun0 to allow for
|
|
||||||
* REPORT_LUNS, et al to be returned when no active
|
|
||||||
* MappedLUN=0 exists for this Initiator Port.
|
|
||||||
*/
|
|
||||||
if (unpacked_lun != 0) {
|
|
||||||
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
|
|
||||||
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
|
||||||
printk("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
|
|
||||||
" Access for 0x%08x\n",
|
|
||||||
se_cmd->se_tfo->get_fabric_name(),
|
|
||||||
unpacked_lun);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Force WRITE PROTECT for virtual LUN 0
|
|
||||||
*/
|
|
||||||
if ((se_cmd->data_direction != DMA_FROM_DEVICE) &&
|
|
||||||
(se_cmd->data_direction != DMA_NONE)) {
|
|
||||||
se_cmd->scsi_sense_reason = TCM_WRITE_PROTECTED;
|
|
||||||
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_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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (se_cmd->data_direction == DMA_TO_DEVICE)
|
||||||
|
deve->write_bytes += se_cmd->data_length;
|
||||||
|
else if (se_cmd->data_direction == DMA_FROM_DEVICE)
|
||||||
|
deve->read_bytes += se_cmd->data_length;
|
||||||
|
|
||||||
|
deve->deve_cmds++;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
|
||||||
|
|
||||||
|
if (!se_lun) {
|
||||||
|
/*
|
||||||
|
* Use the se_portal_group->tpg_virt_lun0 to allow for
|
||||||
|
* REPORT_LUNS, et al to be returned when no active
|
||||||
|
* MappedLUN=0 exists for this Initiator Port.
|
||||||
|
*/
|
||||||
|
if (unpacked_lun != 0) {
|
||||||
|
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
|
||||||
|
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
||||||
|
printk("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
|
||||||
|
" Access for 0x%08x\n",
|
||||||
|
se_cmd->se_tfo->get_fabric_name(),
|
||||||
|
unpacked_lun);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Force WRITE PROTECT for virtual LUN 0
|
||||||
|
*/
|
||||||
|
if ((se_cmd->data_direction != DMA_FROM_DEVICE) &&
|
||||||
|
(se_cmd->data_direction != DMA_NONE)) {
|
||||||
|
se_cmd->scsi_sense_reason = TCM_WRITE_PROTECTED;
|
||||||
|
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
||||||
|
return -EACCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
* 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) {
|
if (se_dev_check_online(se_lun->lun_se_dev) != 0) {
|
||||||
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
|
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
|
||||||
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
/* Directly associate cmd with se_dev */
|
||||||
struct se_device *dev = se_lun->lun_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);
|
spin_lock_irq(&dev->stats_lock);
|
||||||
dev->num_cmds++;
|
dev->num_cmds++;
|
||||||
if (se_cmd->data_direction == DMA_TO_DEVICE)
|
if (se_cmd->data_direction == DMA_TO_DEVICE)
|
||||||
|
@ -168,30 +161,22 @@ out:
|
||||||
else if (se_cmd->data_direction == DMA_FROM_DEVICE)
|
else if (se_cmd->data_direction == DMA_FROM_DEVICE)
|
||||||
dev->read_bytes += se_cmd->data_length;
|
dev->read_bytes += se_cmd->data_length;
|
||||||
spin_unlock_irq(&dev->stats_lock);
|
spin_unlock_irq(&dev->stats_lock);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the iscsi_cmd_t to the struct se_lun's cmd list. This list is used
|
* 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.
|
* for tracking state of struct se_cmds during LUN shutdown events.
|
||||||
*/
|
*/
|
||||||
spin_lock_irqsave(&se_lun->lun_cmd_lock, flags);
|
spin_lock_irqsave(&se_lun->lun_cmd_lock, flags);
|
||||||
list_add_tail(&se_cmd->se_lun_list, &se_lun->lun_cmd_list);
|
list_add_tail(&se_cmd->se_lun_node, &se_lun->lun_cmd_list);
|
||||||
atomic_set(&se_cmd->t_task->transport_lun_active, 1);
|
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
|
|
||||||
spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags);
|
spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(transport_get_lun_for_cmd);
|
EXPORT_SYMBOL(transport_lookup_cmd_lun);
|
||||||
|
|
||||||
int transport_get_lun_for_tmr(
|
int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
|
||||||
struct se_cmd *se_cmd,
|
|
||||||
u32 unpacked_lun)
|
|
||||||
{
|
{
|
||||||
struct se_device *dev = NULL;
|
|
||||||
struct se_dev_entry *deve;
|
struct se_dev_entry *deve;
|
||||||
struct se_lun *se_lun = NULL;
|
struct se_lun *se_lun = NULL;
|
||||||
struct se_session *se_sess = se_cmd->se_sess;
|
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);
|
spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
|
||||||
deve = se_cmd->se_deve =
|
se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun];
|
||||||
&se_sess->se_node_acl->device_list[unpacked_lun];
|
deve = se_cmd->se_deve;
|
||||||
|
|
||||||
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
|
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
|
||||||
se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun;
|
se_tmr->tmr_lun = deve->se_lun;
|
||||||
dev = se_lun->lun_se_dev;
|
se_cmd->se_lun = deve->se_lun;
|
||||||
|
se_lun = deve->se_lun;
|
||||||
se_cmd->pr_res_key = deve->pr_res_key;
|
se_cmd->pr_res_key = deve->pr_res_key;
|
||||||
se_cmd->orig_fe_lun = unpacked_lun;
|
se_cmd->orig_fe_lun = unpacked_lun;
|
||||||
se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
|
se_cmd->se_orig_obj_ptr = se_cmd->se_dev;
|
||||||
/* se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; */
|
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
|
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.
|
* 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) {
|
if (se_dev_check_online(se_lun->lun_se_dev) != 0) {
|
||||||
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
se_tmr->tmr_dev = dev;
|
|
||||||
|
|
||||||
spin_lock(&dev->se_tmr_lock);
|
/* Directly associate cmd with se_dev */
|
||||||
list_add_tail(&se_tmr->tmr_list, &dev->dev_tmr_list);
|
se_cmd->se_dev = se_lun->lun_se_dev;
|
||||||
spin_unlock(&dev->se_tmr_lock);
|
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;
|
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()
|
* 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_lun *se_lun;
|
||||||
struct se_session *se_sess = se_cmd->se_sess;
|
struct se_session *se_sess = se_cmd->se_sess;
|
||||||
struct se_task *se_task;
|
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;
|
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;
|
break;
|
||||||
|
|
||||||
if (!(se_task)) {
|
if (!(se_task)) {
|
||||||
|
|
|
@ -223,7 +223,7 @@ static struct se_device *fd_create_virtdevice(
|
||||||
dev_limits.queue_depth = FD_DEVICE_QUEUE_DEPTH;
|
dev_limits.queue_depth = FD_DEVICE_QUEUE_DEPTH;
|
||||||
|
|
||||||
dev = transport_add_device_to_core_hba(hba, &fileio_template,
|
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);
|
&dev_limits, "FILEIO", FD_VERSION);
|
||||||
if (!(dev))
|
if (!(dev))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -279,7 +279,7 @@ fd_alloc_task(struct se_cmd *cmd)
|
||||||
return NULL;
|
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;
|
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_cmd *cmd = task->task_se_cmd;
|
||||||
struct se_device *dev = cmd->se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct fd_dev *fd_dev = dev->dev_ptr;
|
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;
|
loff_t start, end;
|
||||||
int ret;
|
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.
|
* 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;
|
start = 0;
|
||||||
end = LLONG_MAX;
|
end = LLONG_MAX;
|
||||||
} else {
|
} 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)
|
if (cmd->data_length)
|
||||||
end = start + cmd->data_length;
|
end = start + cmd->data_length;
|
||||||
else
|
else
|
||||||
|
@ -475,7 +475,7 @@ static int fd_do_task(struct se_task *task)
|
||||||
if (ret > 0 &&
|
if (ret > 0 &&
|
||||||
dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
|
dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
|
||||||
dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 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
|
* We might need to be a bit smarter here
|
||||||
* and return some sense data to let the initiator
|
* 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;
|
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"
|
printk(KERN_INFO "CORE_HBA[%d] - TCM iBlock HBA Driver %s on"
|
||||||
" Generic Target Core Stack %s\n", hba->hba_id,
|
" 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;
|
ib_dev->ibd_bd = bd;
|
||||||
|
|
||||||
dev = transport_add_device_to_core_hba(hba,
|
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);
|
&dev_limits, "IBLOCK", IBLOCK_VERSION);
|
||||||
if (!(dev))
|
if (!(dev))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -240,7 +240,7 @@ iblock_alloc_task(struct se_cmd *cmd)
|
||||||
return NULL;
|
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);
|
atomic_set(&ib_req->ib_bio_cnt, 0);
|
||||||
return &ib_req->ib_task;
|
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 se_cmd *cmd = task->task_se_cmd;
|
||||||
struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr;
|
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;
|
sector_t error_sector;
|
||||||
int ret;
|
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 ||
|
if (dev->se_sub_dev->se_dev_attrib.emulate_write_cache == 0 ||
|
||||||
(dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 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;
|
rw = WRITE_FUA;
|
||||||
else
|
else
|
||||||
rw = WRITE;
|
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);
|
DEBUG_IBLOCK("Allocated bio: %p task_size: %u\n", bio, task->task_size);
|
||||||
|
|
||||||
bio->bi_bdev = ib_dev->ibd_bd;
|
bio->bi_bdev = ib_dev->ibd_bd;
|
||||||
bio->bi_private = (void *) task;
|
bio->bi_private = task;
|
||||||
bio->bi_destructor = iblock_bio_destructor;
|
bio->bi_destructor = iblock_bio_destructor;
|
||||||
bio->bi_end_io = &iblock_bio_done;
|
bio->bi_end_io = &iblock_bio_done;
|
||||||
bio->bi_sector = lba;
|
bio->bi_sector = lba;
|
||||||
|
@ -608,7 +608,7 @@ static struct bio *iblock_get_bio(
|
||||||
static int iblock_map_task_SG(struct se_task *task)
|
static int iblock_map_task_SG(struct se_task *task)
|
||||||
{
|
{
|
||||||
struct se_cmd *cmd = task->task_se_cmd;
|
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_dev *ib_dev = task->se_dev->dev_ptr;
|
||||||
struct iblock_req *ib_req = IBLOCK_REQ(task);
|
struct iblock_req *ib_req = IBLOCK_REQ(task);
|
||||||
struct bio *bio = NULL, *hbio = NULL, *tbio = NULL;
|
struct bio *bio = NULL, *hbio = NULL, *tbio = NULL;
|
||||||
|
|
|
@ -157,8 +157,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd)
|
||||||
struct se_session *sess = cmd->se_sess;
|
struct se_session *sess = cmd->se_sess;
|
||||||
struct se_portal_group *tpg = sess->se_tpg;
|
struct se_portal_group *tpg = sess->se_tpg;
|
||||||
|
|
||||||
if ((cmd->t_task->t_task_cdb[1] & 0x01) &&
|
if ((cmd->t_task.t_task_cdb[1] & 0x01) &&
|
||||||
(cmd->t_task->t_task_cdb[1] & 0x02)) {
|
(cmd->t_task.t_task_cdb[1] & 0x02)) {
|
||||||
printk(KERN_ERR "LongIO and Obselete Bits set, returning"
|
printk(KERN_ERR "LongIO and Obselete Bits set, returning"
|
||||||
" ILLEGAL_REQUEST\n");
|
" ILLEGAL_REQUEST\n");
|
||||||
return PYX_TRANSPORT_ILLEGAL_REQUEST;
|
return PYX_TRANSPORT_ILLEGAL_REQUEST;
|
||||||
|
@ -216,7 +216,7 @@ int core_scsi2_emulate_crh(struct se_cmd *cmd)
|
||||||
struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
|
struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
|
||||||
struct t10_pr_registration *pr_reg;
|
struct t10_pr_registration *pr_reg;
|
||||||
struct t10_reservation *pr_tmpl = &su_dev->t10_pr;
|
struct t10_reservation *pr_tmpl = &su_dev->t10_pr;
|
||||||
unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
|
unsigned char *cdb = &cmd->t_task.t_task_cdb[0];
|
||||||
int crh = (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS);
|
int crh = (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS);
|
||||||
int conflict = 0;
|
int conflict = 0;
|
||||||
|
|
||||||
|
@ -1471,7 +1471,7 @@ static int core_scsi3_decode_spec_i_port(
|
||||||
int all_tg_pt,
|
int all_tg_pt,
|
||||||
int aptpl)
|
int aptpl)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct se_port *tmp_port;
|
struct se_port *tmp_port;
|
||||||
struct se_portal_group *dest_tpg = NULL, *tmp_tpg;
|
struct se_portal_group *dest_tpg = NULL, *tmp_tpg;
|
||||||
struct se_session *se_sess = cmd->se_sess;
|
struct se_session *se_sess = cmd->se_sess;
|
||||||
|
@ -1482,7 +1482,7 @@ static int core_scsi3_decode_spec_i_port(
|
||||||
struct list_head tid_dest_list;
|
struct list_head tid_dest_list;
|
||||||
struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp;
|
struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp;
|
||||||
struct target_core_fabric_ops *tmp_tf_ops;
|
struct target_core_fabric_ops *tmp_tf_ops;
|
||||||
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, *i_str = NULL, proto_ident, tmp_proto_ident;
|
unsigned char *ptr, *i_str = NULL, proto_ident, tmp_proto_ident;
|
||||||
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
|
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
|
||||||
u32 tpdl, tid_len = 0;
|
u32 tpdl, tid_len = 0;
|
||||||
|
@ -1509,7 +1509,7 @@ static int core_scsi3_decode_spec_i_port(
|
||||||
tidh_new->dest_node_acl = se_sess->se_node_acl;
|
tidh_new->dest_node_acl = se_sess->se_node_acl;
|
||||||
tidh_new->dest_se_deve = local_se_deve;
|
tidh_new->dest_se_deve = local_se_deve;
|
||||||
|
|
||||||
local_pr_reg = __core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
|
local_pr_reg = __core_scsi3_alloc_registration(cmd->se_dev,
|
||||||
se_sess->se_node_acl, local_se_deve, l_isid,
|
se_sess->se_node_acl, local_se_deve, l_isid,
|
||||||
sa_res_key, all_tg_pt, aptpl);
|
sa_res_key, all_tg_pt, aptpl);
|
||||||
if (!(local_pr_reg)) {
|
if (!(local_pr_reg)) {
|
||||||
|
@ -1741,7 +1741,7 @@ static int core_scsi3_decode_spec_i_port(
|
||||||
* and then call __core_scsi3_add_registration() in the
|
* and then call __core_scsi3_add_registration() in the
|
||||||
* 2nd loop which will never fail.
|
* 2nd loop which will never fail.
|
||||||
*/
|
*/
|
||||||
dest_pr_reg = __core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
|
dest_pr_reg = __core_scsi3_alloc_registration(cmd->se_dev,
|
||||||
dest_node_acl, dest_se_deve, iport_ptr,
|
dest_node_acl, dest_se_deve, iport_ptr,
|
||||||
sa_res_key, all_tg_pt, aptpl);
|
sa_res_key, all_tg_pt, aptpl);
|
||||||
if (!(dest_pr_reg)) {
|
if (!(dest_pr_reg)) {
|
||||||
|
@ -1787,7 +1787,7 @@ static int core_scsi3_decode_spec_i_port(
|
||||||
prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0],
|
prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0],
|
||||||
PR_REG_ISID_ID_LEN);
|
PR_REG_ISID_ID_LEN);
|
||||||
|
|
||||||
__core_scsi3_add_registration(cmd->se_lun->lun_se_dev, dest_node_acl,
|
__core_scsi3_add_registration(cmd->se_dev, dest_node_acl,
|
||||||
dest_pr_reg, 0, 0);
|
dest_pr_reg, 0, 0);
|
||||||
|
|
||||||
printk(KERN_INFO "SPC-3 PR [%s] SPEC_I_PT: Successfully"
|
printk(KERN_INFO "SPC-3 PR [%s] SPEC_I_PT: Successfully"
|
||||||
|
@ -2071,7 +2071,7 @@ static int core_scsi3_emulate_pro_register(
|
||||||
int ignore_key)
|
int ignore_key)
|
||||||
{
|
{
|
||||||
struct se_session *se_sess = cmd->se_sess;
|
struct se_session *se_sess = cmd->se_sess;
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct se_dev_entry *se_deve;
|
struct se_dev_entry *se_deve;
|
||||||
struct se_lun *se_lun = cmd->se_lun;
|
struct se_lun *se_lun = cmd->se_lun;
|
||||||
struct se_portal_group *se_tpg;
|
struct se_portal_group *se_tpg;
|
||||||
|
@ -2117,7 +2117,7 @@ static int core_scsi3_emulate_pro_register(
|
||||||
* Port Endpoint that the PRO was received from on the
|
* Port Endpoint that the PRO was received from on the
|
||||||
* Logical Unit of the SCSI device server.
|
* Logical Unit of the SCSI device server.
|
||||||
*/
|
*/
|
||||||
ret = core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_alloc_registration(cmd->se_dev,
|
||||||
se_sess->se_node_acl, se_deve, isid_ptr,
|
se_sess->se_node_acl, se_deve, isid_ptr,
|
||||||
sa_res_key, all_tg_pt, aptpl,
|
sa_res_key, all_tg_pt, aptpl,
|
||||||
ignore_key, 0);
|
ignore_key, 0);
|
||||||
|
@ -2145,7 +2145,7 @@ static int core_scsi3_emulate_pro_register(
|
||||||
*/
|
*/
|
||||||
if (!(aptpl)) {
|
if (!(aptpl)) {
|
||||||
pr_tmpl->pr_aptpl_active = 0;
|
pr_tmpl->pr_aptpl_active = 0;
|
||||||
core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0);
|
core_scsi3_update_and_write_aptpl(cmd->se_dev, NULL, 0);
|
||||||
printk("SPC-3 PR: Set APTPL Bit Deactivated for"
|
printk("SPC-3 PR: Set APTPL Bit Deactivated for"
|
||||||
" REGISTER\n");
|
" REGISTER\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2155,10 +2155,10 @@ static int core_scsi3_emulate_pro_register(
|
||||||
* update the APTPL metadata information using its
|
* update the APTPL metadata information using its
|
||||||
* preallocated *pr_reg->pr_aptpl_buf.
|
* preallocated *pr_reg->pr_aptpl_buf.
|
||||||
*/
|
*/
|
||||||
pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev,
|
pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev,
|
||||||
se_sess->se_node_acl, se_sess);
|
se_sess->se_node_acl, se_sess);
|
||||||
|
|
||||||
ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_update_and_write_aptpl(cmd->se_dev,
|
||||||
&pr_reg->pr_aptpl_buf[0],
|
&pr_reg->pr_aptpl_buf[0],
|
||||||
pr_tmpl->pr_aptpl_buf_len);
|
pr_tmpl->pr_aptpl_buf_len);
|
||||||
if (!(ret)) {
|
if (!(ret)) {
|
||||||
|
@ -2223,7 +2223,7 @@ static int core_scsi3_emulate_pro_register(
|
||||||
*/
|
*/
|
||||||
if (!(sa_res_key)) {
|
if (!(sa_res_key)) {
|
||||||
pr_holder = core_scsi3_check_implict_release(
|
pr_holder = core_scsi3_check_implict_release(
|
||||||
cmd->se_lun->lun_se_dev, pr_reg);
|
cmd->se_dev, pr_reg);
|
||||||
if (pr_holder < 0) {
|
if (pr_holder < 0) {
|
||||||
kfree(pr_aptpl_buf);
|
kfree(pr_aptpl_buf);
|
||||||
core_scsi3_put_pr_reg(pr_reg);
|
core_scsi3_put_pr_reg(pr_reg);
|
||||||
|
@ -2260,7 +2260,7 @@ static int core_scsi3_emulate_pro_register(
|
||||||
/*
|
/*
|
||||||
* Release the calling I_T Nexus registration now..
|
* Release the calling I_T Nexus registration now..
|
||||||
*/
|
*/
|
||||||
__core_scsi3_free_registration(cmd->se_lun->lun_se_dev, pr_reg,
|
__core_scsi3_free_registration(cmd->se_dev, pr_reg,
|
||||||
NULL, 1);
|
NULL, 1);
|
||||||
/*
|
/*
|
||||||
* From spc4r17, section 5.7.11.3 Unregistering
|
* From spc4r17, section 5.7.11.3 Unregistering
|
||||||
|
@ -2315,7 +2315,7 @@ static int core_scsi3_emulate_pro_register(
|
||||||
* READ_KEYS service action.
|
* READ_KEYS service action.
|
||||||
*/
|
*/
|
||||||
pr_reg->pr_res_generation = core_scsi3_pr_generation(
|
pr_reg->pr_res_generation = core_scsi3_pr_generation(
|
||||||
cmd->se_lun->lun_se_dev);
|
cmd->se_dev);
|
||||||
pr_reg->pr_res_key = sa_res_key;
|
pr_reg->pr_res_key = sa_res_key;
|
||||||
printk("SPC-3 PR [%s] REGISTER%s: Changed Reservation"
|
printk("SPC-3 PR [%s] REGISTER%s: Changed Reservation"
|
||||||
" Key for %s to: 0x%016Lx PRgeneration:"
|
" Key for %s to: 0x%016Lx PRgeneration:"
|
||||||
|
@ -2398,7 +2398,7 @@ static int core_scsi3_pro_reserve(
|
||||||
/*
|
/*
|
||||||
* Locate the existing *pr_reg via struct se_node_acl pointers
|
* Locate the existing *pr_reg via struct se_node_acl pointers
|
||||||
*/
|
*/
|
||||||
pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl,
|
pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl,
|
||||||
se_sess);
|
se_sess);
|
||||||
if (!(pr_reg)) {
|
if (!(pr_reg)) {
|
||||||
printk(KERN_ERR "SPC-3 PR: Unable to locate"
|
printk(KERN_ERR "SPC-3 PR: Unable to locate"
|
||||||
|
@ -2527,7 +2527,7 @@ static int core_scsi3_pro_reserve(
|
||||||
spin_unlock(&dev->dev_reservation_lock);
|
spin_unlock(&dev->dev_reservation_lock);
|
||||||
|
|
||||||
if (pr_tmpl->pr_aptpl_active) {
|
if (pr_tmpl->pr_aptpl_active) {
|
||||||
ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_update_and_write_aptpl(cmd->se_dev,
|
||||||
&pr_reg->pr_aptpl_buf[0],
|
&pr_reg->pr_aptpl_buf[0],
|
||||||
pr_tmpl->pr_aptpl_buf_len);
|
pr_tmpl->pr_aptpl_buf_len);
|
||||||
if (!(ret))
|
if (!(ret))
|
||||||
|
@ -2758,7 +2758,7 @@ static int core_scsi3_emulate_pro_release(
|
||||||
|
|
||||||
write_aptpl:
|
write_aptpl:
|
||||||
if (pr_tmpl->pr_aptpl_active) {
|
if (pr_tmpl->pr_aptpl_active) {
|
||||||
ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_update_and_write_aptpl(cmd->se_dev,
|
||||||
&pr_reg->pr_aptpl_buf[0],
|
&pr_reg->pr_aptpl_buf[0],
|
||||||
pr_tmpl->pr_aptpl_buf_len);
|
pr_tmpl->pr_aptpl_buf_len);
|
||||||
if (!(ret))
|
if (!(ret))
|
||||||
|
@ -2783,7 +2783,7 @@ static int core_scsi3_emulate_pro_clear(
|
||||||
/*
|
/*
|
||||||
* Locate the existing *pr_reg via struct se_node_acl pointers
|
* Locate the existing *pr_reg via struct se_node_acl pointers
|
||||||
*/
|
*/
|
||||||
pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev,
|
pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev,
|
||||||
se_sess->se_node_acl, se_sess);
|
se_sess->se_node_acl, se_sess);
|
||||||
if (!(pr_reg_n)) {
|
if (!(pr_reg_n)) {
|
||||||
printk(KERN_ERR "SPC-3 PR: Unable to locate"
|
printk(KERN_ERR "SPC-3 PR: Unable to locate"
|
||||||
|
@ -2849,7 +2849,7 @@ static int core_scsi3_emulate_pro_clear(
|
||||||
cmd->se_tfo->get_fabric_name());
|
cmd->se_tfo->get_fabric_name());
|
||||||
|
|
||||||
if (pr_tmpl->pr_aptpl_active) {
|
if (pr_tmpl->pr_aptpl_active) {
|
||||||
core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0);
|
core_scsi3_update_and_write_aptpl(cmd->se_dev, NULL, 0);
|
||||||
printk(KERN_INFO "SPC-3 PR: Updated APTPL metadata"
|
printk(KERN_INFO "SPC-3 PR: Updated APTPL metadata"
|
||||||
" for CLEAR\n");
|
" for CLEAR\n");
|
||||||
}
|
}
|
||||||
|
@ -2954,7 +2954,7 @@ static int core_scsi3_pro_preempt(
|
||||||
u64 sa_res_key,
|
u64 sa_res_key,
|
||||||
int abort)
|
int abort)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct se_dev_entry *se_deve;
|
struct se_dev_entry *se_deve;
|
||||||
struct se_node_acl *pr_reg_nacl;
|
struct se_node_acl *pr_reg_nacl;
|
||||||
struct se_session *se_sess = cmd->se_sess;
|
struct se_session *se_sess = cmd->se_sess;
|
||||||
|
@ -2969,7 +2969,7 @@ static int core_scsi3_pro_preempt(
|
||||||
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
||||||
|
|
||||||
se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun];
|
se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun];
|
||||||
pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl,
|
pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl,
|
||||||
se_sess);
|
se_sess);
|
||||||
if (!(pr_reg_n)) {
|
if (!(pr_reg_n)) {
|
||||||
printk(KERN_ERR "SPC-3 PR: Unable to locate"
|
printk(KERN_ERR "SPC-3 PR: Unable to locate"
|
||||||
|
@ -3111,7 +3111,7 @@ static int core_scsi3_pro_preempt(
|
||||||
spin_unlock(&dev->dev_reservation_lock);
|
spin_unlock(&dev->dev_reservation_lock);
|
||||||
|
|
||||||
if (pr_tmpl->pr_aptpl_active) {
|
if (pr_tmpl->pr_aptpl_active) {
|
||||||
ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_update_and_write_aptpl(cmd->se_dev,
|
||||||
&pr_reg_n->pr_aptpl_buf[0],
|
&pr_reg_n->pr_aptpl_buf[0],
|
||||||
pr_tmpl->pr_aptpl_buf_len);
|
pr_tmpl->pr_aptpl_buf_len);
|
||||||
if (!(ret))
|
if (!(ret))
|
||||||
|
@ -3121,7 +3121,7 @@ static int core_scsi3_pro_preempt(
|
||||||
}
|
}
|
||||||
|
|
||||||
core_scsi3_put_pr_reg(pr_reg_n);
|
core_scsi3_put_pr_reg(pr_reg_n);
|
||||||
core_scsi3_pr_generation(cmd->se_lun->lun_se_dev);
|
core_scsi3_pr_generation(cmd->se_dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -3247,7 +3247,7 @@ static int core_scsi3_pro_preempt(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pr_tmpl->pr_aptpl_active) {
|
if (pr_tmpl->pr_aptpl_active) {
|
||||||
ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_update_and_write_aptpl(cmd->se_dev,
|
||||||
&pr_reg_n->pr_aptpl_buf[0],
|
&pr_reg_n->pr_aptpl_buf[0],
|
||||||
pr_tmpl->pr_aptpl_buf_len);
|
pr_tmpl->pr_aptpl_buf_len);
|
||||||
if (!(ret))
|
if (!(ret))
|
||||||
|
@ -3256,7 +3256,7 @@ static int core_scsi3_pro_preempt(
|
||||||
}
|
}
|
||||||
|
|
||||||
core_scsi3_put_pr_reg(pr_reg_n);
|
core_scsi3_put_pr_reg(pr_reg_n);
|
||||||
core_scsi3_pr_generation(cmd->se_lun->lun_se_dev);
|
core_scsi3_pr_generation(cmd->se_dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3298,7 +3298,7 @@ static int core_scsi3_emulate_pro_register_and_move(
|
||||||
int unreg)
|
int unreg)
|
||||||
{
|
{
|
||||||
struct se_session *se_sess = cmd->se_sess;
|
struct se_session *se_sess = cmd->se_sess;
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct se_dev_entry *se_deve, *dest_se_deve = NULL;
|
struct se_dev_entry *se_deve, *dest_se_deve = NULL;
|
||||||
struct se_lun *se_lun = cmd->se_lun;
|
struct se_lun *se_lun = cmd->se_lun;
|
||||||
struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL;
|
struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL;
|
||||||
|
@ -3307,7 +3307,7 @@ static int core_scsi3_emulate_pro_register_and_move(
|
||||||
struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops;
|
struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops;
|
||||||
struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg;
|
struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg;
|
||||||
struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
|
struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
|
||||||
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
|
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
|
||||||
unsigned char *initiator_str;
|
unsigned char *initiator_str;
|
||||||
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
|
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
|
||||||
u32 tid_len, tmp_tid_len;
|
u32 tid_len, tmp_tid_len;
|
||||||
|
@ -3330,7 +3330,7 @@ static int core_scsi3_emulate_pro_register_and_move(
|
||||||
*
|
*
|
||||||
* Locate the existing *pr_reg via struct se_node_acl pointers
|
* Locate the existing *pr_reg via struct se_node_acl pointers
|
||||||
*/
|
*/
|
||||||
pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl,
|
pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl,
|
||||||
se_sess);
|
se_sess);
|
||||||
if (!(pr_reg)) {
|
if (!(pr_reg)) {
|
||||||
printk(KERN_ERR "SPC-3 PR: Unable to locate PR_REGISTERED"
|
printk(KERN_ERR "SPC-3 PR: Unable to locate PR_REGISTERED"
|
||||||
|
@ -3612,7 +3612,7 @@ after_iport_check:
|
||||||
dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl,
|
dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl,
|
||||||
iport_ptr);
|
iport_ptr);
|
||||||
if (!(dest_pr_reg)) {
|
if (!(dest_pr_reg)) {
|
||||||
ret = core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_alloc_registration(cmd->se_dev,
|
||||||
dest_node_acl, dest_se_deve, iport_ptr,
|
dest_node_acl, dest_se_deve, iport_ptr,
|
||||||
sa_res_key, 0, aptpl, 2, 1);
|
sa_res_key, 0, aptpl, 2, 1);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -3683,12 +3683,12 @@ after_iport_check:
|
||||||
*/
|
*/
|
||||||
if (!(aptpl)) {
|
if (!(aptpl)) {
|
||||||
pr_tmpl->pr_aptpl_active = 0;
|
pr_tmpl->pr_aptpl_active = 0;
|
||||||
core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0);
|
core_scsi3_update_and_write_aptpl(cmd->se_dev, NULL, 0);
|
||||||
printk("SPC-3 PR: Set APTPL Bit Deactivated for"
|
printk("SPC-3 PR: Set APTPL Bit Deactivated for"
|
||||||
" REGISTER_AND_MOVE\n");
|
" REGISTER_AND_MOVE\n");
|
||||||
} else {
|
} else {
|
||||||
pr_tmpl->pr_aptpl_active = 1;
|
pr_tmpl->pr_aptpl_active = 1;
|
||||||
ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
|
ret = core_scsi3_update_and_write_aptpl(cmd->se_dev,
|
||||||
&dest_pr_reg->pr_aptpl_buf[0],
|
&dest_pr_reg->pr_aptpl_buf[0],
|
||||||
pr_tmpl->pr_aptpl_buf_len);
|
pr_tmpl->pr_aptpl_buf_len);
|
||||||
if (!(ret))
|
if (!(ret))
|
||||||
|
@ -3723,7 +3723,7 @@ static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb)
|
||||||
*/
|
*/
|
||||||
static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb)
|
static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb)
|
||||||
{
|
{
|
||||||
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
|
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
|
||||||
u64 res_key, sa_res_key;
|
u64 res_key, sa_res_key;
|
||||||
int sa, scope, type, aptpl;
|
int sa, scope, type, aptpl;
|
||||||
int spec_i_pt = 0, all_tg_pt = 0, unreg = 0;
|
int spec_i_pt = 0, all_tg_pt = 0, unreg = 0;
|
||||||
|
@ -3827,10 +3827,10 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb)
|
||||||
*/
|
*/
|
||||||
static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
|
static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *se_dev = cmd->se_lun->lun_se_dev;
|
struct se_device *se_dev = cmd->se_dev;
|
||||||
struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
|
struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
|
||||||
struct t10_pr_registration *pr_reg;
|
struct t10_pr_registration *pr_reg;
|
||||||
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
|
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
|
||||||
u32 add_len = 0, off = 8;
|
u32 add_len = 0, off = 8;
|
||||||
|
|
||||||
if (cmd->data_length < 8) {
|
if (cmd->data_length < 8) {
|
||||||
|
@ -3882,10 +3882,10 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
|
||||||
*/
|
*/
|
||||||
static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
|
static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *se_dev = cmd->se_lun->lun_se_dev;
|
struct se_device *se_dev = cmd->se_dev;
|
||||||
struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
|
struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
|
||||||
struct t10_pr_registration *pr_reg;
|
struct t10_pr_registration *pr_reg;
|
||||||
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
|
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
|
||||||
u64 pr_res_key;
|
u64 pr_res_key;
|
||||||
u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */
|
u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */
|
||||||
|
|
||||||
|
@ -3963,9 +3963,9 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
|
||||||
*/
|
*/
|
||||||
static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
|
static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *dev = cmd->se_lun->lun_se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
|
struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
|
||||||
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
|
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
|
||||||
u16 add_len = 8; /* Hardcoded to 8. */
|
u16 add_len = 8; /* Hardcoded to 8. */
|
||||||
|
|
||||||
if (cmd->data_length < 6) {
|
if (cmd->data_length < 6) {
|
||||||
|
@ -4014,13 +4014,13 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
|
||||||
*/
|
*/
|
||||||
static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
|
static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct se_device *se_dev = cmd->se_lun->lun_se_dev;
|
struct se_device *se_dev = cmd->se_dev;
|
||||||
struct se_node_acl *se_nacl;
|
struct se_node_acl *se_nacl;
|
||||||
struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
|
struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
|
||||||
struct se_portal_group *se_tpg;
|
struct se_portal_group *se_tpg;
|
||||||
struct t10_pr_registration *pr_reg, *pr_reg_tmp;
|
struct t10_pr_registration *pr_reg, *pr_reg_tmp;
|
||||||
struct t10_reservation *pr_tmpl = &se_dev->se_sub_dev->t10_pr;
|
struct t10_reservation *pr_tmpl = &se_dev->se_sub_dev->t10_pr;
|
||||||
unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
|
unsigned char *buf = (unsigned char *)cmd->t_task.t_task_buf;
|
||||||
u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len;
|
u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len;
|
||||||
u32 off = 8; /* off into first Full Status descriptor */
|
u32 off = 8; /* off into first Full Status descriptor */
|
||||||
int format_code = 0;
|
int format_code = 0;
|
||||||
|
@ -4174,7 +4174,7 @@ static int core_scsi3_emulate_pr_in(struct se_cmd *cmd, unsigned char *cdb)
|
||||||
|
|
||||||
int core_scsi3_emulate_pr(struct se_cmd *cmd)
|
int core_scsi3_emulate_pr(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
|
unsigned char *cdb = &cmd->t_task.t_task_cdb[0];
|
||||||
struct se_device *dev = cmd->se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
/*
|
/*
|
||||||
* Following spc2r20 5.5.1 Reservations overview:
|
* Following spc2r20 5.5.1 Reservations overview:
|
||||||
|
|
|
@ -72,7 +72,7 @@ static int pscsi_attach_hba(struct se_hba *hba, u32 host_id)
|
||||||
phv->phv_host_id = host_id;
|
phv->phv_host_id = host_id;
|
||||||
phv->phv_mode = PHV_VIRUTAL_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"
|
printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on"
|
||||||
" Generic Target Core Stack %s\n", hba->hba_id,
|
" 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;
|
pdv->pdv_sd = sd;
|
||||||
|
|
||||||
dev = transport_add_device_to_core_hba(hba, &pscsi_template,
|
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);
|
&dev_limits, NULL, NULL);
|
||||||
if (!(dev)) {
|
if (!(dev)) {
|
||||||
pdv->pdv_sd = NULL;
|
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;
|
pdv->pdv_se_hba = hba;
|
||||||
|
|
||||||
printk(KERN_INFO "PSCSI: Allocated pdv: %p for %s\n", pdv, name);
|
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 &
|
if (task->task_se_cmd->se_deve->lun_flags &
|
||||||
TRANSPORT_LUNFLAGS_READ_ONLY) {
|
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 (cdb[0] == MODE_SENSE_10) {
|
||||||
if (!(buf[3] & 0x80))
|
if (!(buf[3] & 0x80))
|
||||||
|
@ -763,7 +763,7 @@ static struct se_task *
|
||||||
pscsi_alloc_task(struct se_cmd *cmd)
|
pscsi_alloc_task(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct pscsi_plugin_task *pt;
|
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);
|
pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL);
|
||||||
if (!pt) {
|
if (!pt) {
|
||||||
|
@ -776,7 +776,7 @@ pscsi_alloc_task(struct se_cmd *cmd)
|
||||||
* allocate the extended CDB buffer for per struct se_task context
|
* allocate the extended CDB buffer for per struct se_task context
|
||||||
* pt->pscsi_cdb now.
|
* 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);
|
pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL);
|
||||||
if (!(pt->pscsi_cdb)) {
|
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.
|
* also set the end_io_data pointer.to struct se_task.
|
||||||
*/
|
*/
|
||||||
req->end_io = pscsi_req_done;
|
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
|
* Load the referenced struct se_task's SCSI CDB into
|
||||||
* include/linux/blkdev.h:struct request->cmd
|
* include/linux/blkdev.h:struct request->cmd
|
||||||
|
@ -822,7 +822,7 @@ static inline void pscsi_blk_init_request(
|
||||||
/*
|
/*
|
||||||
* Setup pointer for outgoing sense data.
|
* Setup pointer for outgoing sense data.
|
||||||
*/
|
*/
|
||||||
req->sense = (void *)&pt->pscsi_sense[0];
|
req->sense = &pt->pscsi_sense[0];
|
||||||
req->sense_len = 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()
|
* Release the extended CDB allocation from pscsi_alloc_task()
|
||||||
* if one exists.
|
* 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);
|
kfree(pt->pscsi_cdb);
|
||||||
/*
|
/*
|
||||||
* We do not release the bio(s) here associated with this task, as
|
* 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;
|
return 0;
|
||||||
|
|
||||||
ret = blk_rq_map_kern(pdv->pdv_sd->request_queue,
|
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);
|
task->task_size, GFP_KERNEL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret);
|
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;
|
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"
|
printk(KERN_INFO "CORE_HBA[%d] - TCM Ramdisk HBA Driver %s on"
|
||||||
" Generic Target Core Stack %s\n", hba->hba_id,
|
" 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,
|
dev = transport_add_device_to_core_hba(hba,
|
||||||
(rd_dev->rd_direct) ? &rd_dr_template :
|
(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);
|
&dev_limits, prod, rev);
|
||||||
if (!(dev))
|
if (!(dev))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -336,7 +336,7 @@ rd_alloc_task(struct se_cmd *cmd)
|
||||||
printk(KERN_ERR "Unable to allocate struct rd_request\n");
|
printk(KERN_ERR "Unable to allocate struct rd_request\n");
|
||||||
return NULL;
|
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;
|
return &rd_req->rd_task;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +737,7 @@ check_eot:
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
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
|
#ifdef DEBUG_RAMDISK_DR
|
||||||
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
|
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
|
||||||
*se_mem_cnt);
|
*se_mem_cnt);
|
||||||
|
@ -819,7 +819,7 @@ static int rd_DIRECT_without_offset(
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
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
|
#ifdef DEBUG_RAMDISK_DR
|
||||||
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
|
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
|
||||||
*se_mem_cnt);
|
*se_mem_cnt);
|
||||||
|
@ -880,14 +880,14 @@ static int rd_DIRECT_do_se_mem_map(
|
||||||
* across multiple struct se_task->task_sg[].
|
* across multiple struct se_task->task_sg[].
|
||||||
*/
|
*/
|
||||||
ret = transport_init_task_sg(task,
|
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),
|
struct se_mem, se_list),
|
||||||
task_offset);
|
task_offset);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return transport_map_mem_to_sg(task, se_mem_list, task->task_sg,
|
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),
|
struct se_mem, se_list),
|
||||||
out_se_mem, se_mem_cnt, task_offset_in);
|
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 list_head *preempt_and_abort_list,
|
||||||
struct se_cmd *prout_cmd)
|
struct se_cmd *prout_cmd)
|
||||||
{
|
{
|
||||||
struct se_cmd *cmd;
|
struct se_cmd *cmd, *tcmd;
|
||||||
struct se_queue_req *qr, *qr_tmp;
|
|
||||||
struct se_node_acl *tmr_nacl = NULL;
|
struct se_node_acl *tmr_nacl = NULL;
|
||||||
struct se_portal_group *tmr_tpg = NULL;
|
struct se_portal_group *tmr_tpg = NULL;
|
||||||
struct se_queue_obj *qobj = &dev->dev_queue_obj;
|
struct se_queue_obj *qobj = &dev->dev_queue_obj;
|
||||||
struct se_tmr_req *tmr_p, *tmr_pp;
|
struct se_tmr_req *tmr_p, *tmr_pp;
|
||||||
struct se_task *task, *task_tmp;
|
struct se_task *task, *task_tmp;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int fe_count, state, tas;
|
int fe_count, tas;
|
||||||
/*
|
/*
|
||||||
* TASK_ABORTED status bit, this is configurable via ConfigFS
|
* TASK_ABORTED status bit, this is configurable via ConfigFS
|
||||||
* struct se_device attributes. spc4r17 section 7.4.6 Control mode page
|
* struct se_device attributes. spc4r17 section 7.4.6 Control mode page
|
||||||
|
@ -179,14 +178,14 @@ int core_tmr_lun_reset(
|
||||||
continue;
|
continue;
|
||||||
spin_unlock(&dev->se_tmr_lock);
|
spin_unlock(&dev->se_tmr_lock);
|
||||||
|
|
||||||
spin_lock_irqsave(&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))) {
|
if (!(atomic_read(&cmd->t_task.t_transport_active))) {
|
||||||
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);
|
spin_lock(&dev->se_tmr_lock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) {
|
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);
|
spin_lock(&dev->se_tmr_lock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +193,7 @@ int core_tmr_lun_reset(
|
||||||
" Response: 0x%02x, t_state: %d\n",
|
" Response: 0x%02x, t_state: %d\n",
|
||||||
(preempt_and_abort_list) ? "Preempt" : "", tmr_p,
|
(preempt_and_abort_list) ? "Preempt" : "", tmr_p,
|
||||||
tmr_p->function, tmr_p->response, cmd->t_state);
|
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);
|
transport_cmd_finish_abort_tmr(cmd);
|
||||||
spin_lock(&dev->se_tmr_lock);
|
spin_lock(&dev->se_tmr_lock);
|
||||||
|
@ -230,12 +229,6 @@ int core_tmr_lun_reset(
|
||||||
}
|
}
|
||||||
cmd = task->task_se_cmd;
|
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
|
* For PREEMPT_AND_ABORT usage, only process commands
|
||||||
* with a matching reservation key.
|
* with a matching reservation key.
|
||||||
|
@ -254,38 +247,38 @@ int core_tmr_lun_reset(
|
||||||
atomic_set(&task->task_state_active, 0);
|
atomic_set(&task->task_state_active, 0);
|
||||||
spin_unlock_irqrestore(&dev->execute_task_lock, flags);
|
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"
|
DEBUG_LR("LUN_RESET: %s cmd: %p task: %p"
|
||||||
" ITT/CmdSN: 0x%08x/0x%08x, i_state: %d, t_state/"
|
" ITT/CmdSN: 0x%08x/0x%08x, i_state: %d, t_state/"
|
||||||
"def_t_state: %d/%d cdb: 0x%02x\n",
|
"def_t_state: %d/%d cdb: 0x%02x\n",
|
||||||
(preempt_and_abort_list) ? "Preempt" : "", cmd, task,
|
(preempt_and_abort_list) ? "Preempt" : "", cmd, task,
|
||||||
cmd->se_tfo->get_task_tag(cmd), 0,
|
cmd->se_tfo->get_task_tag(cmd), 0,
|
||||||
cmd->se_tfo->get_cmd_state(cmd), cmd->t_state,
|
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"
|
DEBUG_LR("LUN_RESET: ITT[0x%08x] - pr_res_key: 0x%016Lx"
|
||||||
" t_task_cdbs: %d t_task_cdbs_left: %d"
|
" t_task_cdbs: %d t_task_cdbs_left: %d"
|
||||||
" t_task_cdbs_sent: %d -- t_transport_active: %d"
|
" t_task_cdbs_sent: %d -- t_transport_active: %d"
|
||||||
" t_transport_stop: %d t_transport_sent: %d\n",
|
" t_transport_stop: %d t_transport_sent: %d\n",
|
||||||
cmd->se_tfo->get_task_tag(cmd), cmd->pr_res_key,
|
cmd->se_tfo->get_task_tag(cmd), cmd->pr_res_key,
|
||||||
cmd->t_task->t_task_cdbs,
|
cmd->t_task.t_task_cdbs,
|
||||||
atomic_read(&cmd->t_task->t_task_cdbs_left),
|
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_sent),
|
||||||
atomic_read(&cmd->t_task->t_transport_active),
|
atomic_read(&cmd->t_task.t_transport_active),
|
||||||
atomic_read(&cmd->t_task->t_transport_stop),
|
atomic_read(&cmd->t_task.t_transport_stop),
|
||||||
atomic_read(&cmd->t_task->t_transport_sent));
|
atomic_read(&cmd->t_task.t_transport_sent));
|
||||||
|
|
||||||
if (atomic_read(&task->task_active)) {
|
if (atomic_read(&task->task_active)) {
|
||||||
atomic_set(&task->task_stop, 1);
|
atomic_set(&task->task_stop, 1);
|
||||||
spin_unlock_irqrestore(
|
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"
|
DEBUG_LR("LUN_RESET: Waiting for task: %p to shutdown"
|
||||||
" for dev: %p\n", task, dev);
|
" for dev: %p\n", task, dev);
|
||||||
wait_for_completion(&task->task_stop_comp);
|
wait_for_completion(&task->task_stop_comp);
|
||||||
DEBUG_LR("LUN_RESET Completed task: %p shutdown for"
|
DEBUG_LR("LUN_RESET Completed task: %p shutdown for"
|
||||||
" dev: %p\n", task, dev);
|
" dev: %p\n", task, dev);
|
||||||
spin_lock_irqsave(&cmd->t_task->t_state_lock, flags);
|
spin_lock_irqsave(&cmd->t_task.t_state_lock, flags);
|
||||||
atomic_dec(&cmd->t_task->t_task_cdbs_left);
|
atomic_dec(&cmd->t_task.t_task_cdbs_left);
|
||||||
|
|
||||||
atomic_set(&task->task_active, 0);
|
atomic_set(&task->task_active, 0);
|
||||||
atomic_set(&task->task_stop, 0);
|
atomic_set(&task->task_stop, 0);
|
||||||
|
@ -295,24 +288,24 @@ int core_tmr_lun_reset(
|
||||||
}
|
}
|
||||||
__transport_stop_task_timer(task, &flags);
|
__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(
|
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"
|
DEBUG_LR("LUN_RESET: Skipping task: %p, dev: %p for"
|
||||||
" t_task_cdbs_ex_left: %d\n", task, dev,
|
" 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);
|
spin_lock_irqsave(&dev->execute_task_lock, flags);
|
||||||
continue;
|
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"
|
DEBUG_LR("LUN_RESET: got t_transport_active = 1 for"
|
||||||
" task: %p, t_fe_count: %d dev: %p\n", task,
|
" task: %p, t_fe_count: %d dev: %p\n", task,
|
||||||
fe_count, dev);
|
fe_count, dev);
|
||||||
atomic_set(&cmd->t_task->t_transport_aborted, 1);
|
atomic_set(&cmd->t_task.t_transport_aborted, 1);
|
||||||
spin_unlock_irqrestore(&cmd->t_task->t_state_lock,
|
spin_unlock_irqrestore(&cmd->t_task.t_state_lock,
|
||||||
flags);
|
flags);
|
||||||
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
|
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,"
|
DEBUG_LR("LUN_RESET: Got t_transport_active = 0 for task: %p,"
|
||||||
" t_fe_count: %d dev: %p\n", task, fe_count, dev);
|
" t_fe_count: %d dev: %p\n", task, fe_count, dev);
|
||||||
atomic_set(&cmd->t_task->t_transport_aborted, 1);
|
atomic_set(&cmd->t_task.t_transport_aborted, 1);
|
||||||
spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
|
spin_unlock_irqrestore(&cmd->t_task.t_state_lock, flags);
|
||||||
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
|
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->execute_task_lock, flags);
|
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.
|
* reference, otherwise the struct se_cmd is released.
|
||||||
*/
|
*/
|
||||||
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
|
spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
|
||||||
list_for_each_entry_safe(qr, qr_tmp, &qobj->qobj_list, qr_list) {
|
list_for_each_entry_safe(cmd, tcmd, &qobj->qobj_list, se_queue_node) {
|
||||||
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;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* For PREEMPT_AND_ABORT usage, only process commands
|
* For PREEMPT_AND_ABORT usage, only process commands
|
||||||
* with a matching reservation key.
|
* with a matching reservation key.
|
||||||
|
@ -365,18 +345,15 @@ int core_tmr_lun_reset(
|
||||||
if (prout_cmd == cmd)
|
if (prout_cmd == cmd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
atomic_dec(&cmd->t_task->t_transport_queue_active);
|
atomic_dec(&cmd->t_task.t_transport_queue_active);
|
||||||
atomic_dec(&qobj->queue_cnt);
|
atomic_dec(&qobj->queue_cnt);
|
||||||
list_del(&qr->qr_list);
|
list_del(&cmd->se_queue_node);
|
||||||
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
|
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:"
|
DEBUG_LR("LUN_RESET: %s from Device Queue: cmd: %p t_state:"
|
||||||
" %d t_fe_count: %d\n", (preempt_and_abort_list) ?
|
" %d t_fe_count: %d\n", (preempt_and_abort_list) ?
|
||||||
"Preempt" : "", cmd, state,
|
"Preempt" : "", cmd, cmd->t_state,
|
||||||
atomic_read(&cmd->t_task->t_fe_count));
|
atomic_read(&cmd->t_task.t_fe_count));
|
||||||
/*
|
/*
|
||||||
* Signal that the command has failed via cmd->se_cmd_flags,
|
* Signal that the command has failed via cmd->se_cmd_flags,
|
||||||
* and call TFO->new_cmd_failure() to wakeup any fabric
|
* and call TFO->new_cmd_failure() to wakeup any fabric
|
||||||
|
@ -388,7 +365,7 @@ int core_tmr_lun_reset(
|
||||||
transport_new_cmd_failure(cmd);
|
transport_new_cmd_failure(cmd);
|
||||||
|
|
||||||
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas,
|
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_lock_irqsave(&qobj->cmd_queue_lock, flags);
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
|
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -208,7 +208,7 @@ void core_scsi3_ua_for_check_condition(
|
||||||
u8 *asc,
|
u8 *asc,
|
||||||
u8 *ascq)
|
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_dev_entry *deve;
|
||||||
struct se_session *sess = cmd->se_sess;
|
struct se_session *sess = cmd->se_sess;
|
||||||
struct se_node_acl *nacl;
|
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(),
|
nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
|
||||||
(dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
|
(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,
|
"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(
|
int core_scsi3_ua_clear_for_request_sense(
|
||||||
|
|
|
@ -72,16 +72,16 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
|
||||||
caller, cmd, cmd->cdb);
|
caller, cmd, cmd->cdb);
|
||||||
printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
|
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",
|
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,
|
caller, cmd, task, task->t_tasks_se_num,
|
||||||
task->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags);
|
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 "
|
printk(KERN_INFO "%s: cmd %p mem %p page %p "
|
||||||
"len 0x%x off 0x%x\n",
|
"len 0x%x off 0x%x\n",
|
||||||
caller, cmd, mem,
|
caller, cmd, mem,
|
||||||
mem->se_page, mem->se_len, mem->se_off);
|
mem->se_page, mem->se_len, mem->se_off);
|
||||||
sp = cmd->seq;
|
sp = cmd->seq;
|
||||||
if (sp) {
|
if (sp) {
|
||||||
ep = fc_seq_exch(sp);
|
ep = fc_seq_exch(sp);
|
||||||
|
@ -262,9 +262,9 @@ int ft_write_pending(struct se_cmd *se_cmd)
|
||||||
* TCM/LIO target
|
* TCM/LIO target
|
||||||
*/
|
*/
|
||||||
transport_do_task_sg_chain(se_cmd);
|
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 =
|
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,
|
if (cmd->sg && lport->tt.ddp_setup(lport, ep->xid,
|
||||||
cmd->sg, cmd->sg_cnt))
|
cmd->sg, cmd->sg_cnt))
|
||||||
|
@ -438,7 +438,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
|
||||||
switch (fcp->fc_tm_flags) {
|
switch (fcp->fc_tm_flags) {
|
||||||
case FCP_TMF_LUN_RESET:
|
case FCP_TMF_LUN_RESET:
|
||||||
cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
|
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
|
* Make sure to clean up newly allocated TMR request
|
||||||
* since "unable to handle TMR request because failed
|
* 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);
|
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);
|
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) {
|
if (ret < 0) {
|
||||||
ft_dump_cmd(cmd, __func__);
|
ft_dump_cmd(cmd, __func__);
|
||||||
transport_send_check_condition_and_sense(&cmd->se_cmd,
|
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_IO_DBG("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret);
|
||||||
ft_dump_cmd(cmd, __func__);
|
ft_dump_cmd(cmd, __func__);
|
||||||
|
|
||||||
if (ret == -1) {
|
if (ret == -ENOMEM) {
|
||||||
transport_send_check_condition_and_sense(se_cmd,
|
transport_send_check_condition_and_sense(se_cmd,
|
||||||
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
|
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
|
||||||
transport_generic_free_cmd(se_cmd, 0, 1, 0);
|
transport_generic_free_cmd(se_cmd, 0, 1, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ret == -2) {
|
if (ret == -EINVAL) {
|
||||||
if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
|
if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
|
||||||
ft_queue_status(se_cmd);
|
ft_queue_status(se_cmd);
|
||||||
else
|
else
|
||||||
|
|
|
@ -331,7 +331,7 @@ static struct se_portal_group *ft_add_tpg(
|
||||||
transport_init_queue_obj(&tpg->qobj);
|
transport_init_queue_obj(&tpg->qobj);
|
||||||
|
|
||||||
ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg,
|
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) {
|
if (ret < 0) {
|
||||||
kfree(tpg);
|
kfree(tpg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -90,15 +90,14 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
|
||||||
lport = ep->lp;
|
lport = ep->lp;
|
||||||
cmd->seq = lport->tt.seq_start_next(cmd->seq);
|
cmd->seq = lport->tt.seq_start_next(cmd->seq);
|
||||||
|
|
||||||
task = se_cmd->t_task;
|
task = &se_cmd->t_task;
|
||||||
BUG_ON(!task);
|
|
||||||
remaining = se_cmd->data_length;
|
remaining = se_cmd->data_length;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup to use first mem list entry if any.
|
* Setup to use first mem list entry if any.
|
||||||
*/
|
*/
|
||||||
if (task->t_tasks_se_num) {
|
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);
|
struct se_mem, se_list);
|
||||||
mem_len = mem->se_len;
|
mem_len = mem->se_len;
|
||||||
mem_off = mem->se_off;
|
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;
|
u32 f_ctl;
|
||||||
void *buf;
|
void *buf;
|
||||||
|
|
||||||
task = se_cmd->t_task;
|
task = &se_cmd->t_task;
|
||||||
BUG_ON(!task);
|
|
||||||
|
|
||||||
fh = fc_frame_header_get(fp);
|
fh = fc_frame_header_get(fp);
|
||||||
if (!(ntoh24(fh->fh_f_ctl) & FC_FC_REL_OFF))
|
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.
|
* Setup to use first mem list entry if any.
|
||||||
*/
|
*/
|
||||||
if (task->t_tasks_se_num) {
|
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);
|
struct se_mem, se_list);
|
||||||
mem_len = mem->se_len;
|
mem_len = mem->se_len;
|
||||||
mem_off = mem->se_off;
|
mem_off = mem->se_off;
|
||||||
|
|
|
@ -123,7 +123,7 @@ enum se_cmd_flags_table {
|
||||||
SCF_SENT_DELAYED_TAS = 0x00020000,
|
SCF_SENT_DELAYED_TAS = 0x00020000,
|
||||||
SCF_ALUA_NON_OPTIMIZED = 0x00040000,
|
SCF_ALUA_NON_OPTIMIZED = 0x00040000,
|
||||||
SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
|
SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
|
||||||
SCF_PASSTHROUGH_SG_TO_MEM = 0x00100000,
|
SCF_UNUSED = 0x00100000,
|
||||||
SCF_PASSTHROUGH_CONTIG_TO_SG = 0x00200000,
|
SCF_PASSTHROUGH_CONTIG_TO_SG = 0x00200000,
|
||||||
SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,
|
SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,
|
||||||
SCF_EMULATE_SYNC_CACHE = 0x00800000,
|
SCF_EMULATE_SYNC_CACHE = 0x00800000,
|
||||||
|
@ -452,9 +452,9 @@ struct se_transport_task {
|
||||||
* and other HW target mode fabric modules.
|
* and other HW target mode fabric modules.
|
||||||
*/
|
*/
|
||||||
struct scatterlist *t_task_pt_sgl;
|
struct scatterlist *t_task_pt_sgl;
|
||||||
struct list_head *t_mem_list;
|
struct list_head t_mem_list;
|
||||||
/* Used for BIDI READ */
|
/* Used for BIDI READ */
|
||||||
struct list_head *t_mem_bidi_list;
|
struct list_head t_mem_bidi_list;
|
||||||
struct list_head t_task_list;
|
struct list_head t_task_list;
|
||||||
} ____cacheline_aligned;
|
} ____cacheline_aligned;
|
||||||
|
|
||||||
|
@ -523,9 +523,9 @@ struct se_cmd {
|
||||||
atomic_t transport_sent;
|
atomic_t transport_sent;
|
||||||
/* Used for sense data */
|
/* Used for sense data */
|
||||||
void *sense_buffer;
|
void *sense_buffer;
|
||||||
struct list_head se_delayed_list;
|
struct list_head se_delayed_node;
|
||||||
struct list_head se_ordered_list;
|
struct list_head se_ordered_node;
|
||||||
struct list_head se_lun_list;
|
struct list_head se_lun_node;
|
||||||
struct se_device *se_dev;
|
struct se_device *se_dev;
|
||||||
struct se_dev_entry *se_deve;
|
struct se_dev_entry *se_deve;
|
||||||
struct se_device *se_obj_ptr;
|
struct se_device *se_obj_ptr;
|
||||||
|
@ -534,9 +534,8 @@ struct se_cmd {
|
||||||
/* Only used for internal passthrough and legacy TCM fabric modules */
|
/* Only used for internal passthrough and legacy TCM fabric modules */
|
||||||
struct se_session *se_sess;
|
struct se_session *se_sess;
|
||||||
struct se_tmr_req *se_tmr_req;
|
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;
|
struct list_head se_queue_node;
|
||||||
struct se_transport_task t_task_backstore;
|
|
||||||
struct target_core_fabric_ops *se_tfo;
|
struct target_core_fabric_ops *se_tfo;
|
||||||
int (*transport_emulate_cdb)(struct se_cmd *);
|
int (*transport_emulate_cdb)(struct se_cmd *);
|
||||||
void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);
|
void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef TARGET_CORE_DEVICE_H
|
#ifndef TARGET_CORE_DEVICE_H
|
||||||
#define TARGET_CORE_DEVICE_H
|
#define TARGET_CORE_DEVICE_H
|
||||||
|
|
||||||
extern int transport_get_lun_for_cmd(struct se_cmd *, u32);
|
extern int transport_lookup_cmd_lun(struct se_cmd *, u32);
|
||||||
extern int transport_get_lun_for_tmr(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(
|
extern struct se_dev_entry *core_get_se_deve_from_rtpi(
|
||||||
struct se_node_acl *, u16);
|
struct se_node_acl *, u16);
|
||||||
extern int core_free_device_list_for_node(struct se_node_acl *,
|
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,
|
struct se_subsystem_dev *, u32,
|
||||||
void *, struct se_dev_limits *,
|
void *, struct se_dev_limits *,
|
||||||
const char *, const char *);
|
const char *, const char *);
|
||||||
extern void transport_device_setup_cmd(struct se_cmd *);
|
|
||||||
extern void transport_init_se_cmd(struct se_cmd *,
|
extern void transport_init_se_cmd(struct se_cmd *,
|
||||||
struct target_core_fabric_ops *,
|
struct target_core_fabric_ops *,
|
||||||
struct se_session *, u32, int, int,
|
struct se_session *, u32, int, int,
|
||||||
|
|
Loading…
Add table
Reference in a new issue