Re: [PATCH 39/42] target: Call transport_new_cmd instead of adding to cmd queue

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

 



On Fri, 2011-05-27 at 12:07 -0700, Andy Grover wrote:
> This will cause transport_new_cmd to be executed in the calling thread's
> context, instead of the backstore thread's context. This saves two
> context switches per cmd.
> 
> Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
> ---

As Christoph mentioned earler, this original patch to enable your
iscsi-target optimization series breaks all non iscsi-target fabrics.
But hey, that is easy enough for me to fix now.  ;-)

Committed as 5bb520f61 with the following changes to skip patch #25/#26
for the wholesale target_*() naming for the moment, and make your
original change here optional based upon TFO->new_cmd_map() usage for
other fabric modules.

Thanks again Andy,

--nab

-----------------------------------------------------------------------

[PATCH] target: Add optional transport_generic_new_cmd instead of adding to cmd queue

This will cause transport_generic_new_cmd() to be optionally executed in the calling
thread's context, instead of the backstore thread's context.  This saves two
context switches per cmd, and assumes that fabric modules (like iscsi-target) who
do not provide a struct target_core_fabric_ops->new_cmd_map() in order to work
with existing non iscsi-target fabric modules.

Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
Reported-by: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
---
 drivers/target/target_core_transport.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 915b2ef..7596f6f 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -203,6 +203,7 @@ typedef int (*map_func_t)(struct se_task *, u32);

 static int transport_generic_write_pending(struct se_cmd *);
 static int transport_processing_thread(void *param);
+static int transport_generic_new_cmd(struct se_cmd *cmd);
 static int __transport_execute_tasks(struct se_device *dev);
 static void transport_complete_task_attr(struct se_cmd *cmd);
 static void transport_direct_request_timeout(struct se_cmd *cmd);
@@ -751,7 +752,7 @@ void transport_cmd_finish_abort_tmr(struct se_cmd *cmd)
        transport_generic_remove(cmd, 0, 0);
 }

-static void transport_add_cmd_to_queue(
+static int transport_add_cmd_to_queue(
        struct se_cmd *cmd,
        int t_state)
 {
@@ -775,6 +776,8 @@ static void transport_add_cmd_to_queue(

        atomic_inc(&qobj->queue_cnt);
        wake_up_interruptible(&qobj->thread_wq);
+
+       return 0;
 }

 static struct se_cmd *
@@ -1847,9 +1850,14 @@ int transport_generic_handle_cdb(
                printk(KERN_ERR "cmd->se_lun is NULL\n");
                return -EINVAL;
        }
-
-       transport_add_cmd_to_queue(cmd, TRANSPORT_NEW_CMD);
-       return 0;
+       /*
+        * Assume that target fabrics not presenting an cmd->se_tfo->new_cmd_map
+        * function pointer (like iscsi-target) want direct execution of
+        * transport_generic_new_cmd()
+        */
+       return (cmd->se_tfo->new_cmd_map) ?
+               transport_add_cmd_to_queue(cmd, TRANSPORT_NEW_CMD) :
+               transport_generic_new_cmd(cmd);
 }
 EXPORT_SYMBOL(transport_generic_handle_cdb);

-- 
1.7.2.5





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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux