[PATCH 2/3] qla2xxx: simplify command submission userspace offload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rename the free_work work structure in struct qla_cmd and use it to submit new
commands without requiring a struct qla_tgt_sess_work_param allocation and
going through qla_tgt_sched_sess_work.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: lio-core/drivers/scsi/qla2xxx/qla_target.c
===================================================================
--- lio-core.orig/drivers/scsi/qla2xxx/qla_target.c	2011-11-07 08:18:21.518318212 +0100
+++ lio-core/drivers/scsi/qla2xxx/qla_target.c	2011-11-07 08:22:38.677815514 +0100
@@ -80,6 +80,8 @@ enum fcp_resp_rsp_codes {
 #define FCP_PRI_SHIFT       3   /* priority field starts in bit 3 */
 #define FCP_PRI_RESVD_MASK  0x80        /* reserved bits in priority field */
 
+static void qla_tgt_exec_cmd_work(struct work_struct *work);
+
 /*
  * This driver calls qla2x00_req_pkt() and qla2x00_issue_marker(), which
  * must be called under HW lock and could unlock/lock it inside.
@@ -1145,11 +1147,8 @@ static int qla_tgt_sched_sess_work(struc
 		" to find session for param %p (size %d, tgt %p)\n", type, prm, param,
 		param_size, tgt);
 
-	BUG_ON(param_size > (sizeof(*prm) -
-		offsetof(struct qla_tgt_sess_work_param, cmd)));
-
 	prm->type = type;
-	memcpy(&prm->cmd, param, param_size);
+	memcpy(&prm->tm_iocb, param, param_size);
 
 	spin_lock_irqsave(&tgt->sess_work_lock, flags);
 	if (!tgt->sess_works_pending)
@@ -3180,11 +3179,10 @@ out_sched:
 		res = -EBUSY;
 		goto out_free_cmd;
 	}
-	res = qla_tgt_sched_sess_work(tgt, QLA_TGT_SESS_WORK_CMD, &cmd, sizeof(cmd));
-	if (res != 0)
-		qla_tgt_free_cmd(cmd);
 
-	return res;
+	INIT_WORK(&cmd->work, qla_tgt_exec_cmd_work);
+	schedule_work(&cmd->work);
+	return 0;
 }
 
 /* ha->hardware_lock supposed to be held on entry */
@@ -4545,20 +4543,18 @@ retry:
 	return sess;
 }
 
-static void qla_tgt_exec_cmd_work(struct qla_tgt *tgt,
-	struct qla_tgt_sess_work_param *prm)
+static void qla_tgt_exec_cmd_work(struct work_struct *work)
 {
+	struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
+	struct qla_tgt *tgt = cmd->tgt;
 	struct scsi_qla_host *vha = tgt->vha;
 	struct qla_hw_data *ha = vha->hw;
 	struct qla_tgt_sess *sess = NULL;
 	unsigned long flags;
 	uint8_t *s_id = NULL; /* to hide compiler warnings */
 	int rc, loop_id = -1; /* to hide compiler warnings */
-	struct qla_tgt_cmd *cmd = prm->cmd;
 	atio_from_isp_t *a = (atio_from_isp_t *)&cmd->atio;
 
-	ql_dbg(ql_dbg_tgt_mgt, vha, 0xe14b, "qla_tgt_exec_sess_work() processing -> prm %p\n", prm);
-
 	spin_lock_irqsave(&ha->hardware_lock, flags);
 
 	if (tgt->tgt_stop)
@@ -4806,9 +4802,6 @@ static void qla_tgt_sess_work_fn(struct
 		spin_unlock_irqrestore(&tgt->sess_work_lock, flags);
 
 		switch (prm->type) {
-		case QLA_TGT_SESS_WORK_CMD:
-			qla_tgt_exec_cmd_work(tgt, prm);
-			break;
 		case QLA_TGT_SESS_WORK_ABORT:
 			qla_tgt_abort_work(tgt, prm);
 			break;
Index: lio-core/drivers/scsi/qla2xxx/qla_target.h
===================================================================
--- lio-core.orig/drivers/scsi/qla2xxx/qla_target.h	2011-11-07 08:18:21.538315262 +0100
+++ lio-core/drivers/scsi/qla2xxx/qla_target.h	2011-11-07 08:22:16.197824345 +0100
@@ -919,7 +919,7 @@ struct qla_tgt_cmd {
 	atomic_t cmd_free;
 	struct completion cmd_stop_free_comp;
 	struct se_cmd se_cmd;
-	struct work_struct free_work;
+	struct work_struct work;
 	/* Sense buffer that will be mapped into outgoing status */
 	unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER];
 
@@ -949,13 +949,11 @@ struct qla_tgt_cmd {
 struct qla_tgt_sess_work_param {
 	struct list_head sess_works_list_entry;
 
-#define QLA_TGT_SESS_WORK_CMD	0
 #define QLA_TGT_SESS_WORK_ABORT	1
 #define QLA_TGT_SESS_WORK_TM	2
 	int type;
 
 	union {
-		struct qla_tgt_cmd *cmd;
 		abts_recv_from_24xx_t abts;
 		imm_ntfy_from_isp_t tm_iocb;
 		atio_from_isp_t tm_iocb2;
Index: lio-core/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
===================================================================
--- lio-core.orig/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c	2011-11-07 08:17:55.617815456 +0100
+++ lio-core/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c	2011-11-07 08:18:10.970037627 +0100
@@ -386,8 +386,7 @@ u32 tcm_qla2xxx_tpg_get_inst_index(struc
 
 static void tcm_qla2xxx_complete_free(struct work_struct *work)
 {
-	struct qla_tgt_cmd *cmd = container_of(work,
-				struct qla_tgt_cmd, free_work);
+	struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
 
 	transport_generic_free_cmd(&cmd->se_cmd, 0);
 }
@@ -421,8 +420,8 @@ void tcm_qla2xxx_free_cmd(struct qla_tgt
 	atomic_set(&cmd->cmd_free, 1);
 	smp_mb__after_atomic_dec();
 
-	INIT_WORK(&cmd->free_work, tcm_qla2xxx_complete_free);
-	queue_work(tcm_qla2xxx_free_wq, &cmd->free_work);
+	INIT_WORK(&cmd->work, tcm_qla2xxx_complete_free);
+	queue_work(tcm_qla2xxx_free_wq, &cmd->work);
 }
 
 /*

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux