1. 05 Feb, 2019 14 commits
    • Bart Van Assche's avatar
      scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock · 32e36bfb
      Bart Van Assche authored
      When using SCSI passthrough in combination with the iSCSI target driver
      then cmd->t_state_lock may be obtained from interrupt context. Hence, all
      code that obtains cmd->t_state_lock from thread context must disable
      interrupts first. This patch avoids that lockdep reports the following:
      
      WARNING: inconsistent lock state
      4.18.0-dbg+ #1 Not tainted
      --------------------------------
      inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
      iscsi_ttx/1800 [HC1[1]:SC0[2]:HE0:SE0] takes:
      000000006e7b0ceb (&(&cmd->t_state_lock)->rlock){?...}, at: target_complete_cmd+0x47/0x2c0 [target_core_mod]
      {HARDIRQ-ON-W} state was registered at:
       lock_acquire+0xd2/0x260
       _raw_spin_lock+0x32/0x50
       iscsit_close_connection+0x97e/0x1020 [iscsi_target_mod]
       iscsit_take_action_for_connection_exit+0x108/0x200 [iscsi_target_mod]
       iscsi_target_rx_thread+0x180/0x190 [iscsi_target_mod]
       kthread+0x1cf/0x1f0
       ret_from_fork+0x24/0x30
      irq event stamp: 1281
      hardirqs last  enabled at (1279): [<ffffffff970ade79>] __local_bh_enable_ip+0xa9/0x160
      hardirqs last disabled at (1281): [<ffffffff97a008a5>] interrupt_entry+0xb5/0xd0
      softirqs last  enabled at (1278): [<ffffffff977cd9a1>] lock_sock_nested+0x51/0xc0
      softirqs last disabled at (1280): [<ffffffffc07a6e04>] ip6_finish_output2+0x124/0xe40 [ipv6]
      
      other info that might help us debug this:
      Possible unsafe locking scenario:
      
            CPU0
            ----
       lock(&(&cmd->t_state_lock)->rlock);
       <Interrupt>
         lock(&(&cmd->t_state_lock)->rlock);
      
      *** DEADLOCK ***
      
      3 locks held by iscsi_ttx/1800:
      *0: 00000000c3b711b7 (sk_lock-AF_INET6){+.+.}, at: tcp_sendmsg+0x1e/0x50
      *1: 00000000fa81046f (rcu_read_lock){....}, at: inet6_csk_xmit+0xc7/0x2e0 [ipv6]
      *2: 00000000c091d70d (rcu_read_lock_bh){....}, at: ip6_finish_output2+0x124/0xe40 [ipv6]
      
      stack backtrace:
      CPU: 0 PID: 1800 Comm: iscsi_ttx Not tainted 4.18.0-dbg+ #1
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      Call Trace:
      <IRQ>
      dump_stack+0xa4/0xf5
      print_usage_bug+0x25b/0x27b
      mark_lock+0x70f/0x7b0
      __lock_acquire+0xbc2/0x1b50
      lock_acquire+0xd2/0x260
      _raw_spin_lock_irqsave+0x4a/0x60
      target_complete_cmd+0x47/0x2c0 [target_core_mod]
      target_complete_cmd_with_length+0x70/0xa0 [target_core_mod]
      pscsi_req_done+0x335/0x530 [target_core_pscsi]
      __blk_mq_end_request+0xa5/0x140
      scsi_end_request+0x112/0x320 [scsi_mod]
      scsi_io_completion+0x183/0xa30 [scsi_mod]
      scsi_finish_command+0x1c0/0x280 [scsi_mod]
      scsi_softirq_done+0x19a/0x230 [scsi_mod]
      __blk_mq_complete_request_remote+0x2f/0x40
      flush_smp_call_function_queue+0x12a/0x220
      generic_smp_call_function_single_interrupt+0x13/0x30
      smp_call_function_single_interrupt+0x7a/0x350
      call_function_single_interrupt+0xf/0x20
      </IRQ>
      RIP: 0010:__asan_load4+0x1e/0x80
      debug_lockdep_rcu_enabled+0x26/0x40
      ip6_finish_output2+0x15a/0xe40 [ipv6]
      ip6_finish_output+0x308/0x440 [ipv6]
      ip6_output+0x11d/0x3b0 [ipv6]
      ip6_xmit+0x639/0xc50 [ipv6]
      inet6_csk_xmit+0x198/0x2e0 [ipv6]
      __tcp_transmit_skb+0xc1b/0x15b0
      tcp_write_xmit+0x42e/0x1f20
      __tcp_push_pending_frames+0x59/0x150
      tcp_push+0x189/0x270
      tcp_sendmsg_locked+0x7b9/0x1680
      tcp_sendmsg+0x2c/0x50
      inet_sendmsg+0x71/0x250
      sock_sendmsg+0x4c/0x60
      tx_data+0x12b/0x1f0 [iscsi_target_mod]
      iscsit_send_tx_data+0x77/0xe0 [iscsi_target_mod]
      iscsit_xmit_pdu+0x2c5/0x740 [iscsi_target_mod]
      iscsit_response_queue+0x941/0xd40 [iscsi_target_mod]
      iscsi_target_tx_thread+0x23b/0x350 [iscsi_target_mod]
      kthread+0x1cf/0x1f0
      ret_from_fork+0x24/0x30
      
      Fixes: 064cdd2d ("target: Fix race between iscsi-target connection shutdown + ABORT_TASK")
      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>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      32e36bfb
    • Bart Van Assche's avatar
      scsi: target/iscsi: Rename a function and a function pointer · 1e65cc16
      Bart Van Assche authored
      Having both a function and a function pointer member with the same
      name (iscsit_release_cmd) is confusing. Hence rename the function pointer
      member.
      
      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>
      1e65cc16
    • Bart Van Assche's avatar
      scsi: target/iscsi: Fix spelling of "unsolicited" · 0300b114
      Bart Van Assche authored
      Change "unsoliticed" into "unsolicited".
      
      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>
      Cc: Sagi Grimberg <sagi@grimberg.me>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      0300b114
    • Bart Van Assche's avatar
      scsi: target/iscsi: Convert comments about locking into runtime checks · 618baaf7
      Bart Van Assche authored
      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>
      618baaf7
    • Bart Van Assche's avatar
      scsi: target/iscsi: Remove an incorrect comment · b53655b8
      Bart Van Assche authored
      The single iscsit_start_nopin_response_timer() caller does not hold any
      locks. Hence remove the comment above this function.
      
      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>
      b53655b8
    • Bart Van Assche's avatar
      scsi: RDMA/srpt: Fix a credit leak for aborted commands · 40ca8757
      Bart Van Assche authored
      Make sure that the next time a response is sent to the initiator that the
      credit it had allocated for the aborted request gets freed.
      
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Fixes: 131e6abc ("target: Add TFO->abort_task for aborted task resources release") # v3.15
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      40ca8757
    • Bart Van Assche's avatar
      scsi: RDMA/srpt: Rework I/O context allocation · fd1b6687
      Bart Van Assche authored
      Instead of maintaining a list of free I/O contexts, use an sbitmap data
      structure to track which I/O contexts are in use and which are free. This
      makes the ib_srpt driver more consistent with other LIO drivers.
      
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      fd1b6687
    • Bart Van Assche's avatar
      scsi: RDMA/srpt: Fix handling of TMF submission failure · 337ec69e
      Bart Van Assche authored
      If submitting a TMF to the target core fails, send the "FUNCTION REJECTED"
      response to the initiator.
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      337ec69e
    • Bart Van Assche's avatar
      scsi: RDMA/srpt: Fix handling of command / TMF submission failure · 8b8807b9
      Bart Van Assche authored
      If submitting an SRP IU to the target core fails, send the SCSI response
      "BUSY" to the initiator instead of not sending any response.
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      8b8807b9
    • Bart Van Assche's avatar
      scsi: target/core: Add target_send_busy() · 94ebb471
      Bart Van Assche authored
      Introduce a function that sends the SCSI status "BUSY" back to the
      initiator. The next patch will add a call to this function in the srpt
      target driver.
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      94ebb471
    • Bart Van Assche's avatar
      scsi: target/core: Inline transport_lun_remove_cmd() · 83f85b8e
      Bart Van Assche authored
      Remove the code that clears .se_lun from transport_cmd_check_stop_to_fabric()
      such that the transport_lun_remove_cmd() call can be moved into
      target_release_cmd_kref(). Because this guarantees that
      transport_lun_remove_cmd() will be called exactly once, it is safe to change
      the cmpxchg() call into a test of se_cmd.lun_ref_active. Inline
      transport_lun_remove_cmd() because it is not worth to keep it as a separate
      function.
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      83f85b8e
    • Bart Van Assche's avatar
      scsi: target/core: Simplify the LUN RESET implementation · 2281c95f
      Bart Van Assche authored
      Due to the task management handling rework it is safe to wait for a TMF
      that is not in the active state. Hence remove the CMD_T_ACTIVE test from
      core_tmr_drain_tmr_list(). Additionally, call __target_check_io_state()
      instead of open coding it.
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      2281c95f
    • Bart Van Assche's avatar
      scsi: target/core: Remove several state tests from the TMF code · 3f0661a4
      Bart Van Assche authored
      Whether or not a session is being torn down does not affect whether or not
      SCSI commands are in the task set. Hence remove the "tearing down" checks
      from the TMF code. The TRANSPORT_ISTATE_PROCESSING check is left out
      because it is now safe to wait for a command that is in that state. The
      CMD_T_PRE_EXECUTE is left out because abort processing is postponed until
      after commands have left the pre-execute state since the patch that makes
      TMF processing synchronous.
      
      See also commit 1c21a480 ("target: Avoid early CMD_T_PRE_EXECUTE
      failures during ABORT_TASK").
      
      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>
      3f0661a4
    • Bart Van Assche's avatar
      scsi: target/core: Remove the write_pending_status() callback function · f80d2f08
      Bart Van Assche authored
      Due to the patch that makes TMF handling synchronous the
      write_pending_status() callback function is no longer called.  Hence remove
      it.
      Acked-by: default avatarFelipe Balbi <balbi@ti.com>
      Reviewed-by: default avatarSagi Grimberg <sagig@mellanox.com>
      Reviewed-by: default avatarAndy Grover <agrover@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Reviewed-by: default avatarBryant G. Ly <bryantly@linux.vnet.ibm.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Himanshu Madhani <himanshu.madhani@qlogic.com>
      Cc: Quinn Tran <quinn.tran@qlogic.com>
      Cc: Saurav Kashyap <saurav.kashyap@qlogic.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f80d2f08
  2. 01 Feb, 2019 2 commits
  3. 29 Jan, 2019 24 commits