linux/drivers/target
Mike Christie ed1227e080 scsi: target: Fix ordered tag handling
This patch fixes the following bugs:

1. If there are multiple ordered cmds queued and multiple simple cmds
   completing, target_restart_delayed_cmds() could be called on different
   CPUs and each instance could start a ordered cmd. They could then run in
   different orders than they were queued.

2. target_restart_delayed_cmds() and target_handle_task_attr() can race
   where:

   1. target_handle_task_attr() has passed the simple_cmds == 0 check.

   2. transport_complete_task_attr() then decrements simple_cmds to 0.

   3. transport_complete_task_attr() runs target_restart_delayed_cmds() and
      it does not see any cmds on the delayed_cmd_list.

   4. target_handle_task_attr() adds the cmd to the delayed_cmd_list.

   The cmd will then end up timing out.

3. If we are sent > 1 ordered cmds and simple_cmds == 0, we can execute
   them out of order, because target_handle_task_attr() will hit that
   simple_cmds check first and return false for all ordered cmds sent.

4. We run target_restart_delayed_cmds() after every cmd completion, so if
   there is more than 1 simple cmd running, we start executing ordered cmds
   after that first cmd instead of waiting for all of them to complete.

5. Ordered cmds are not supposed to start until HEAD OF QUEUE and all older
   cmds have completed, and not just simple.

6. It's not a bug but it doesn't make sense to take the delayed_cmd_lock
   for every cmd completion when ordered cmds are almost never used. Just
   replacing that lock with an atomic increases IOPs by up to 10% when
   completions are spread over multiple CPUs and there are multiple
   sessions/ mqs/thread accessing the same device.

This patch moves the queued delayed handling to a per device work to
serialze the cmd executions for each device and adds a new counter to track
HEAD_OF_QUEUE and SIMPLE cmds. We can then check the new counter to
determine when to run the work on the completion path.

Link: https://lore.kernel.org/r/20210930020422.92578-3-michael.christie@oracle.com
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-10-18 22:38:35 -04:00
..
iscsi scsi: target: cxgbit: Enable Delayed ACK 2021-10-18 22:38:35 -04:00
loopback scsi: target: tcm_loop: Call scsi_done() directly 2021-10-16 21:31:43 -04:00
sbp scsi: target: sbp: Replace enable attr with ops.enable 2021-10-04 23:27:38 -04:00
tcm_fc scsi: target: tcm_fc: Fix a kernel-doc header 2021-04-15 22:44:41 -04:00
Kconfig scsi: core: Rename CONFIG_BLK_SCSI_REQUEST to CONFIG_SCSI_COMMON 2021-07-28 22:24:27 -04:00
Makefile
target_core_alua.c scsi: target: core: Drop unnecessary se_cmd ASC/ASCQ members 2021-08-03 07:27:43 -04:00
target_core_alua.h
target_core_configfs.c Merge branch '5.15/scsi-fixes' into 5.16/scsi-staging 2021-10-12 11:58:12 -04:00
target_core_device.c scsi: target: Fix ordered tag handling 2021-10-18 22:38:35 -04:00
target_core_fabric_configfs.c scsi: target: core: Add common tpg/enable attribute 2021-10-04 23:27:38 -04:00
target_core_fabric_lib.c scsi: target: Handle short iSIDs 2020-07-08 00:14:34 -04:00
target_core_file.c scsi: target: core: file: Don't duplicate memset(0xff) 2021-03-09 23:47:18 -05:00
target_core_file.h
target_core_hba.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
target_core_iblock.c scsi: target: Remove redundant assignment to variable ret 2021-07-27 00:06:42 -04:00
target_core_iblock.h scsi: target: iblock: Add backend plug/unplug callouts 2021-03-04 17:37:02 -05:00
target_core_internal.h scsi: target: Fix ordered tag handling 2021-10-18 22:38:35 -04:00
target_core_pr.c scsi: target: Fix spelling mistake "CONFLIFT" -> "CONFLICT" 2021-09-22 00:17:29 -04:00
target_core_pr.h scsi: target: core: Unify NAA identifier generation 2021-05-15 14:14:28 -04:00
target_core_pscsi.c scsi: target: pscsi: Fix possible null-pointer dereference in pscsi_complete_cmd() 2021-08-17 22:28:39 -04:00
target_core_pscsi.h
target_core_rd.c scsi: target: Add the DUMMY flag to rd_mcp 2021-04-05 23:26:38 -04:00
target_core_rd.h scsi: target: Add the DUMMY flag to rd_mcp 2021-04-05 23:26:38 -04:00
target_core_sbc.c scsi: target: Fix protect handling in WRITE SAME(32) 2021-07-18 21:27:42 -04:00
target_core_spc.c scsi: target: Use standard SAM status types 2021-05-31 22:48:24 -04:00
target_core_stat.c scsi: target: core: Remove unused macros NONE and ISPRINT 2021-03-09 23:47:18 -05:00
target_core_tmr.c scsi: target: core: Flush submission work during TMR processing 2021-03-04 17:37:02 -05:00
target_core_tpg.c scsi: target: Drop sess_cmd_lock from I/O path 2020-11-04 22:39:37 -05:00
target_core_transport.c scsi: target: Fix ordered tag handling 2021-10-18 22:38:35 -04:00
target_core_ua.c scsi: target: use an enum to track emulate_ua_intlck_ctrl 2020-02-21 17:37:16 -05:00
target_core_ua.h
target_core_user.c scsi: target: tcmu: Allocate zeroed pages for data area 2021-10-18 22:38:35 -04:00
target_core_xcopy.c scsi: target: Remove unused function arguments 2021-09-14 23:41:24 -04:00
target_core_xcopy.h scsi: target: Fix XCOPY NAA identifier lookup 2021-01-11 17:06:48 -05:00