1. 05 11月, 2020 4 次提交
  2. 05 8月, 2020 1 次提交
  3. 29 7月, 2020 2 次提交
  4. 10 6月, 2020 3 次提交
  5. 08 5月, 2020 3 次提交
  6. 25 4月, 2020 1 次提交
  7. 27 3月, 2020 1 次提交
    • M
      scsi: target: fix hang when multiple threads try to destroy the same iscsi session · 57c46e9f
      Maurizio Lombardi 提交于
      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.comReported-by: NMatt Coleman <mcoleman@datto.com>
      Tested-by: NMatt Coleman <mcoleman@datto.com>
      Tested-by: NRahul Kundu <rahul.kundu@chelsio.com>
      Signed-off-by: NMaurizio Lombardi <mlombard@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      57c46e9f
  8. 17 3月, 2020 1 次提交
  9. 22 2月, 2020 3 次提交
  10. 04 10月, 2019 1 次提交
  11. 13 4月, 2019 2 次提交
    • B
      scsi: target/iscsi: Handle too large immediate data buffers correctly · 0ca650c1
      Bart Van Assche 提交于
      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: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      0ca650c1
    • B
      scsi: target/core: Rework the SPC-2 reservation handling code · fae43461
      Bart Van Assche 提交于
      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: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      fae43461
  12. 05 2月, 2019 5 次提交
  13. 08 12月, 2018 8 次提交
    • D
      scsi: target: consistently null-terminate t10_wwn strings · b2da4abf
      David Disseldorp 提交于
      In preparation for supporting user provided vendor strings, add an extra
      byte to the vendor, model and revision arrays in struct t10_wwn. This
      ensures that the full INQUIRY data can be carried in the arrays along with
      a null-terminator.
      
      Change a number of array readers and writers so that they account for
      explicit null-termination:
      
      - The pscsi_set_inquiry_info() and emulate_model_alias_store() codepaths
        don't currently explicitly null-terminate; fix this.
      
      - Existing t10_wwn field dumps use for-loops which step over
        null-terminators for right-padding.
        + Use printf with width specifiers instead.
      Signed-off-by: NDavid Disseldorp <ddiss@suse.de>
      Reviewed-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      b2da4abf
    • B
      scsi: target/core: Make ABORT and LUN RESET handling synchronous · 2c9fa49e
      Bart Van Assche 提交于
      Instead of invoking target driver callback functions from the context that
      handles an abort or LUN RESET task management function, only set the abort
      flag from that context and perform the actual abort handling from the
      context of the regular command processing flow. This approach has the
      advantage that the task management code becomes much easier to read and to
      verify since the number of potential race conditions against the command
      processing flow is strongly reduced.
      
      This patch has been tested by running the following two shell commands
      concurrently for about ten minutes for both the iSCSI and the SRP target
      drivers ($dev is an initiator device node connected with storage provided
      by the target driver under test):
      
       * fio with data verification enabled on a filesystem mounted on top of
         $dev.
      
       * while true; do sg_reset -d $dev; echo -n .; sleep .1; done
      
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      2c9fa49e
    • B
      scsi: target/core: Fix TAS handling for aborted commands · aaa00cc9
      Bart Van Assche 提交于
      The TASK ABORTED STATUS (TAS) bit is defined as follows in SAM:
      "TASK_ABORTED: this status shall be returned if a command is aborted by a
      command or task management function on another I_T nexus and the control
      mode page TAS bit is set to one". TAS handling is spread over the target
      core and the iSCSI target driver. If a LUN RESET is received, the target
      core will send the TASK_ABORTED response for all commands for which such a
      response has to be sent. If an ABORT TASK is received, only the iSCSI
      target driver will send the TASK_ABORTED response for the commands for
      which that response has to be sent.  That is a bug since all target drivers
      have to honor the TAS bit. Fix this by moving the code that handles TAS
      from the iSCSI target driver into the target core. Additionally, if a
      command has been aborted, instead of sending the TASK_ABORTED status from
      the context that processes the SCSI command send it from the context of the
      ABORT TMF.  The core_tmr_abort_task() change in this patch causes the
      CMD_T_TAS flag to be set if a TASK_ABORTED status has to be sent back to
      the initiator that submitted the command. If that flag has been set
      transport_cmd_finish_abort() will send the TASK_ABORTED response.
      
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      aaa00cc9
    • B
      scsi: target/core: Simplify the code for aborting SCSI commands · fbbd4923
      Bart Van Assche 提交于
      Instead of allowing the code that aborts a SCSI command to finish before
      all iSCSI data frames have been received, make that code wait until all
      iSCSI data frames have been received. Introduce a new member variable in
      the target driver template to communicate that information from the iSCSI
      target driver to the target core. This change allows to leave out the check
      whether or not it is already safe to send the TASK_ABORTED reply from
      transport_send_task_abort().
      
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      fbbd4923
    • B
      scsi: target/core: Make it possible to wait from more than one context for command completion · a014c364
      Bart Van Assche 提交于
      This patch does not change any functionality but makes the patch that makes
      TMF handling synchronous easier to read.
      
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      a014c364
    • B
      scsi: target/core: Use system workqueues for TMF · db5b21a2
      Bart Van Assche 提交于
      A quote from SAM-5: "The order in which task management requests are
      processed is not specified by the SCSI architecture model.  The SCSI
      architecture model does not require in-order delivery of such task
      management requests or processing by the task manager in the order
      received. To guarantee the processing order of task management requests
      referencing sent to a specific logical unit, an application client should
      not have more than one such task management request pending to that logical
      unit." This means that it is safe to use the system workqueues instead of
      tmr_wq for processing TMFs. An intended side effect of this patch is that
      it enables concurrent processing of TMFs.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      db5b21a2
    • B
      scsi: target/core: Make sure that target_wait_for_sess_cmds() waits long enough · ad669505
      Bart Van Assche 提交于
      A session must only be released after all code that accesses the session
      structure has finished. Make sure that this is the case by introducing a
      new command counter per session that is only decremented after the
      .release_cmd() callback has finished. This patch fixes the following crash:
      
      BUG: KASAN: use-after-free in do_raw_spin_lock+0x1c/0x130
      Read of size 4 at addr ffff8801534b16e4 by task rmdir/14805
      CPU: 16 PID: 14805 Comm: rmdir Not tainted 4.18.0-rc2-dbg+ #5
      Call Trace:
      dump_stack+0xa4/0xf5
      print_address_description+0x6f/0x270
      kasan_report+0x241/0x360
      __asan_load4+0x78/0x80
      do_raw_spin_lock+0x1c/0x130
      _raw_spin_lock_irqsave+0x52/0x60
      srpt_set_ch_state+0x27/0x70 [ib_srpt]
      srpt_disconnect_ch+0x1b/0xc0 [ib_srpt]
      srpt_close_session+0xa8/0x260 [ib_srpt]
      target_shutdown_sessions+0x170/0x180 [target_core_mod]
      core_tpg_del_initiator_node_acl+0xf3/0x200 [target_core_mod]
      target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
      config_item_release+0x9c/0x110 [configfs]
      config_item_put+0x26/0x30 [configfs]
      configfs_rmdir+0x3b8/0x510 [configfs]
      vfs_rmdir+0xb3/0x1e0
      do_rmdir+0x262/0x2c0
      do_syscall_64+0x77/0x230
      entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      ad669505
    • B
      scsi: target/core: Simplify transport_clear_lun_ref() · a95be384
      Bart Van Assche 提交于
      Since transport_clear_lun_ref() already waits until the percpu-refcount
      .release() method is called, it is not necessary to wait first until
      percpu_ref_kill_and_confirm() has finished transitioning the refcount into
      atomic mode. Remove the code that waits for percpu_ref_kill_and_confirm()
      to complete and also the completion object that is used by that code.  This
      patch does not change the behavior of the SCSI target code.
      
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Disseldorp <ddiss@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      a95be384
  14. 29 11月, 2018 3 次提交
  15. 22 11月, 2018 1 次提交
  16. 16 10月, 2018 1 次提交