Skip to content

Commit 605e740

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: qla2xxx: Move sess cmd list/lock to driver
Except for debug output in the shutdown path, tcm_qla2xxx is the only driver using the se_session sess_cmd_list. Move the list to that driver to facilitate removing the sess_cmd_lock from the main I/O path for the rest of the drivers. Link: https://lore.kernel.org/r/[email protected] Cc: Nilesh Javali <[email protected]> Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 27b0efd commit 605e740

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,6 +2493,8 @@ typedef struct fc_port {
24932493
int generation;
24942494

24952495
struct se_session *se_sess;
2496+
struct list_head sess_cmd_list;
2497+
spinlock_t sess_cmd_lock;
24962498
struct kref sess_kref;
24972499
struct qla_tgt *tgt;
24982500
unsigned long expires;

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4974,6 +4974,9 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
49744974
INIT_LIST_HEAD(&fcport->gnl_entry);
49754975
INIT_LIST_HEAD(&fcport->list);
49764976

4977+
INIT_LIST_HEAD(&fcport->sess_cmd_list);
4978+
spin_lock_init(&fcport->sess_cmd_lock);
4979+
49774980
return fcport;
49784981
}
49794982

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,6 +4292,7 @@ static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t *vha,
42924292

42934293
cmd->cmd_type = TYPE_TGT_CMD;
42944294
memcpy(&cmd->atio, atio, sizeof(*atio));
4295+
INIT_LIST_HEAD(&cmd->sess_cmd_list);
42954296
cmd->state = QLA_TGT_STATE_NEW;
42964297
cmd->tgt = vha->vha_tgt.qla_tgt;
42974298
qlt_incr_num_pend_cmds(vha);

drivers/scsi/qla2xxx/qla_target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ struct qla_tgt_cmd {
856856
uint8_t cmd_type;
857857
uint8_t pad[7];
858858
struct se_cmd se_cmd;
859+
struct list_head sess_cmd_list;
859860
struct fc_port *sess;
860861
struct qla_qpair *qpair;
861862
uint32_t reset_count;

drivers/scsi/qla2xxx/tcm_qla2xxx.c

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ static void tcm_qla2xxx_free_mcmd(struct qla_tgt_mgmt_cmd *mcmd)
255255
static void tcm_qla2xxx_complete_free(struct work_struct *work)
256256
{
257257
struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
258+
unsigned long flags;
258259

259260
cmd->cmd_in_wq = 0;
260261

@@ -265,6 +266,10 @@ static void tcm_qla2xxx_complete_free(struct work_struct *work)
265266
cmd->trc_flags |= TRC_CMD_FREE;
266267
cmd->cmd_sent_to_fw = 0;
267268

269+
spin_lock_irqsave(&cmd->sess->sess_cmd_lock, flags);
270+
list_del_init(&cmd->sess_cmd_list);
271+
spin_unlock_irqrestore(&cmd->sess->sess_cmd_lock, flags);
272+
268273
transport_generic_free_cmd(&cmd->se_cmd, 0);
269274
}
270275

@@ -451,13 +456,14 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
451456
struct se_portal_group *se_tpg;
452457
struct tcm_qla2xxx_tpg *tpg;
453458
#endif
454-
int flags = TARGET_SCF_ACK_KREF;
459+
int target_flags = TARGET_SCF_ACK_KREF;
460+
unsigned long flags;
455461

456462
if (bidi)
457-
flags |= TARGET_SCF_BIDI_OP;
463+
target_flags |= TARGET_SCF_BIDI_OP;
458464

459465
if (se_cmd->cpuid != WORK_CPU_UNBOUND)
460-
flags |= TARGET_SCF_USE_CPUID;
466+
target_flags |= TARGET_SCF_USE_CPUID;
461467

462468
sess = cmd->sess;
463469
if (!sess) {
@@ -479,11 +485,15 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
479485
return 0;
480486
}
481487
#endif
482-
483488
cmd->qpair->tgt_counters.qla_core_sbt_cmd++;
489+
490+
spin_lock_irqsave(&sess->sess_cmd_lock, flags);
491+
list_add_tail(&cmd->sess_cmd_list, &sess->sess_cmd_list);
492+
spin_unlock_irqrestore(&sess->sess_cmd_lock, flags);
493+
484494
return target_submit_cmd(se_cmd, se_sess, cdb, &cmd->sense_buffer[0],
485-
cmd->unpacked_lun, data_length, fcp_task_attr,
486-
data_dir, flags);
495+
cmd->unpacked_lun, data_length, fcp_task_attr,
496+
data_dir, target_flags);
487497
}
488498

489499
static void tcm_qla2xxx_handle_data_work(struct work_struct *work)
@@ -617,25 +627,20 @@ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, u64 lun,
617627
static struct qla_tgt_cmd *tcm_qla2xxx_find_cmd_by_tag(struct fc_port *sess,
618628
uint64_t tag)
619629
{
620-
struct qla_tgt_cmd *cmd = NULL;
621-
struct se_cmd *secmd;
630+
struct qla_tgt_cmd *cmd;
622631
unsigned long flags;
623632

624633
if (!sess->se_sess)
625634
return NULL;
626635

627-
spin_lock_irqsave(&sess->se_sess->sess_cmd_lock, flags);
628-
list_for_each_entry(secmd, &sess->se_sess->sess_cmd_list, se_cmd_list) {
629-
/* skip task management functions, including tmr->task_cmd */
630-
if (secmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
631-
continue;
632-
633-
if (secmd->tag == tag) {
634-
cmd = container_of(secmd, struct qla_tgt_cmd, se_cmd);
635-
break;
636-
}
636+
spin_lock_irqsave(&sess->sess_cmd_lock, flags);
637+
list_for_each_entry(cmd, &sess->sess_cmd_list, sess_cmd_list) {
638+
if (cmd->se_cmd.tag == tag)
639+
goto done;
637640
}
638-
spin_unlock_irqrestore(&sess->se_sess->sess_cmd_lock, flags);
641+
cmd = NULL;
642+
done:
643+
spin_unlock_irqrestore(&sess->sess_cmd_lock, flags);
639644

640645
return cmd;
641646
}
@@ -765,11 +770,19 @@ static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
765770

766771
static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
767772
{
768-
struct qla_tgt_cmd *cmd = container_of(se_cmd,
769-
struct qla_tgt_cmd, se_cmd);
773+
struct qla_tgt_cmd *cmd;
774+
unsigned long flags;
770775

771-
if (qlt_abort_cmd(cmd))
776+
if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
772777
return;
778+
779+
cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd);
780+
781+
spin_lock_irqsave(&cmd->sess->sess_cmd_lock, flags);
782+
list_del_init(&cmd->sess_cmd_list);
783+
spin_unlock_irqrestore(&cmd->sess->sess_cmd_lock, flags);
784+
785+
qlt_abort_cmd(cmd);
773786
}
774787

775788
static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *,

0 commit comments

Comments
 (0)