Or Gerlitz wrote:
> I can't go over this max when applying my patch of lockless flow for 
> queuecommand / passthrough

this is the patch I was using till today when I started to suspect it doesn't 
yield any
or very little of IOPS over the rest of the patches. 


---
 drivers/infiniband/ulp/iser/iser_memory.c |    2 ++
 drivers/scsi/libiscsi.c                   |   26 ++++++++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)

Index: linux-2.6.33-rc4/drivers/scsi/libiscsi.c
===================================================================
--- linux-2.6.33-rc4.orig/drivers/scsi/libiscsi.c
+++ linux-2.6.33-rc4/drivers/scsi/libiscsi.c
@@ -354,7 +354,7 @@ static int iscsi_check_tmf_restrictions(
  * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set
  * fields like dlength or final based on how much data it sends
  */
-static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
+static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task, uint32_t 
next_cmdsn)
 {
        struct iscsi_conn *conn = task->conn;
        struct iscsi_session *session = conn->session;
@@ -475,10 +475,8 @@ static int iscsi_prep_scsi_cmd_pdu(struc
                return -EIO;
 
        task->state = ISCSI_TASK_RUNNING;
-       hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
-       session->cmdsn++;
+       hdr->cmdsn = task->cmdsn = cpu_to_be32(next_cmdsn);
 
-       conn->scsicmd_pdus_cnt++;
        ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x "
                          "itt 0x%x len %d bidi_len %d cmdsn %d win %d]\n",
                          scsi_bidi_cmnd(sc) ? "bidirectional" :
@@ -1454,6 +1452,7 @@ static int iscsi_data_xmit(struct iscsi_
 {
        struct iscsi_task *task;
        int rc = 0;
+       uint32_t next_cmdsn;
 
        spin_lock_bh(&conn->session->lock);
        if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
@@ -1497,7 +1496,10 @@ check_mgmt:
                        fail_scsi_task(conn->task, DID_IMM_RETRY);
                        continue;
                }
-               rc = iscsi_prep_scsi_cmd_pdu(conn->task);
+               next_cmdsn = conn->session->cmdsn;
+               conn->session->cmdsn++; /* FIXME - do it in one line of code */
+               conn->scsicmd_pdus_cnt++;
+               rc = iscsi_prep_scsi_cmd_pdu(conn->task, next_cmdsn);
                if (rc) {
                        if (rc == -ENOMEM || rc == -EACCES) {
                                list_add_tail(&conn->task->running,
@@ -1607,6 +1609,7 @@ int iscsi_queuecommand(struct scsi_cmnd 
        struct iscsi_session *session;
        struct iscsi_conn *conn;
        struct iscsi_task *task = NULL;
+       uint32_t next_cmdsn;
 
        sc->scsi_done = done;
        sc->result = 0;
@@ -1683,8 +1686,14 @@ int iscsi_queuecommand(struct scsi_cmnd 
        }
 
        if (!ihost->workq) {
-               reason = iscsi_prep_scsi_cmd_pdu(task);
+               next_cmdsn = session->cmdsn;
+               session->cmdsn++; /* FIXME - do it in one line of code */
+               session->queued_cmdsn++;
+               conn->scsicmd_pdus_cnt++;
+               spin_unlock(&session->lock);
+               reason = iscsi_prep_scsi_cmd_pdu(task, next_cmdsn);
                if (reason) {
+                       spin_lock(&session->lock); /* match error flow */
                        if (reason == -ENOMEM ||  reason == -EACCES) {
                                reason = FAILURE_OOM;
                                goto prepd_reject;
@@ -1694,6 +1703,7 @@ int iscsi_queuecommand(struct scsi_cmnd 
                        }
                }
                if (session->tt->xmit_task(task)) {
+                       spin_lock(&session->lock); /* match error flow */
                        session->cmdsn--;
                        reason = FAILURE_SESSION_NOT_READY;
                        goto prepd_reject;
@@ -1701,10 +1711,10 @@ int iscsi_queuecommand(struct scsi_cmnd 
        } else {
                list_add_tail(&task->running, &conn->cmdqueue);
                iscsi_conn_queue_work(conn);
+               session->queued_cmdsn++;
+               spin_unlock(&session->lock);
        }
 
-       session->queued_cmdsn++;
-       spin_unlock(&session->lock);
        spin_lock(host->host_lock);
        return 0;
 
Index: linux-2.6.33-rc4/drivers/infiniband/ulp/iser/iser_memory.c
===================================================================
--- linux-2.6.33-rc4.orig/drivers/infiniband/ulp/iser/iser_memory.c
+++ linux-2.6.33-rc4/drivers/infiniband/ulp/iser/iser_memory.c
@@ -402,8 +402,10 @@ int iser_reg_rdma_mem(struct iscsi_iser_
                         (unsigned long)regd_buf->reg.va,
                         (unsigned long)regd_buf->reg.len);
        } else { /* use FMR for multiple dma entries */
+               spin_lock(&ib_conn->lock); /* protect ib_conn->page_vec */
                iser_page_vec_build(mem, ib_conn->page_vec, ibdev);
                err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, 
&regd_buf->reg);
+               spin_unlock(&ib_conn->lock);
                if (err) {
                        iser_data_buf_dump(mem, ibdev);
                        iser_err("mem->dma_nents = %d (dlength = 0x%x)\n",

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to