From 695434e1cbd57f404110bf4ab187a5127ffd79bb Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Fri, 3 Jun 2011 20:59:19 -0700 Subject: target: Add transport_handle_cdb_direct optimization This patch adds a transport_handle_cdb_direct() optimization for mapping and queueing tasks directly from within fabric processing context by calling the newly exported transport_generic_new_cmd(). This currently expects to be called from process context only, and will fail if called within interrupt context. This patch also leaves transport_generic_handle_cdb() unmodified for the moment to function as expected with existing tcm_fc and ib_srpt fabrics, and will be removed once these have been converted and tested with v4.1 code using transport_handle_cdb_direct(). Based on Andy's original patch here: [PATCH 39/42] target: Call transport_new_cmd instead of adding to cmd queue Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_transport.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers/target') diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index d42a98e4725..1ae6eb7a621 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1842,11 +1842,35 @@ 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; } EXPORT_SYMBOL(transport_generic_handle_cdb); +/* + * Used by fabric module frontends to queue tasks directly. + * Many only be used from process context only + */ +int transport_handle_cdb_direct( + struct se_cmd *cmd) +{ + if (!cmd->se_lun) { + dump_stack(); + printk(KERN_ERR "cmd->se_lun is NULL\n"); + return -EINVAL; + } + if (in_interrupt()) { + dump_stack(); + printk(KERN_ERR "transport_generic_handle_cdb cannot be called" + " from interrupt context\n"); + return -EINVAL; + } + + return transport_generic_new_cmd(cmd); +} +EXPORT_SYMBOL(transport_handle_cdb_direct); + /* * Used by fabric module frontends defining a TFO->new_cmd_map() caller * to queue up a newly setup se_cmd w/ TRANSPORT_NEW_CMD_MAP in order to -- cgit v1.2.3-18-g5258