Skip to content

Commit ce0f706

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull scsi target fixes from Nicholas Bellinger: "This includes an important >= v3.6 regression bugfix for active I/O shutdown (Roland), some TMR related failure / corner cases fixes for long outstanding I/O (Roland), two FCoE target mode fabric fabric role fixes (MDR), a fix for an incorrect sense code during LUN communication failure (Dr. Hannes), plus a handful of other minor fixes. There are still some outstanding zero-length control CDB regression fixes that need to be addressed for v3.8, that will be coming in a follow-up PULL request." * git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: iscsi-target: Fix CmdSN comparison (use cmd->cmd_sn instead of cmd->stat_sn) target: Release se_cmd when LUN lookup fails for TMR target: Fix use-after-free in LUN RESET handling target: Fix missing CMD_T_ACTIVE bit regression for pending WRITEs tcm_fc: Do not report target role when target is not defined tcm_fc: Do not indicate retry capability to initiators target: Use TCM_NO_SENSE for initialisation target: Introduce TCM_NO_SENSE target: use correct sense code for LUN communication failure
2 parents 31db720 + 64fe4f4 commit ce0f706

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

drivers/target/iscsi/iscsi_target_erl2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
372372
* made generic here.
373373
*/
374374
if (!(cmd->cmd_flags & ICF_OOO_CMDSN) && !cmd->immediate_cmd &&
375-
iscsi_sna_gte(cmd->stat_sn, conn->sess->exp_cmd_sn)) {
375+
iscsi_sna_gte(cmd->cmd_sn, conn->sess->exp_cmd_sn)) {
376376
list_del(&cmd->i_conn_node);
377377
spin_unlock_bh(&conn->cmd_lock);
378378
iscsit_free_cmd(cmd);

drivers/target/target_core_alua.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd)
212212
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, *l_tg_pt_gp_mem;
213213
unsigned char *buf;
214214
unsigned char *ptr;
215-
sense_reason_t rc;
215+
sense_reason_t rc = TCM_NO_SENSE;
216216
u32 len = 4; /* Skip over RESERVED area in header */
217217
int alua_access_state, primary = 0;
218218
u16 tg_pt_id, rtpi;

drivers/target/target_core_pr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
20532053
/* Used for APTPL metadata w/ UNREGISTER */
20542054
unsigned char *pr_aptpl_buf = NULL;
20552055
unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL;
2056-
sense_reason_t ret;
2056+
sense_reason_t ret = TCM_NO_SENSE;
20572057
int pr_holder = 0, type;
20582058

20592059
if (!se_sess || !se_lun) {

drivers/target/target_core_transport.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,6 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)
541541

542542
void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
543543
{
544-
if (!(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB))
545-
transport_lun_remove_cmd(cmd);
546-
547544
if (transport_cmd_check_stop_to_fabric(cmd))
548545
return;
549546
if (remove)
@@ -1396,6 +1393,8 @@ static void target_complete_tmr_failure(struct work_struct *work)
13961393

13971394
se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
13981395
se_cmd->se_tfo->queue_tm_rsp(se_cmd);
1396+
1397+
transport_cmd_check_stop_to_fabric(se_cmd);
13991398
}
14001399

14011400
/**
@@ -1688,6 +1687,7 @@ void target_execute_cmd(struct se_cmd *cmd)
16881687
}
16891688

16901689
cmd->t_state = TRANSPORT_PROCESSING;
1690+
cmd->transport_state |= CMD_T_ACTIVE;
16911691
spin_unlock_irq(&cmd->t_state_lock);
16921692

16931693
if (!target_handle_task_attr(cmd))
@@ -2597,6 +2597,16 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd,
25972597
* SENSE KEY values from include/scsi/scsi.h
25982598
*/
25992599
switch (reason) {
2600+
case TCM_NO_SENSE:
2601+
/* CURRENT ERROR */
2602+
buffer[0] = 0x70;
2603+
buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10;
2604+
/* Not Ready */
2605+
buffer[SPC_SENSE_KEY_OFFSET] = NOT_READY;
2606+
/* NO ADDITIONAL SENSE INFORMATION */
2607+
buffer[SPC_ASC_KEY_OFFSET] = 0;
2608+
buffer[SPC_ASCQ_KEY_OFFSET] = 0;
2609+
break;
26002610
case TCM_NON_EXISTENT_LUN:
26012611
/* CURRENT ERROR */
26022612
buffer[0] = 0x70;
@@ -2743,7 +2753,7 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd,
27432753
/* ILLEGAL REQUEST */
27442754
buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
27452755
/* LOGICAL UNIT COMMUNICATION FAILURE */
2746-
buffer[SPC_ASC_KEY_OFFSET] = 0x80;
2756+
buffer[SPC_ASC_KEY_OFFSET] = 0x08;
27472757
break;
27482758
}
27492759
/*
@@ -2804,6 +2814,8 @@ void transport_send_task_abort(struct se_cmd *cmd)
28042814
}
28052815
cmd->scsi_status = SAM_STAT_TASK_ABORTED;
28062816

2817+
transport_lun_remove_cmd(cmd);
2818+
28072819
pr_debug("Setting SAM_STAT_TASK_ABORTED status for CDB: 0x%02x,"
28082820
" ITT: 0x%08x\n", cmd->t_task_cdb[0],
28092821
cmd->se_tfo->get_task_tag(cmd));

drivers/target/tcm_fc/tfc_sess.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,11 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
355355

356356
tport = ft_tport_create(rdata->local_port);
357357
if (!tport)
358-
return 0; /* not a target for this local port */
358+
goto not_target; /* not a target for this local port */
359359

360360
acl = ft_acl_get(tport->tpg, rdata);
361361
if (!acl)
362-
return 0;
362+
goto not_target; /* no target for this remote */
363363

364364
if (!rspp)
365365
goto fill;
@@ -396,12 +396,18 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
396396

397397
/*
398398
* OR in our service parameters with other provider (initiator), if any.
399-
* TBD XXX - indicate RETRY capability?
400399
*/
401400
fill:
402401
fcp_parm = ntohl(spp->spp_params);
402+
fcp_parm &= ~FCP_SPPF_RETRY;
403403
spp->spp_params = htonl(fcp_parm | FCP_SPPF_TARG_FCN);
404404
return FC_SPP_RESP_ACK;
405+
406+
not_target:
407+
fcp_parm = ntohl(spp->spp_params);
408+
fcp_parm &= ~FCP_SPPF_TARG_FCN;
409+
spp->spp_params = htonl(fcp_parm);
410+
return 0;
405411
}
406412

407413
/**

include/target/target_core_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ typedef unsigned __bitwise__ sense_reason_t;
174174

175175
enum tcm_sense_reason_table {
176176
#define R(x) (__force sense_reason_t )(x)
177+
TCM_NO_SENSE = R(0x00),
177178
TCM_NON_EXISTENT_LUN = R(0x01),
178179
TCM_UNSUPPORTED_SCSI_OPCODE = R(0x02),
179180
TCM_INCORRECT_AMOUNT_OF_DATA = R(0x03),

0 commit comments

Comments
 (0)