Skip to content

Commit 48ea2ce

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger: "It's been usually busy for summer, with most of the efforts centered around TCMU developments and various target-core + fabric driver bug fixing activities. Not particularly large in terms of LoC, but lots of smaller patches from many different folks. The highlights include: - ibmvscsis logical partition manager support (Michael Cyr + Bryant Ly) - Convert target/iblock WRITE_SAME to blkdev_issue_zeroout (hch + nab) - Add support for TMR percpu LUN reference counting (nab) - Fix a potential deadlock between EXTENDED_COPY and iscsi shutdown (Bart) - Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce (Jiang Yi) - Fix TMCU module removal (Xiubo Li) - Fix iser-target OOPs during login failure (Andrea Righi + Sagi) - Breakup target-core free_device backend driver callback (mnc) - Perform TCMU add/delete/reconfig synchronously (mnc) - Fix TCMU multiple UIO open/close sequences (mnc) - Fix TCMU CHECK_CONDITION sense handling (mnc) - Fix target-core SAM_STAT_BUSY + TASK_SET_FULL handling (mnc + nab) - Introduce TYPE_ZBC support in PSCSI (Damien Le Moal) - Fix possible TCMU memory leak + OOPs when recalculating cmd base size (Xiubo Li + Bryant Ly + Damien Le Moal + mnc) - Add login_keys_workaround attribute for non RFC initiators (Robert LeBlanc + Arun Easi + nab)" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (68 commits) iscsi-target: Add login_keys_workaround attribute for non RFC initiators Revert "qla2xxx: Fix incorrect tcm_qla2xxx_free_cmd use during TMR ABORT" tcmu: clean up the code and with one small fix tcmu: Fix possbile memory leak / OOPs when recalculating cmd base size target: export lio pgr/alua support as device attr target: Fix return sense reason in target_scsi3_emulate_pr_out target: Fix cmd size for PR-OUT in passthrough_parse_cdb tcmu: Fix dev_config_store target: pscsi: Introduce TYPE_ZBC support target: Use macro for WRITE_VERIFY_32 operation codes target: fix SAM_STAT_BUSY/TASK_SET_FULL handling target: remove transport_complete pscsi: finish cmd processing from pscsi_req_done tcmu: fix sense handling during completion target: add helper to copy sense to se_cmd buffer target: do not require a transport_complete for SCF_TRANSPORT_TASK_SENSE target: make device_mutex and device_list static tcmu: Fix flushing cmd entry dcache page tcmu: fix multiple uio open/close sequences tcmu: drop configured check in destroy ...
2 parents 6240300 + 138d351 commit 48ea2ce

45 files changed

Lines changed: 1356 additions & 698 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/infiniband/ulp/isert/ib_isert.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ static void
14521452
isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)
14531453
{
14541454
struct isert_conn *isert_conn = wc->qp->qp_context;
1455-
struct ib_device *ib_dev = isert_conn->cm_id->device;
1455+
struct ib_device *ib_dev = isert_conn->device->ib_device;
14561456

14571457
if (unlikely(wc->status != IB_WC_SUCCESS)) {
14581458
isert_print_wc(wc, "login recv");

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,8 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
11571157
}
11581158
spin_unlock_irqrestore(&ioctx->spinlock, flags);
11591159

1160-
pr_debug("Aborting cmd with state %d and tag %lld\n", state,
1161-
ioctx->cmd.tag);
1160+
pr_debug("Aborting cmd with state %d -> %d and tag %lld\n", state,
1161+
ioctx->state, ioctx->cmd.tag);
11621162

11631163
switch (state) {
11641164
case SRPT_STATE_NEW:

‎drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c‎

Lines changed: 143 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ static long ibmvscsis_unregister_command_q(struct scsi_info *vscsi)
155155
qrc = h_free_crq(vscsi->dds.unit_id);
156156
switch (qrc) {
157157
case H_SUCCESS:
158+
spin_lock_bh(&vscsi->intr_lock);
159+
vscsi->flags &= ~PREP_FOR_SUSPEND_FLAGS;
160+
spin_unlock_bh(&vscsi->intr_lock);
158161
break;
159162

160163
case H_HARDWARE:
@@ -422,6 +425,9 @@ static void ibmvscsis_disconnect(struct work_struct *work)
422425
new_state = vscsi->new_state;
423426
vscsi->new_state = 0;
424427

428+
vscsi->flags |= DISCONNECT_SCHEDULED;
429+
vscsi->flags &= ~SCHEDULE_DISCONNECT;
430+
425431
pr_debug("disconnect: flags 0x%x, state 0x%hx\n", vscsi->flags,
426432
vscsi->state);
427433

@@ -802,6 +808,13 @@ static long ibmvscsis_establish_new_q(struct scsi_info *vscsi)
802808
long rc = ADAPT_SUCCESS;
803809
uint format;
804810

811+
rc = h_vioctl(vscsi->dds.unit_id, H_ENABLE_PREPARE_FOR_SUSPEND, 30000,
812+
0, 0, 0, 0);
813+
if (rc == H_SUCCESS)
814+
vscsi->flags |= PREP_FOR_SUSPEND_ENABLED;
815+
else if (rc != H_NOT_FOUND)
816+
pr_err("Error from Enable Prepare for Suspend: %ld\n", rc);
817+
805818
vscsi->flags &= PRESERVE_FLAG_FIELDS;
806819
vscsi->rsp_q_timer.timer_pops = 0;
807820
vscsi->debit = 0;
@@ -950,6 +963,63 @@ static void ibmvscsis_free_cmd_resources(struct scsi_info *vscsi,
950963
}
951964
}
952965

966+
/**
967+
* ibmvscsis_ready_for_suspend() - Helper function to call VIOCTL
968+
* @vscsi: Pointer to our adapter structure
969+
* @idle: Indicates whether we were called from adapter_idle. This
970+
* is important to know if we need to do a disconnect, since if
971+
* we're called from adapter_idle, we're still processing the
972+
* current disconnect, so we can't just call post_disconnect.
973+
*
974+
* This function is called when the adapter is idle when phyp has sent
975+
* us a Prepare for Suspend Transport Event.
976+
*
977+
* EXECUTION ENVIRONMENT:
978+
* Process or interrupt environment called with interrupt lock held
979+
*/
980+
static long ibmvscsis_ready_for_suspend(struct scsi_info *vscsi, bool idle)
981+
{
982+
long rc = 0;
983+
struct viosrp_crq *crq;
984+
985+
/* See if there is a Resume event in the queue */
986+
crq = vscsi->cmd_q.base_addr + vscsi->cmd_q.index;
987+
988+
pr_debug("ready_suspend: flags 0x%x, state 0x%hx crq_valid:%x\n",
989+
vscsi->flags, vscsi->state, (int)crq->valid);
990+
991+
if (!(vscsi->flags & PREP_FOR_SUSPEND_ABORTED) && !(crq->valid)) {
992+
rc = h_vioctl(vscsi->dds.unit_id, H_READY_FOR_SUSPEND, 0, 0, 0,
993+
0, 0);
994+
if (rc) {
995+
pr_err("Ready for Suspend Vioctl failed: %ld\n", rc);
996+
rc = 0;
997+
}
998+
} else if (((vscsi->flags & PREP_FOR_SUSPEND_OVERWRITE) &&
999+
(vscsi->flags & PREP_FOR_SUSPEND_ABORTED)) ||
1000+
((crq->valid) && ((crq->valid != VALID_TRANS_EVENT) ||
1001+
(crq->format != RESUME_FROM_SUSP)))) {
1002+
if (idle) {
1003+
vscsi->state = ERR_DISCONNECT_RECONNECT;
1004+
ibmvscsis_reset_queue(vscsi);
1005+
rc = -1;
1006+
} else if (vscsi->state == CONNECTED) {
1007+
ibmvscsis_post_disconnect(vscsi,
1008+
ERR_DISCONNECT_RECONNECT, 0);
1009+
}
1010+
1011+
vscsi->flags &= ~PREP_FOR_SUSPEND_OVERWRITE;
1012+
1013+
if ((crq->valid) && ((crq->valid != VALID_TRANS_EVENT) ||
1014+
(crq->format != RESUME_FROM_SUSP)))
1015+
pr_err("Invalid element in CRQ after Prepare for Suspend");
1016+
}
1017+
1018+
vscsi->flags &= ~(PREP_FOR_SUSPEND_PENDING | PREP_FOR_SUSPEND_ABORTED);
1019+
1020+
return rc;
1021+
}
1022+
9531023
/**
9541024
* ibmvscsis_trans_event() - Handle a Transport Event
9551025
* @vscsi: Pointer to our adapter structure
@@ -974,18 +1044,8 @@ static long ibmvscsis_trans_event(struct scsi_info *vscsi,
9741044
case PARTNER_FAILED:
9751045
case PARTNER_DEREGISTER:
9761046
ibmvscsis_delete_client_info(vscsi, true);
977-
break;
978-
979-
default:
980-
rc = ERROR;
981-
dev_err(&vscsi->dev, "trans_event: invalid format %d\n",
982-
(uint)crq->format);
983-
ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT,
984-
RESPONSE_Q_DOWN);
985-
break;
986-
}
987-
988-
if (rc == ADAPT_SUCCESS) {
1047+
if (crq->format == MIGRATED)
1048+
vscsi->flags &= ~PREP_FOR_SUSPEND_OVERWRITE;
9891049
switch (vscsi->state) {
9901050
case NO_QUEUE:
9911051
case ERR_DISCONNECTED:
@@ -1034,6 +1094,60 @@ static long ibmvscsis_trans_event(struct scsi_info *vscsi,
10341094
vscsi->flags |= (RESPONSE_Q_DOWN | TRANS_EVENT);
10351095
break;
10361096
}
1097+
break;
1098+
1099+
case PREPARE_FOR_SUSPEND:
1100+
pr_debug("Prep for Suspend, crq status = 0x%x\n",
1101+
(int)crq->status);
1102+
switch (vscsi->state) {
1103+
case ERR_DISCONNECTED:
1104+
case WAIT_CONNECTION:
1105+
case CONNECTED:
1106+
ibmvscsis_ready_for_suspend(vscsi, false);
1107+
break;
1108+
case SRP_PROCESSING:
1109+
vscsi->resume_state = vscsi->state;
1110+
vscsi->flags |= PREP_FOR_SUSPEND_PENDING;
1111+
if (crq->status == CRQ_ENTRY_OVERWRITTEN)
1112+
vscsi->flags |= PREP_FOR_SUSPEND_OVERWRITE;
1113+
ibmvscsis_post_disconnect(vscsi, WAIT_IDLE, 0);
1114+
break;
1115+
case NO_QUEUE:
1116+
case UNDEFINED:
1117+
case UNCONFIGURING:
1118+
case WAIT_ENABLED:
1119+
case ERR_DISCONNECT:
1120+
case ERR_DISCONNECT_RECONNECT:
1121+
case WAIT_IDLE:
1122+
pr_err("Invalid state for Prepare for Suspend Trans Event: 0x%x\n",
1123+
vscsi->state);
1124+
break;
1125+
}
1126+
break;
1127+
1128+
case RESUME_FROM_SUSP:
1129+
pr_debug("Resume from Suspend, crq status = 0x%x\n",
1130+
(int)crq->status);
1131+
if (vscsi->flags & PREP_FOR_SUSPEND_PENDING) {
1132+
vscsi->flags |= PREP_FOR_SUSPEND_ABORTED;
1133+
} else {
1134+
if ((crq->status == CRQ_ENTRY_OVERWRITTEN) ||
1135+
(vscsi->flags & PREP_FOR_SUSPEND_OVERWRITE)) {
1136+
ibmvscsis_post_disconnect(vscsi,
1137+
ERR_DISCONNECT_RECONNECT,
1138+
0);
1139+
vscsi->flags &= ~PREP_FOR_SUSPEND_OVERWRITE;
1140+
}
1141+
}
1142+
break;
1143+
1144+
default:
1145+
rc = ERROR;
1146+
dev_err(&vscsi->dev, "trans_event: invalid format %d\n",
1147+
(uint)crq->format);
1148+
ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT,
1149+
RESPONSE_Q_DOWN);
1150+
break;
10371151
}
10381152

10391153
rc = vscsi->flags & SCHEDULE_DISCONNECT;
@@ -1201,6 +1315,7 @@ static struct ibmvscsis_cmd *ibmvscsis_get_free_cmd(struct scsi_info *vscsi)
12011315
static void ibmvscsis_adapter_idle(struct scsi_info *vscsi)
12021316
{
12031317
int free_qs = false;
1318+
long rc = 0;
12041319

12051320
pr_debug("adapter_idle: flags 0x%x, state 0x%hx\n", vscsi->flags,
12061321
vscsi->state);
@@ -1240,7 +1355,14 @@ static void ibmvscsis_adapter_idle(struct scsi_info *vscsi)
12401355
vscsi->rsp_q_timer.timer_pops = 0;
12411356
vscsi->debit = 0;
12421357
vscsi->credit = 0;
1243-
if (vscsi->flags & TRANS_EVENT) {
1358+
if (vscsi->flags & PREP_FOR_SUSPEND_PENDING) {
1359+
vscsi->state = vscsi->resume_state;
1360+
vscsi->resume_state = 0;
1361+
rc = ibmvscsis_ready_for_suspend(vscsi, true);
1362+
vscsi->flags &= ~DISCONNECT_SCHEDULED;
1363+
if (rc)
1364+
break;
1365+
} else if (vscsi->flags & TRANS_EVENT) {
12441366
vscsi->state = WAIT_CONNECTION;
12451367
vscsi->flags &= PRESERVE_FLAG_FIELDS;
12461368
} else {
@@ -3792,8 +3914,16 @@ static struct se_portal_group *ibmvscsis_make_tpg(struct se_wwn *wwn,
37923914
{
37933915
struct ibmvscsis_tport *tport =
37943916
container_of(wwn, struct ibmvscsis_tport, tport_wwn);
3917+
u16 tpgt;
37953918
int rc;
37963919

3920+
if (strstr(name, "tpgt_") != name)
3921+
return ERR_PTR(-EINVAL);
3922+
rc = kstrtou16(name + 5, 0, &tpgt);
3923+
if (rc)
3924+
return ERR_PTR(rc);
3925+
tport->tport_tpgt = tpgt;
3926+
37973927
tport->releasing = false;
37983928

37993929
rc = core_tpg_register(&tport->tport_wwn, &tport->se_tpg,

‎drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ struct scsi_info {
262262
#define DISCONNECT_SCHEDULED 0x00800
263263
/* remove function is sleeping */
264264
#define CFG_SLEEPING 0x01000
265+
/* Register for Prepare for Suspend Transport Events */
266+
#define PREP_FOR_SUSPEND_ENABLED 0x02000
267+
/* Prepare for Suspend event sent */
268+
#define PREP_FOR_SUSPEND_PENDING 0x04000
269+
/* Resume from Suspend event sent */
270+
#define PREP_FOR_SUSPEND_ABORTED 0x08000
271+
/* Prepare for Suspend event overwrote another CRQ entry */
272+
#define PREP_FOR_SUSPEND_OVERWRITE 0x10000
265273
u32 flags;
266274
/* adapter lock */
267275
spinlock_t intr_lock;
@@ -272,6 +280,7 @@ struct scsi_info {
272280
/* used in crq, to tag what iu the response is for */
273281
u64 empty_iu_tag;
274282
uint new_state;
283+
uint resume_state;
275284
/* control block for the response queue timer */
276285
struct timer_cb rsp_q_timer;
277286
/* keep last client to enable proper accounting */
@@ -324,17 +333,29 @@ struct scsi_info {
324333
#define TARGET_STOP(VSCSI) (long)(((VSCSI)->state & DONT_PROCESS_STATE) | \
325334
((VSCSI)->flags & BLOCK))
326335

336+
#define PREP_FOR_SUSPEND_FLAGS (PREP_FOR_SUSPEND_ENABLED | \
337+
PREP_FOR_SUSPEND_PENDING | \
338+
PREP_FOR_SUSPEND_ABORTED | \
339+
PREP_FOR_SUSPEND_OVERWRITE)
340+
327341
/* flag bit that are not reset during disconnect */
328-
#define PRESERVE_FLAG_FIELDS 0
342+
#define PRESERVE_FLAG_FIELDS (PREP_FOR_SUSPEND_FLAGS)
329343

330344
#define vio_iu(IUE) ((union viosrp_iu *)((IUE)->sbuf->buf))
331345

332346
#define READ_CMD(cdb) (((cdb)[0] & 0x1F) == 8)
333347
#define WRITE_CMD(cdb) (((cdb)[0] & 0x1F) == 0xA)
334348

335349
#ifndef H_GET_PARTNER_INFO
336-
#define H_GET_PARTNER_INFO 0x0000000000000008LL
350+
#define H_GET_PARTNER_INFO 0x0000000000000008LL
351+
#endif
352+
#ifndef H_ENABLE_PREPARE_FOR_SUSPEND
353+
#define H_ENABLE_PREPARE_FOR_SUSPEND 0x000000000000001DLL
337354
#endif
355+
#ifndef H_READY_FOR_SUSPEND
356+
#define H_READY_FOR_SUSPEND 0x000000000000001ELL
357+
#endif
358+
338359

339360
#define h_copy_rdma(l, sa, sb, da, db) \
340361
plpar_hcall_norets(H_COPY_RDMA, l, sa, sb, da, db)

‎drivers/scsi/ibmvscsi_tgt/libsrp.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ enum srp_trans_event {
3030
UNUSED_FORMAT = 0,
3131
PARTNER_FAILED = 1,
3232
PARTNER_DEREGISTER = 2,
33-
MIGRATED = 6
33+
MIGRATED = 6,
34+
PREPARE_FOR_SUSPEND = 9,
35+
RESUME_FROM_SUSP = 0xA
3436
};
3537

3638
enum srp_status {
39+
CRQ_ENTRY_OVERWRITTEN = 0x20,
3740
HEADER_DESCRIPTOR = 0xF1,
3841
PING = 0xF5,
3942
PING_RESPONSE = 0xF6

‎drivers/scsi/qla2xxx/qla_target.c‎

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,36 +1874,13 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha,
18741874
struct abts_recv_from_24xx *abts, struct fc_port *sess)
18751875
{
18761876
struct qla_hw_data *ha = vha->hw;
1877-
struct se_session *se_sess = sess->se_sess;
18781877
struct qla_tgt_mgmt_cmd *mcmd;
1879-
struct qla_tgt_cmd *cmd;
1880-
struct se_cmd *se_cmd;
18811878
int rc;
1882-
bool found_lun = false;
1883-
unsigned long flags;
1884-
1885-
spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
1886-
list_for_each_entry(se_cmd, &se_sess->sess_cmd_list, se_cmd_list) {
1887-
if (se_cmd->tag == abts->exchange_addr_to_abort) {
1888-
found_lun = true;
1889-
break;
1890-
}
1891-
}
1892-
spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
18931879

1894-
/* cmd not in LIO lists, look in qla list */
1895-
if (!found_lun) {
1896-
if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) {
1897-
/* send TASK_ABORT response immediately */
1898-
qlt_24xx_send_abts_resp(ha->base_qpair, abts,
1899-
FCP_TMF_CMPL, false);
1900-
return 0;
1901-
} else {
1902-
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081,
1903-
"unable to find cmd in driver or LIO for tag 0x%x\n",
1904-
abts->exchange_addr_to_abort);
1905-
return -ENOENT;
1906-
}
1880+
if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) {
1881+
/* send TASK_ABORT response immediately */
1882+
qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_CMPL, false);
1883+
return 0;
19071884
}
19081885

19091886
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f,
@@ -1919,14 +1896,17 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha,
19191896
}
19201897
memset(mcmd, 0, sizeof(*mcmd));
19211898

1922-
cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd);
19231899
mcmd->sess = sess;
19241900
memcpy(&mcmd->orig_iocb.abts, abts, sizeof(mcmd->orig_iocb.abts));
19251901
mcmd->reset_count = ha->base_qpair->chip_reset;
19261902
mcmd->tmr_func = QLA_TGT_ABTS;
19271903
mcmd->qpair = ha->base_qpair;
19281904

1929-
rc = ha->tgt.tgt_ops->handle_tmr(mcmd, cmd->unpacked_lun, mcmd->tmr_func,
1905+
/*
1906+
* LUN is looked up by target-core internally based on the passed
1907+
* abts->exchange_addr_to_abort tag.
1908+
*/
1909+
rc = ha->tgt.tgt_ops->handle_tmr(mcmd, 0, mcmd->tmr_func,
19301910
abts->exchange_addr_to_abort);
19311911
if (rc != 0) {
19321912
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052,

‎drivers/scsi/qla2xxx/tcm_qla2xxx.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,13 @@ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, u64 lun,
600600
struct fc_port *sess = mcmd->sess;
601601
struct se_cmd *se_cmd = &mcmd->se_cmd;
602602
int transl_tmr_func = 0;
603+
int flags = TARGET_SCF_ACK_KREF;
603604

604605
switch (tmr_func) {
605606
case QLA_TGT_ABTS:
606607
pr_debug("%ld: ABTS received\n", sess->vha->host_no);
607608
transl_tmr_func = TMR_ABORT_TASK;
609+
flags |= TARGET_SCF_LOOKUP_LUN_FROM_TAG;
608610
break;
609611
case QLA_TGT_2G_ABORT_TASK:
610612
pr_debug("%ld: 2G Abort Task received\n", sess->vha->host_no);
@@ -637,7 +639,7 @@ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, u64 lun,
637639
}
638640

639641
return target_submit_tmr(se_cmd, sess->se_sess, NULL, lun, mcmd,
640-
transl_tmr_func, GFP_ATOMIC, tag, TARGET_SCF_ACK_KREF);
642+
transl_tmr_func, GFP_ATOMIC, tag, flags);
641643
}
642644

643645
static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)

0 commit comments

Comments
 (0)