1. 08 Dec, 2018 8 commits
    • Bart Van Assche's avatar
      scsi: target/core: Fix TAS handling for aborted commands · aaa00cc9
      Bart Van Assche authored
      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: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      aaa00cc9
    • Bart Van Assche's avatar
      scsi: target/core: Simplify the code for aborting SCSI commands · fbbd4923
      Bart Van Assche authored
      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: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      fbbd4923
    • Bart Van Assche's avatar
      scsi: target/core: Make it possible to wait from more than one context for command completion · a014c364
      Bart Van Assche authored
      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: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      a014c364
    • Bart Van Assche's avatar
      scsi: target/core: Use system workqueues for TMF · db5b21a2
      Bart Van Assche authored
      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: default avatarChristoph 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: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      db5b21a2
    • Bart Van Assche's avatar
      scsi: target/core: Make sure that target_wait_for_sess_cmds() waits long enough · ad669505
      Bart Van Assche authored
      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: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      ad669505
    • Bart Van Assche's avatar
      scsi: target/core: Simplify transport_clear_lun_ref() · a95be384
      Bart Van Assche authored
      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: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      a95be384
    • Bart Van Assche's avatar
      scsi: target/core: Use kvcalloc() instead of open-coding it · 5d6cd9fe
      Bart Van Assche authored
      This patch does not change any functionality. Note: the code that frees
      sess_cmd_map already uses kvfree() so that code does not need to be
      modified.
      Reviewed-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      5d6cd9fe
    • Bart Van Assche's avatar
      scsi: target/tcmu: Fix queue_cmd_ring() declaration · e7f41104
      Bart Van Assche authored
      This patch does not change any functionality but avoids that sparse
      complains about the queue_cmd_ring() function and its callers.
      
      Fixes: 6fd0ce79 ("tcmu: prep queue_cmd_ring to be used by unmap wq")
      Reviewed-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      e7f41104
  2. 29 Nov, 2018 19 commits
  3. 28 Nov, 2018 3 commits
  4. 22 Nov, 2018 9 commits
  5. 15 Nov, 2018 1 commit
    • Steffen Maier's avatar
      scsi: zfcp: drop old default switch case which might paper over missing case · 399b6c8b
      Steffen Maier authored
      This was introduced with v2.6.27 commit 287ac01a ("[SCSI] zfcp: Cleanup
      code in zfcp_erp.c") but would now suppress helpful -Wswitch compiler
      warnings when building with W=1 such as the following forced example:
      
      drivers/s390/scsi/zfcp_erp.c: In function 'zfcp_erp_setup_act':
      drivers/s390/scsi/zfcp_erp.c:220:2: warning: enumeration value 'ZFCP_ERP_ACTION_REOPEN_PORT' not handled in switch [-Wswitch]
        switch (need) {
        ^~~~~~
      
      But then again, only with W=1 we would notice unhandled enum cases.
      Without the default cases and a missed unhandled enum case, the code might
      perform unforeseen things we might not want...
      
      As of today, we never run through the removed default case, so removing it
      is no functional change.  In the future, we never should run through a
      default case but introduce the necessary specific case(s) to handle new
      functionality.
      Signed-off-by: default avatarSteffen Maier <maier@linux.ibm.com>
      Reviewed-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      399b6c8b