target: .40 bugfixes+changes (round 1)
Subsystems (2)
cover target: .40 bugfixes+changes (round 1)
From: Nicholas Bellinger <[email protected]>
Hi James & Co,
This series is the first round of target core .v40 changes containing the four original bugfixes for .39 required for tcm_fc(openfcoe) HW offload and other in-flight HW drivers to function properly. This series was originally posted here:
[PATCH-v2 0/4] Bugfixes for .39-rc8
http://marc.info/?l=linux-scsi&m=130514011321906&w=2
As before, the first four patches should be backported to .39.y and 38.y..
For your convience, this original four part series has been merged with two other conversion patches requested by Mike and Christoph to be fixed ahead of the iscsi-target merge. This includes dropping the legacy target_core_fabric_ops->pack_lun() call for REPORT_LUNs in favor of int_to_scsilun(), and converting from libsas.h:TASK_ATTR usage to proper scsi_tcq.h:MSG_*_TAG for target core.
The latter two patches also include conversion for the two current scsi-misc upstream fabric modules: tcm_loop and tcm_fc(openfcoe).
This patch has been made against the latest scsi-misc HEAD:
commit 6ad11eaa8a689a27e0c99905bcf800a37cd432a0
Author: Joe Carnuccio <[email protected]> Date: Tue May 10 11:30:16 2011 -0700
[SCSI] qla2xxx: Refactor call to qla2xxx_read_sfp for thermal temperature.
This series is available directly from git here:
git://git.kernel.org/pub/scm/linux/kernel/git/nab/scsi-post-merge-2.6.git for-40-target
Please review and merge.
Thanks!
--nab
Nicholas Bellinger (6):
target: Fix multi task->task_sg[] chaining logic bug
target: Fix interrupt context bug with stats_lock and
core_tmr_alloc_req
target: Fix bug with task_sg chained transport_free_dev_tasks release
target: Fix task->task_execute_queue=1 clear bug + LUN_RESET OOPs
target: Convert REPORT_LUNs to use int_to_scsilun
target: Convert TASK_ATTR to scsi_tcq.h definitions
drivers/target/loopback/tcm_loop.c | 25 +++--------- drivers/target/target_core_configfs.c | 4 -- drivers/target/target_core_device.c | 29 +++---------- drivers/target/target_core_pscsi.c | 4 +- drivers/target/target_core_tmr.c | 7 ++- drivers/target/target_core_transport.c | 68 ++++++++++++++++++++---------- drivers/target/tcm_fc/tfc_cmd.c | 20 +++++++++- drivers/target/tcm_fc/tfc_conf.c | 8 ---- include/scsi/scsi_tcq.h | 1 + include/target/target_core_base.h | 1 + include/target/target_core_fabric_ops.h | 1 - include/target/target_core_transport.h | 1 + 12 files changed, 86 insertions(+), 83 deletions(-)
Signature · 1 line
1.7.5.1
PATCH 1/6 target: Fix multi task->task_sg[] chaining logic bug
From: Nicholas Bellinger <[email protected]>
This patch fixes a bug in transport_do_task_sg_chain() used by HW target mode modules with sg_chain() to provide a single sg_next() walkable memory layout for use with pci_map_sg() and friends. This patch addresses an issue with mapping multiple small block max_sector tasks across multiple struct se_task->task_sg[] mappings for HW target mode operation.
This was causing OOPs with (cmd->t_task->t_tasks_no > 1) I/O traffic for HW target drivers using transport_do_task_sg_chain(), and has been tested so far with tcm_fc(openfcoe), tcm_qla2xxx, and ib_srpt fabrics with t_tasks_no > 1 IBLOCK backends using a smaller max_sectors to trigger the original issue.
--- drivers/target/target_core_transport.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-)
drivers/target/target_core_transport.c +15 -11
@@ -4776,18 +4776,20 @@ void transport_do_task_sg_chain(struct se_cmd *cmd) sg_end_cur->page_link &= ~0x02 ;sg_chain (sg_head, task_sg_num, sg_head_cur); - sg_count += (task->task_sg_num +1 ); - }else sg_count += task->task_sg_num; + task_sg_num = (task->task_sg_num +1 ); + }else { +sg_chain (sg_head, task_sg_num, sg_head_cur); + sg_count += task->task_sg_num; + task_sg_num = task->task_sg_num; + } sg_head = sg_head_cur; sg_link = sg_link_cur; - task_sg_num = task->task_sg_num;continue ; } sg_head = sg_first = &task->task_sg[0 ]; sg_link = &task->task_sg[task->task_sg_num]; - task_sg_num = task->task_sg_num;/* * Check for single task.. */
@@ -4798,9 +4800,12 @@ void transport_do_task_sg_chain(struct se_cmd *cmd)*/ sg_end = &task->task_sg[task->task_sg_num -1 ]; sg_end->page_link &= ~0x02 ; - sg_count += (task->task_sg_num +1 ); - }else sg_count += task->task_sg_num; + task_sg_num = (task->task_sg_num +1 ); + }else { + sg_count += task->task_sg_num; + task_sg_num = task->task_sg_num; + } }/* * Setup the starting pointer and total t_tasks_sg_linked_no including
@@ -4809,21 +4814,20 @@ void transport_do_task_sg_chain(struct se_cmd *cmd)T_TASK (cmd)->t_tasks_sg_chained = sg_first;T_TASK (cmd)->t_tasks_sg_chained_no = sg_count; -DEBUG_CMD_M ("Setup T_TASK(cmd)->t_tasks_sg_chained: %p and" -" t_tasks_sg_chained_no: %u\n" ,T_TASK (cmd)->t_tasks_sg_chained, +DEBUG_CMD_M ("Setup cmd: %p T_TASK(cmd)->t_tasks_sg_chained: %p and" +" t_tasks_sg_chained_no: %u\n" , cmd,T_TASK (cmd)->t_tasks_sg_chained,T_TASK (cmd)->t_tasks_sg_chained_no);for_each_sg (T_TASK (cmd)->t_tasks_sg_chained, sg,T_TASK (cmd)->t_tasks_sg_chained_no, i) { -DEBUG_CMD_M ("SG: %p page: %p length: %d offset: %d\n" , - sg,sg_page (sg), sg->length, sg->offset); +DEBUG_CMD_M ("SG[%d]: %p page: %p length: %d offset: %d, magic: 0x%08x\n" , + i, sg,sg_page (sg), sg->length, sg->offset, sg->sg_magic);if (sg_is_chain (sg))DEBUG_CMD_M ("SG: %p sg_is_chain=1\n" , sg);if (sg_is_last (sg))DEBUG_CMD_M ("SG: %p sg_is_last=1\n" , sg); } - }EXPORT_SYMBOL (transport_do_task_sg_chain);
Signature · 1 line
1.7.5.1
PATCH 2/6 target: Fix interrupt context bug with stats_lock and core_tmr_alloc_req
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch fixes two bugs wrt to the interrupt context usage of target core with HW target mode drivers. It first converts the usage of struct se_device->stats_lock in transport_get_lun_for_cmd() and core_tmr_lun_reset() to properly use spin_lock_irq() to address an BUG with CONFIG_LOCKDEP_SUPPORT=y enabled.
This patch also adds a 'in_interrupt()' check to allow GFP_ATOMIC usage from core_tmr_alloc_req() to fix a 'sleeping in interrupt context' BUG with HW target fabrics that require this logic to function.
--- drivers/target/target_core_device.c | 4 ++-- drivers/target/target_core_tmr.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/target/target_core_device.c +2 -2
@@ -150,13 +150,13 @@ out: {struct se_device *dev = se_lun->lun_se_dev; -spin_lock (&dev->stats_lock); +spin_lock_irq (&dev->stats_lock); dev->num_cmds++;if (se_cmd->data_direction ==DMA_TO_DEVICE ) dev->write_bytes += se_cmd->data_length;else if (se_cmd->data_direction ==DMA_FROM_DEVICE ) dev->read_bytes += se_cmd->data_length; -spin_unlock (&dev->stats_lock); +spin_unlock_irq (&dev->stats_lock); }/*
drivers/target/target_core_tmr.c +4 -3
@@ -55,7 +55,8 @@ struct se_tmr_req *core_tmr_alloc_req( {struct se_tmr_req *tmr; - tmr =kmem_cache_zalloc (se_tmr_req_cache,GFP_KERNEL ); + tmr =kmem_cache_zalloc (se_tmr_req_cache, (in_interrupt ()) ? +GFP_ATOMIC :GFP_KERNEL );if (!(tmr)) {printk (KERN_ERR "Unable to allocate struct se_tmr_req\n" );return ERR_PTR (-ENOMEM );
@@ -398,9 +399,9 @@ int core_tmr_lun_reset(printk (KERN_INFO "LUN_RESET: SCSI-2 Released reservation\n" ); } -spin_lock (&dev->stats_lock); +spin_lock_irq (&dev->stats_lock); dev->num_resets++; -spin_unlock (&dev->stats_lock); +spin_unlock_irq (&dev->stats_lock); DEBUG_LR("LUN_RESET: %s for [%s] Complete\n", (preempt_and_abort_list) ? "Preempt" : "TMR",
Signature · 1 line
1.7.5.1
PATCH 3/6 target: Fix bug with task_sg chained transport_free_dev_tasks release
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch addresses a bug in the target core release path for HW operation where transport_free_dev_tasks() was incorrectly being called from transport_lun_remove_cmd() while releasing a se_cmd reference and calling struct target_core_fabric_ops->queue_data_in().
This would result in a OOPs with HW target mode when the release of se_task->task_sg[] would happen before pci_unmap_sg() can be called in HW target mode fabric module code. This patch addresses the issue by moving transport_free_dev_tasks() from transport_lun_remove_cmd() into transport_generic_free_cmd(), and adding TRANSPORT_FREE_CMD_INTR and transport_generic_free_cmd_intr() to allow se_cmd descriptor release to happen fromfrom within transport_processing_thread() process context when release of se_cmd is not possible from HW interrupt context.
--- drivers/target/target_core_transport.c | 13 ++++++++++++- include/target/target_core_base.h | 1 + include/target/target_core_transport.h | 1 + 3 files changed, 14 insertions(+), 1 deletions(-)
drivers/target/target_core_transport.c +12 -1
@@ -762,7 +762,6 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)transport_all_task_dev_remove_state (cmd);spin_unlock_irqrestore (&T_TASK (cmd)->t_state_lock, flags); -transport_free_dev_tasks (cmd); check_lun:spin_lock_irqsave (&lun->lun_cmd_lock, flags);
@@ -2058,6 +2057,13 @@ int transport_generic_handle_tmr( }EXPORT_SYMBOL (transport_generic_handle_tmr); +void transport_generic_free_cmd_intr ( +struct se_cmd *cmd) +{ +transport_add_cmd_to_queue (cmd,TRANSPORT_FREE_CMD_INTR ); +} +EXPORT_SYMBOL (transport_generic_free_cmd_intr); +static int transport_stop_tasks_for_cmd (struct se_cmd *cmd) {struct se_task *task, *task_tmp;
@@ -5301,6 +5307,8 @@ void transport_generic_free_cmd(if (wait_for_tasks && cmd->transport_wait_for_tasks) cmd->transport_wait_for_tasks (cmd,0 ,0 ); +transport_free_dev_tasks (cmd); +transport_generic_remove (cmd, release_to_pool, session_reinstatement); }
@@ -6136,6 +6144,9 @@ get_cmd:case TRANSPORT_REMOVE :transport_generic_remove (cmd,1 ,0 );break ; +case TRANSPORT_FREE_CMD_INTR : +transport_generic_free_cmd (cmd,0 ,1 ,0 ); +break ;case TRANSPORT_PROCESS_TMR :transport_generic_do_tmr (cmd);break ;
include/target/target_core_base.h +1 -0
@@ -98,6 +98,7 @@ enum transport_state_table {TRANSPORT_REMOVE =14 ,TRANSPORT_FREE =15 ,TRANSPORT_NEW_CMD_MAP =16 , + TRANSPORT_FREE_CMD_INTR = 17, };/* Used for struct se_cmd->se_cmd_flags */
include/target/target_core_transport.h +1 -0
@@ -172,6 +172,7 @@ extern int transport_generic_handle_cdb_map(struct se_cmd *);extern int transport_generic_handle_data (struct se_cmd *);extern void transport_new_cmd_failure (struct se_cmd *);extern int transport_generic_handle_tmr (struct se_cmd *); +extern void transport_generic_free_cmd_intr (struct se_cmd *);extern void __transport_stop_task_timer (struct se_task *,unsigned long *);extern unsigned char transport_asciihex_to_binaryhex (unsigned char val[2 ]); extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32,
Signature · 1 line
1.7.5.1
PATCH 4/6 target: Fix task->task_execute_queue=1 clear bug + LUN_RESET OOPs
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch fixes a bug where task->task_execute_queue=1 was not being cleared once se_task had been removed from se_device->execute_task_list, resulting in an OOPs in core_tmr_lun_reset() for the task->task_active=0 case where transport_remove_task_from_execute_queue() was incorrectly being called.
This patch fixes two cases in transport_get_task_from_execute_queue() and transport_remove_task_from_execute_queue() to properly clear task->task_execute_queue=0 once list_del(&task->t_execute_list) has been called.
It also adds an explict check in transport_remove_task_from_execute_queue() to dump_stack + return if called with task->task_execute_queue=0.
--- drivers/target/target_core_transport.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/target/target_core_transport.c +7 -0
@@ -1194,6 +1194,7 @@ transport_get_task_from_execute_queue(struct se_device *dev)break ;list_del (&task->t_execute_list); +atomic_set (&task->task_execute_queue,0 );atomic_dec (&dev->execute_tasks);return task;
@@ -1209,8 +1210,14 @@ void transport_remove_task_from_execute_queue( {unsigned long flags; +if (atomic_read (&task->task_execute_queue) ==0 ) { +dump_stack (); +return ; + } +spin_lock_irqsave (&dev->execute_task_lock, flags);list_del (&task->t_execute_list); +atomic_set (&task->task_execute_queue,0 );atomic_dec (&dev->execute_tasks);spin_unlock_irqrestore (&dev->execute_task_lock, flags); }
Signature · 1 line
1.7.5.1
PATCH 5/6 target: Convert REPORT_LUNs to use int_to_scsilun
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch converts transport_core_report_lun_response() to use drivers/scsi/scsi_scan.c:int_to_scsilun instead of using the struct target_core_fabric_ops->pack_lun() fabric provided API vector.
It also removes the tfo->pack_lun check from target_fabric_tf_ops_check() and removes from struct target_core_fabric_ops->pack_lun() from target_core_fabric_ops.h, and the following mainline scsi-misc fabric modules:
*) tcm_loop: Drop tcm_loop_pack_lun() usage
*) tcm_fc: Drop ft_pack_lun() usage
--- drivers/target/loopback/tcm_loop.c | 13 ------------- drivers/target/target_core_configfs.c | 4 ---- drivers/target/target_core_device.c | 25 +++++-------------------- drivers/target/tcm_fc/tfc_conf.c | 8 -------- include/target/target_core_fabric_ops.h | 1 - 5 files changed, 5 insertions(+), 46 deletions(-)
drivers/target/loopback/tcm_loop.c +0 -13
@@ -939,18 +939,6 @@ static u16 tcm_loop_get_fabric_sense_len(void)return 0 ; } -static u64 tcm_loop_pack_lun (unsigned int lun) -{ -u64 result; - -/* LSB of lun into byte 1 big-endian */ - result = ((lun &0xff ) <<8 ); -/* use flat space addressing method */ - result |=0x40 | ((lun >>8 ) &0x3f ); - -return cpu_to_le64 (result); -} -static char *tcm_loop_dump_proto_id (struct tcm_loop_hba *tl_hba) {switch (tl_hba->tl_proto_id) {
@@ -1481,7 +1469,6 @@ static int tcm_loop_register_configfs(void) fabric->tf_ops.set_fabric_sense_len = &tcm_loop_set_fabric_sense_len; fabric->tf_ops.get_fabric_sense_len = &tcm_loop_get_fabric_sense_len; fabric->tf_ops.is_state_remove = &tcm_loop_is_state_remove; - fabric->tf_ops.pack_lun = &tcm_loop_pack_lun; tf_cg = &fabric->tf_group;/*
drivers/target/target_core_configfs.c +0 -4
@@ -497,10 +497,6 @@ static int target_fabric_tf_ops_check(printk (KERN_ERR "Missing tfo->is_state_remove()\n" );return -EINVAL ; } -if (!(tfo->pack_lun)) { -printk (KERN_ERR "Missing tfo->pack_lun()\n" ); -return -EINVAL ; - }/* * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn() * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in
drivers/target/target_core_device.c +5 -20
@@ -38,6 +38,7 @@#include <net/sock.h> #include <net/tcp.h> #include <scsi/scsi.h> +#include <scsi/scsi_device.h> #include <target/target_core_base.h> #include <target/target_core_device.h>
@@ -658,8 +659,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)struct se_session *se_sess =SE_SESS (se_cmd);struct se_task *se_task;unsigned char *buf = (unsigned char *)T_TASK (se_cmd)->t_task_buf; -u32 cdb_offset =0 , lun_count =0 , offset =8 ; -u64 i, lun; +u32 cdb_offset =0 , lun_count =0 , offset =8 , i;list_for_each_entry (se_task, &T_TASK (se_cmd)->t_task_list, t_list)break ;
@@ -675,15 +675,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)* a $FABRIC_MOD. In that case, report LUN=0 only. */ if (!(se_sess)) { - lun =0 ; - buf[offset++] = ((lun >>56 ) &0xff ); - buf[offset++] = ((lun >>48 ) &0xff ); - buf[offset++] = ((lun >>40 ) &0xff ); - buf[offset++] = ((lun >>32 ) &0xff ); - buf[offset++] = ((lun >>24 ) &0xff ); - buf[offset++] = ((lun >>16 ) &0xff ); - buf[offset++] = ((lun >>8 ) &0xff ); - buf[offset++] = (lun &0xff ); +int_to_scsilun (0 , (struct scsi_lun *)&buf[offset]); lun_count =1 ; goto done; }
@@ -703,15 +695,8 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)if ((cdb_offset +8 ) >= se_cmd->data_length)continue ; - lun =cpu_to_be64 (CMD_TFO (se_cmd)->pack_lun (deve->mapped_lun)); - buf[offset++] = ((lun >>56 ) &0xff ); - buf[offset++] = ((lun >>48 ) &0xff ); - buf[offset++] = ((lun >>40 ) &0xff ); - buf[offset++] = ((lun >>32 ) &0xff ); - buf[offset++] = ((lun >>24 ) &0xff ); - buf[offset++] = ((lun >>16 ) &0xff ); - buf[offset++] = ((lun >>8 ) &0xff ); - buf[offset++] = (lun &0xff ); +int_to_scsilun (deve->mapped_lun, (struct scsi_lun *)&buf[offset]); + offset +=8 ; cdb_offset +=8 ; }spin_unlock_irq (&SE_NODE_ACL (se_sess)->device_list_lock);
drivers/target/tcm_fc/tfc_conf.c +0 -8
@@ -519,13 +519,6 @@ static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg)return tpg->index; } -static u64 ft_pack_lun (unsigned int index) -{ -WARN_ON (index >=256 ); -/* Caller wants this byte-swapped */ -return cpu_to_le64 ((index &0xff ) <<8 ); -} -static struct target_core_fabric_ops ft_fabric_ops = { .get_fabric_name = ft_get_fabric_name, .get_fabric_proto_ident = fc_get_fabric_proto_ident,
@@ -564,7 +557,6 @@ static struct target_core_fabric_ops ft_fabric_ops = { .get_fabric_sense_len = ft_get_fabric_sense_len, .set_fabric_sense_len = ft_set_fabric_sense_len, .is_state_remove = ft_is_state_remove, - .pack_lun = ft_pack_lun,/* * Setup function pointers for generic logic in * target_core_fabric_configfs.c
include/target/target_core_fabric_ops.h +0 -1
@@ -77,7 +77,6 @@ struct target_core_fabric_ops {u16 (*set_fabric_sense_len)(struct se_cmd *,u32 );u16 (*get_fabric_sense_len)(void);int (*is_state_remove)(struct se_cmd *); -u64 (*pack_lun)(unsigned int );/* * fabric module calls for target_core_fabric_configfs.c */
Signature · 1 line
1.7.5.1
James Bottomley
maintainerRe: [PATCH 5/6] target: Convert REPORT_LUNs to use int_to_scsilun
Quoted 11 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This patch converts
transport_core_report_lun_response()to use drivers/scsi/scsi_scan.c:int_to_scsilun instead of using the structtarget_core_fabric_ops->pack_lun()fabric provided API vector.It also removes the
tfo->pack_luncheck fromtarget_fabric_tf_ops_check()and removes from structtarget_core_fabric_ops->pack_lun()fromtarget_core_fabric_ops.h, and the following mainline scsi-misc fabric modules:
Quoted 5 lines
*)
tcm_loop: Droptcm_loop_pack_lun()usage
*)tcm_fc: Dropft_pack_lun()usageReported-by Mike Christie <[email protected]>Signed-off-by Nicholas A. Bellinger <[email protected]>
There's no way this or the following patch count as bug fixes. They're converging hand rolled functions and definitions (which is good, but not a bug fix).
James
Re: [PATCH 5/6] target: Convert REPORT_LUNs to use int_to_scsilun
Quoted 15 lines · James Bottomley
Quoted 14 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This patch converts
transport_core_report_lun_response()to use drivers/scsi/scsi_scan.c:int_to_scsilun instead of using the structtarget_core_fabric_ops->pack_lun()fabric provided API vector.It also removes the
tfo->pack_luncheck fromtarget_fabric_tf_ops_check()and removes from structtarget_core_fabric_ops->pack_lun()fromtarget_core_fabric_ops.h, and the following mainline scsi-misc fabric modules:*)
tcm_loop: Droptcm_loop_pack_lun()usage
*)tcm_fc: Dropft_pack_lun()usage
Quoted 7 lines
Quoted 2 lines
Reported-by Mike Christie <[email protected]>Signed-off-by Nicholas A. Bellinger <[email protected]>There's no way this or the following patch count as bug fixes. They're converging hand rolled functions and definitions (which is good, but not a bug fix).
Correct, patches # 1 -> 4 where the bugfixes patches of this series that needed to go to also go into stable, but the remaining two patches requested by Mike and Christoph during iscsi-target review are >= .40 only material.
Thank you!
--nab
PATCH 6/6 target: Convert TASK_ATTR to scsi_tcq.h definitions
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch converts target core and follwing scsi-misc upstream fabric modules to use include/scsi/scsi_tcq.h includes for SIMPLE, HEAD_OF_QUEUE and ORDERED SCSI tasks instead of scsi/libsas.h with TASK_ATTR*
*) tcm_loop: Convert tcm_loop_allocate_core_cmd() + tcm_loop_device_reset() to
scsi_tcq.h
*) tcm_fc: Convert ft_send_cmd() from FCP_PTA_* to scsi_tcq.h
--- drivers/target/loopback/tcm_loop.c | 12 ++++++------ drivers/target/target_core_pscsi.c | 4 ++-- drivers/target/target_core_transport.c | 22 +++++++++++----------- drivers/target/tcm_fc/tfc_cmd.c | 20 +++++++++++++++++++- include/scsi/scsi_tcq.h | 1 + 5 files changed, 39 insertions(+), 20 deletions(-)
drivers/target/loopback/tcm_loop.c +6 -6
@@ -31,7 +31,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi_device.h> #include <scsi/scsi_cmnd.h> -#include <scsi/libsas.h> /* For TASK_ATTR_* */ +#include <scsi/scsi_tcq.h> #include <target/target_core_base.h> #include <target/target_core_transport.h>
@@ -95,17 +95,17 @@ static struct se_cmd *tcm_loop_allocate_core_cmd(if (sc->device->tagged_supported) {switch (sc->tag) {case HEAD_OF_QUEUE_TAG : - sam_task_attr =TASK_ATTR_HOQ ; + sam_task_attr =MSG_HEAD_TAG ;break ;case ORDERED_QUEUE_TAG : - sam_task_attr =TASK_ATTR_ORDERED ; + sam_task_attr =MSG_ORDERED_TAG ;break ;default : - sam_task_attr =TASK_ATTR_SIMPLE ; + sam_task_attr =MSG_SIMPLE_TAG ;break ; } }else - sam_task_attr =TASK_ATTR_SIMPLE ; + sam_task_attr =MSG_SIMPLE_TAG ;/* * Initialize struct se_cmd descriptor from target_core_mod infrastructure
@@ -379,7 +379,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)* Initialize struct se_cmd descriptor from target_core_mod infrastructure */ transport_init_se_cmd (se_cmd, se_tpg->se_tpg_tfo, se_sess,0 , -DMA_NONE ,TASK_ATTR_SIMPLE , +DMA_NONE ,MSG_SIMPLE_TAG , &tl_cmd->tl_sense_buf[0 ]);/* * Allocate the LUN_RESET TMR
drivers/target/target_core_pscsi.c +2 -2
@@ -41,7 +41,7 @@#include <scsi/scsi_device.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_host.h> -#include <scsi/libsas.h> /* For TASK_ATTR_* */ +#include <scsi/scsi_tcq.h> #include <target/target_core_base.h> #include <target/target_core_device.h>
@@ -911,7 +911,7 @@ static int pscsi_do_task(struct se_task *task)* descriptor */ blk_execute_rq_nowait (pdv->pdv_sd->request_queue,NULL , pt->pscsi_req, - (task->task_se_cmd->sam_task_attr ==TASK_ATTR_HOQ ), + (task->task_se_cmd->sam_task_attr ==MSG_HEAD_TAG ), pscsi_req_done);return PYX_TRANSPORT_SENT_TO_TRANSPORT ;
drivers/target/target_core_transport.c +11 -11
@@ -42,7 +42,7 @@#include <net/tcp.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> -#include <scsi/libsas.h> /* For TASK_ATTR_* */ +#include <scsi/scsi_tcq.h> #include <target/target_core_base.h> #include <target/target_core_device.h>
@@ -1074,7 +1074,7 @@ static inline int transport_add_task_check_sam_attr(* head of the struct se_device->execute_task_list, and task_prev * after that for each subsequent task */ -if (task->task_se_cmd->sam_task_attr ==TASK_ATTR_HOQ ) { +if (task->task_se_cmd->sam_task_attr ==MSG_HEAD_TAG ) { list_add(&task->t_execute_list, (task_prev != NULL) ? &task_prev->t_execute_list :
@@ -1873,7 +1873,7 @@ static int transport_check_alloc_task_attr(struct se_cmd *cmd)if (SE_DEV (cmd)->dev_task_attr_type !=SAM_TASK_ATTR_EMULATED )return 0 ; -if (cmd->sam_task_attr ==TASK_ATTR_ACA ) { +if (cmd->sam_task_attr ==MSG_ACA_TAG ) {DEBUG_STA ("SAM Task Attribute ACA" " emulation is not supported\n" );return -1 ;
@@ -2517,7 +2517,7 @@ static inline int transport_execute_task_attr(struct se_cmd *cmd)* Check for the existence of HEAD_OF_QUEUE, and if true return 1 * to allow the passed struct se_cmd list of tasks to the front of the list. */ -if (cmd->sam_task_attr ==TASK_ATTR_HOQ ) { +if (cmd->sam_task_attr ==MSG_HEAD_TAG ) {atomic_inc (&SE_DEV (cmd)->dev_hoq_count);smp_mb__after_atomic_inc (); DEBUG_STA("Added HEAD_OF_QUEUE for CDB:"
@@ -2525,7 +2525,7 @@ static inline int transport_execute_task_attr(struct se_cmd *cmd)T_TASK (cmd)->t_task_cdb[0 ], cmd->se_ordered_id);return 1 ; - }else if (cmd->sam_task_attr ==TASK_ATTR_ORDERED ) { + }else if (cmd->sam_task_attr ==MSG_ORDERED_TAG ) {spin_lock (&SE_DEV (cmd)->ordered_cmd_lock);list_add_tail (&cmd->se_ordered_list, &SE_DEV (cmd)->ordered_cmd_list);
@@ -3424,7 +3424,7 @@ static int transport_generic_cmd_sequencer(* See spc4r17 section 5.3 */ if (SE_DEV (cmd)->dev_task_attr_type ==SAM_TASK_ATTR_EMULATED ) - cmd->sam_task_attr =TASK_ATTR_HOQ ; + cmd->sam_task_attr =MSG_HEAD_TAG ; cmd->se_cmd_flags |=SCF_SCSI_CONTROL_NONSG_IO_CDB ;break ;case READ_BUFFER :
@@ -3632,7 +3632,7 @@ static int transport_generic_cmd_sequencer(* See spc4r17 section 5.3 */ if (SE_DEV (cmd)->dev_task_attr_type ==SAM_TASK_ATTR_EMULATED ) - cmd->sam_task_attr =TASK_ATTR_HOQ ; + cmd->sam_task_attr =MSG_HEAD_TAG ; cmd->se_cmd_flags |=SCF_SCSI_CONTROL_NONSG_IO_CDB ;break ;default :
@@ -3790,21 +3790,21 @@ static void transport_complete_task_attr(struct se_cmd *cmd)struct se_cmd *cmd_p, *cmd_tmp;int new_active_tasks =0 ; -if (cmd->sam_task_attr ==TASK_ATTR_SIMPLE ) { +if (cmd->sam_task_attr ==MSG_SIMPLE_TAG ) {atomic_dec (&dev->simple_cmds);smp_mb__after_atomic_dec (); dev->dev_cur_ordered_id++;DEBUG_STA ("Incremented dev->dev_cur_ordered_id: %u for" " SIMPLE: %u\n" , dev->dev_cur_ordered_id, cmd->se_ordered_id); - }else if (cmd->sam_task_attr ==TASK_ATTR_HOQ ) { + }else if (cmd->sam_task_attr ==MSG_HEAD_TAG ) {atomic_dec (&dev->dev_hoq_count);smp_mb__after_atomic_dec (); dev->dev_cur_ordered_id++;DEBUG_STA ("Incremented dev_cur_ordered_id: %u for" " HEAD_OF_QUEUE: %u\n" , dev->dev_cur_ordered_id, cmd->se_ordered_id); - }else if (cmd->sam_task_attr ==TASK_ATTR_ORDERED ) { + }else if (cmd->sam_task_attr ==MSG_ORDERED_TAG ) {spin_lock (&dev->ordered_cmd_lock);list_del (&cmd->se_ordered_list);atomic_dec (&dev->dev_ordered_sync);
@@ -3837,7 +3837,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd) new_active_tasks++;spin_lock (&dev->delayed_cmd_lock); -if (cmd_p->sam_task_attr ==TASK_ATTR_ORDERED ) +if (cmd_p->sam_task_attr ==MSG_ORDERED_TAG )break ; }spin_unlock (&dev->delayed_cmd_lock);
drivers/target/tcm_fc/tfc_cmd.c +19 -1
@@ -35,6 +35,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi_device.h> #include <scsi/scsi_cmnd.h> +#include <scsi/scsi_tcq.h> #include <scsi/libfc.h> #include <scsi/fc_encode.h>
@@ -592,8 +593,25 @@ static void ft_send_cmd(struct ft_cmd *cmd)case FCP_CFL_WRDATA |FCP_CFL_RDDATA : goto err;/* TBD not supported by tcm_fc yet */ } +/* +* Locate the SAM Task Attr from fc_pri_ta +*/ +switch (fcp->fc_pri_ta &FCP_PTA_MASK ) { +case FCP_PTA_HEADQ : + task_attr =MSG_HEAD_TAG ; +break ; +case FCP_PTA_ORDERED : + task_attr =MSG_ORDERED_TAG ; +break ; +case FCP_PTA_ACA : + task_attr =MSG_ACA_TAG ; +break ; +case FCP_PTA_SIMPLE :/* Fallthrough */ +default : + task_attr =MSG_SIMPLE_TAG ; + } + -/* FCP_PTA_ maps 1:1 to TASK_ATTR_ */ task_attr = fcp->fc_pri_ta &FCP_PTA_MASK ; data_len =ntohl (fcp->fc_dl); cmd->cdb = fcp->fc_cdb;
include/scsi/scsi_tcq.h +1 -0
@@ -9,6 +9,7 @@#define MSG_SIMPLE_TAG 0x20#define MSG_HEAD_TAG 0x21#define MSG_ORDERED_TAG 0x22 +#define MSG_ACA_TAG 0x24/* unsupported */ #define SCSI_NO_TAG (-1)/* identify no tag in use */
Signature · 1 line
1.7.5.1