Skip to content
Snippets Groups Projects
  1. Oct 19, 2021
    • Mike Christie's avatar
      scsi: target: Replace lun_tg_pt_gp_lock with rcu in I/O path · 7324f47d
      Mike Christie authored
      We are only holding the lun_tg_pt_gp_lock in target_alua_state_check() to
      make sure tg_pt_gp is not freed from under us while we copy the state,
      delay, ID values. We can instead use RCU here to access the tg_pt_gp.
      
      With this patch IOPs can increase up to 10% for jobs like:
      
        fio  --filename=/dev/sdX  --direct=1 --rw=randrw --bs=4k \
          --ioengine=libaio --iodepth=64  --numjobs=N
      
      when there are multiple sessions (running that fio command to each /dev/sdX
      or using multipath and there are over 8 paths), or more than 8 queues for
      the loop or vhost with multiple threads case and numjobs > 8.
      
      Link: https://lore.kernel.org/r/20210930020422.92578-5-michael.christie@oracle.com
      
      
      Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      7324f47d
    • Mike Christie's avatar
      scsi: target: Fix ordered tag handling · ed1227e0
      Mike Christie authored
      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: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      ed1227e0
  2. Oct 05, 2021
  3. Aug 18, 2021
  4. Aug 03, 2021
  5. May 15, 2021
  6. Mar 04, 2021
  7. Feb 23, 2021
  8. Jan 27, 2021
    • Anastasia Kovaleva's avatar
      scsi: target: core: Change ASCQ for residual write · ead0ffc9
      Anastasia Kovaleva authored
      According to FCP-4 (9.4.2):
      
        If the command requested that data beyond the length specified by the
        FCP_DL field be transferred, then the device server shall set the
        FCP_RESID_OVER bit (see 9.5.8) to one in the FCP_RSP IU and:
      
        a) process the command normally except that data beyond the FCP_DL count
        shall not be requested or transferred;
      
        b) transfer no data and return CHECK CONDITION status with the sense key
        set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD
        IN COMMAND INFORMATION UNIT; or
      
        c) may transfer data and return CHECK CONDITION status with the sense key
        set to ABORTED COMMAND and the additional sense code set to INVALID FIELD
        IN COMMAND INFORMATION UNIT.
      
      TCM follows b) and transfers no data for residual writes but returns
      INVALID FIELD IN CDB instead of INVALID FIELD IN COMMAND INFORMATION UNIT.
      
      Change the ASCQ to INVALID FIELD IN COMMAND INFORMATION UNIT to meet the
      standard.
      
      Link: https://lore.kernel.org/r/20201203082035.54566-4-a.kovaleva@yadro.com
      
      
      Signed-off-by: default avatarAnastasia Kovaleva <a.kovaleva@yadro.com>
      Signed-off-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      ead0ffc9
  9. Nov 05, 2020
  10. Aug 05, 2020
  11. Jul 29, 2020
  12. Jun 10, 2020
  13. May 08, 2020
  14. Apr 24, 2020
  15. Mar 27, 2020
    • Maurizio Lombardi's avatar
      scsi: target: fix hang when multiple threads try to destroy the same iscsi session · 57c46e9f
      Maurizio Lombardi authored
      A number of hangs have been reported against the target driver; they are
      due to the fact that multiple threads may try to destroy the iscsi session
      at the same time. This may be reproduced for example when a "targetcli
      iscsi/iqn.../tpg1 disable" command is executed while a logout operation is
      underway.
      
      When this happens, two or more threads may end up sleeping and waiting for
      iscsit_close_connection() to execute "complete(session_wait_comp)".  Only
      one of the threads will wake up and proceed to destroy the session
      structure, the remaining threads will hang forever.
      
      Note that if the blocked threads are somehow forced to wake up with
      complete_all(), they will try to free the same iscsi session structure
      destroyed by the first thread, causing double frees, memory corruptions
      etc...
      
      With this patch, the threads that want to destroy the iscsi session will
      increase the session refcount and will set the "session_close" flag to 1;
      then they wait for the driver to close the remaining active connections.
      When the last connection is closed, iscsit_close_connection() will wake up
      all the threads and will wait for the session's refcount to reach zero;
      when this happens, iscsit_close_connection() will destroy the session
      structure because no one is referencing it anymore.
      
       INFO: task targetcli:5971 blocked for more than 120 seconds.
             Tainted: P           OE    4.15.0-72-generic #81~16.04.1
       "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
       targetcli       D    0  5971      1 0x00000080
       Call Trace:
        __schedule+0x3d6/0x8b0
        ? vprintk_func+0x44/0xe0
        schedule+0x36/0x80
        schedule_timeout+0x1db/0x370
        ? __dynamic_pr_debug+0x8a/0xb0
        wait_for_completion+0xb4/0x140
        ? wake_up_q+0x70/0x70
        iscsit_free_session+0x13d/0x1a0 [iscsi_target_mod]
        iscsit_release_sessions_for_tpg+0x16b/0x1e0 [iscsi_target_mod]
        iscsit_tpg_disable_portal_group+0xca/0x1c0 [iscsi_target_mod]
        lio_target_tpg_enable_store+0x66/0xe0 [iscsi_target_mod]
        configfs_write_file+0xb9/0x120
        __vfs_write+0x1b/0x40
        vfs_write+0xb8/0x1b0
        SyS_write+0x5c/0xe0
        do_syscall_64+0x73/0x130
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      
      Link: https://lore.kernel.org/r/20200313170656.9716-3-mlombard@redhat.com
      
      
      Reported-by: default avatarMatt Coleman <mcoleman@datto.com>
      Tested-by: default avatarMatt Coleman <mcoleman@datto.com>
      Tested-by: default avatarRahul Kundu <rahul.kundu@chelsio.com>
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      57c46e9f
  16. Mar 17, 2020
  17. Feb 21, 2020
  18. Oct 04, 2019
  19. Apr 13, 2019
    • Bart Van Assche's avatar
      scsi: target/iscsi: Handle too large immediate data buffers correctly · 0ca650c1
      Bart Van Assche authored
      
      Since target_alloc_sgl() and iscsit_allocate_iovecs() allocate buffer space
      for se_cmd.data_length bytes and since that number can be smaller than the
      iSCSI Expected Data Transfer Length (EDTL), ensure that the iSCSI target
      driver does not attempt to receive more bytes than what fits in the receive
      buffer. Always receive the full immediate data buffer such that the iSCSI
      target driver does not attempt to parse immediate data as an iSCSI PDU.
      
      Note: the current code base only calls iscsit_get_dataout() if the size of
      the immediate data buffer does not exceed the buffer size derived from the
      SCSI CDB. See also target_cmd_size_check().
      
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      0ca650c1
    • Bart Van Assche's avatar
      scsi: target/core: Rework the SPC-2 reservation handling code · fae43461
      Bart Van Assche authored
      
      Instead of tracking the initiator that established an SPC-2 reservation,
      track the session through which the SPC-2 reservation has been
      established. This patch does not change any functionality.
      
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      fae43461
  20. Feb 05, 2019
Loading