1. 07 7月, 2017 3 次提交
    • M
      xcopy: loop over devices using idr helper · 6906d008
      Mike Christie 提交于
      This converts the xcopy code to use the idr helper. The next patch
      will drop the g_device_list and make g_device_mutex local to the
      target_core_device.c file.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Reviewed-by: NBart Van Assche <bart.vanassche@wdc.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      6906d008
    • B
      target: Fix a deadlock between the XCOPY code and iSCSI session shutdown · d877d727
      Bart Van Assche 提交于
      Move the code for parsing an XCOPY command from the context of
      the iSCSI receiver thread to the context of the XCOPY workqueue.
      Keep the simple XCOPY checks in the context of the iSCSI receiver
      thread. Move the code for allocating and freeing struct xcopy_op
      from the code that parses an XCOPY command to its caller.
      
      This patch fixes the following deadlock:
      
      ======================================================
      [ INFO: possible circular locking dependency detected ]
      4.10.0-rc7-dbg+ #1 Not tainted
      -------------------------------------------------------
      rmdir/13321 is trying to acquire lock:
       (&sess->cmdsn_mutex){+.+.+.}, at: [<ffffffffa02cb47d>] iscsit_free_all_ooo_cmdsns+0x2d/0xb0 [iscsi_target_mod]
      
      but task is already holding lock:
       (&sb->s_type->i_mutex_key#14){++++++}, at: [<ffffffff811c6e20>] vfs_rmdir+0x50/0x140
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      -> #1 (&sb->s_type->i_mutex_key#14){++++++}:
       lock_acquire+0x71/0x90
       down_write+0x3f/0x70
       configfs_depend_item+0x3a/0xb0 [configfs]
       target_depend_item+0x13/0x20 [target_core_mod]
       target_xcopy_locate_se_dev_e4+0xdd/0x1a0 [target_core_mod]
       target_do_xcopy+0x34b/0x970 [target_core_mod]
       __target_execute_cmd+0x22/0xa0 [target_core_mod]
       target_execute_cmd+0x233/0x2c0 [target_core_mod]
       iscsit_execute_cmd+0x208/0x270 [iscsi_target_mod]
       iscsit_sequence_cmd+0x10b/0x190 [iscsi_target_mod]
       iscsit_get_rx_pdu+0x37d/0xcd0 [iscsi_target_mod]
       iscsi_target_rx_thread+0x6e/0xa0 [iscsi_target_mod]
       kthread+0x102/0x140
       ret_from_fork+0x31/0x40
      
      -> #0 (&sess->cmdsn_mutex){+.+.+.}:
       __lock_acquire+0x10e6/0x1260
       lock_acquire+0x71/0x90
       mutex_lock_nested+0x5f/0x670
       iscsit_free_all_ooo_cmdsns+0x2d/0xb0 [iscsi_target_mod]
       iscsit_close_session+0xac/0x200 [iscsi_target_mod]
       lio_tpg_close_session+0x9f/0xb0 [iscsi_target_mod]
       target_shutdown_sessions+0xc3/0xd0 [target_core_mod]
       core_tpg_del_initiator_node_acl+0x91/0x140 [target_core_mod]
       target_fabric_nacl_base_release+0x20/0x30 [target_core_mod]
       config_item_release+0x5a/0xc0 [configfs]
       config_item_put+0x1d/0x1f [configfs]
       configfs_rmdir+0x1a6/0x300 [configfs]
       vfs_rmdir+0xb7/0x140
       do_rmdir+0x1f4/0x200
       SyS_rmdir+0x11/0x20
       entry_SYSCALL_64_fastpath+0x23/0xc6
      
      other info that might help us debug this:
      
       Possible unsafe locking scenario:
             CPU0                    CPU1
             ----                    ----
        lock(&sb->s_type->i_mutex_key#14);
                                     lock(&sess->cmdsn_mutex);
                                     lock(&sb->s_type->i_mutex_key#14);
        lock(&sess->cmdsn_mutex);
      
       *** DEADLOCK ***
      
      3 locks held by rmdir/13321:
       #0:  (sb_writers#10){.+.+.+}, at: [<ffffffff811e1aff>] mnt_want_write+0x1f/0x50
       #1:  (&default_group_class[depth - 1]#2/1){+.+.+.}, at: [<ffffffff811cc8ce>] do_rmdir+0x15e/0x200
       #2:  (&sb->s_type->i_mutex_key#14){++++++}, at: [<ffffffff811c6e20>] vfs_rmdir+0x50/0x140
      
      stack backtrace:
      CPU: 2 PID: 13321 Comm: rmdir Not tainted 4.10.0-rc7-dbg+ #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      Call Trace:
       dump_stack+0x86/0xc3
       print_circular_bug+0x1c7/0x220
       __lock_acquire+0x10e6/0x1260
       lock_acquire+0x71/0x90
       mutex_lock_nested+0x5f/0x670
       iscsit_free_all_ooo_cmdsns+0x2d/0xb0 [iscsi_target_mod]
       iscsit_close_session+0xac/0x200 [iscsi_target_mod]
       lio_tpg_close_session+0x9f/0xb0 [iscsi_target_mod]
       target_shutdown_sessions+0xc3/0xd0 [target_core_mod]
       core_tpg_del_initiator_node_acl+0x91/0x140 [target_core_mod]
       target_fabric_nacl_base_release+0x20/0x30 [target_core_mod]
       config_item_release+0x5a/0xc0 [configfs]
       config_item_put+0x1d/0x1f [configfs]
       configfs_rmdir+0x1a6/0x300 [configfs]
       vfs_rmdir+0xb7/0x140
       do_rmdir+0x1f4/0x200
       SyS_rmdir+0x11/0x20
       entry_SYSCALL_64_fastpath+0x23/0xc6
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: David Disseldorp <ddiss@suse.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      d877d727
    • B
      target: Use {get,put}_unaligned_be*() instead of open coding these functions · a85d667e
      Bart Van Assche 提交于
      Introduce the function get_unaligned_be24(). Use {get,put}_unaligned_be*()
      where appropriate. This patch does not change any functionality.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: David Disseldorp <ddiss@suse.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      a85d667e
  2. 08 2月, 2017 1 次提交
  3. 11 1月, 2017 9 次提交
  4. 10 12月, 2016 1 次提交
    • B
      target: Minimize #include directives · 8dcf07be
      Bart Van Assche 提交于
      Remove superfluous #include directives from the include/target/*.h
      files. Add missing #include directives to other *.h and *.c files.
      Use forward declarations for structures where possible. This
      change reduces the build time for make M=drivers/target on my
      laptop from 27.1s to 18.7s or by about 30%.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
      8dcf07be
  5. 20 10月, 2016 2 次提交
  6. 14 5月, 2016 1 次提交
  7. 11 9月, 2015 1 次提交
    • N
      target: Attach EXTENDED_COPY local I/O descriptors to xcopy_pt_sess · 4416f89b
      Nicholas Bellinger 提交于
      This patch is a >= v4.1 regression bug-fix where control CDB
      emulation logic in commit 38b57f82 now expects a se_cmd->se_sess
      pointer to exist when determining T10-PI support is to be exposed
      for initiator host ports.
      
      To address this bug, go ahead and add locally generated se_cmd
      descriptors for copy-offload block-copy to it's own stand-alone
      se_session nexus, while the parent EXTENDED_COPY se_cmd descriptor
      remains associated with it's originating se_cmd->se_sess nexus.
      
      Note a valid se_cmd->se_sess is also required for future support
      of WRITE_INSERT and READ_STRIP software emulation when submitting
      backend I/O to se_device that exposes T10-PI suport.
      Reported-by: NAlex Gorbachev <ag@iss-integration.com>
      Tested-by: NAlex Gorbachev <ag@iss-integration.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Doug Gilbert <dgilbert@interlog.com>
      Cc: <stable@vger.kernel.org> # v4.1+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4416f89b
  8. 02 6月, 2015 1 次提交
    • B
      target: Minimize SCSI header #include directives · ba929992
      Bart Van Assche 提交于
      Only include SCSI initiator header files in target code that needs
      these header files, namely the SCSI pass-through code and the tcm_loop
      driver. Change SCSI_SENSE_BUFFERSIZE into TRANSPORT_SENSE_BUFFER in
      target code because the former is intended for initiator code and the
      latter for target code. With this patch the only initiator include
      directives in target code that remain are as follows:
      
      $ git grep -nHE 'include .scsi/(scsi.h|scsi_host.h|scsi_device.h|scsi_cmnd.h)' drivers/target drivers/infiniband/ulp/{isert,srpt} drivers/usb/gadget/legacy/tcm_*.[ch] drivers/{vhost,xen} include/{target,trace/events/target.h}
      drivers/target/loopback/tcm_loop.c:29:#include <scsi/scsi.h>
      drivers/target/loopback/tcm_loop.c:31:#include <scsi/scsi_host.h>
      drivers/target/loopback/tcm_loop.c:32:#include <scsi/scsi_device.h>
      drivers/target/loopback/tcm_loop.c:33:#include <scsi/scsi_cmnd.h>
      drivers/target/target_core_pscsi.c:39:#include <scsi/scsi_device.h>
      drivers/target/target_core_pscsi.c:40:#include <scsi/scsi_host.h>
      drivers/xen/xen-scsiback.c:52:#include <scsi/scsi_host.h> /* SG_ALL */
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJames Bottomley <JBottomley@Odin.com>
      ba929992
  9. 01 6月, 2015 1 次提交
  10. 31 5月, 2015 3 次提交
  11. 15 4月, 2015 1 次提交
    • C
      target: simplify the target template registration API · 9ac8928e
      Christoph Hellwig 提交于
      Instead of calling target_fabric_configfs_init() +
      target_fabric_configfs_register() / target_fabric_configfs_deregister()
      target_fabric_configfs_free() from every target driver, rewrite the API
      so that we have simple register/unregister functions that operate on
      a const operations vector.
      
      This patch also fixes a memory leak in several target drivers. Several
      target drivers namely called target_fabric_configfs_deregister()
      without calling target_fabric_configfs_free().
      
      A large part of this patch is based on earlier changes from
      Bart Van Assche <bart.vanassche@sandisk.com>.
      
      (v2: Add a new TF_CIT_SETUP_DRV macro so that the core configfs code
      can declare attributes as either core only or for drivers)
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      9ac8928e
  12. 08 4月, 2015 2 次提交
  13. 27 3月, 2015 1 次提交
  14. 20 11月, 2014 1 次提交
  15. 07 6月, 2014 1 次提交
  16. 10 1月, 2014 1 次提交
  17. 09 11月, 2013 1 次提交
  18. 08 11月, 2013 2 次提交
    • N
      target: Drop left-over se_lun->lun_cmd_list shutdown code · 4a9a6c8d
      Nicholas Bellinger 提交于
      Now with percpu refcounting for se_lun in place, go ahead and drop
      the legacy per se_cmd accounting for se_lun shutdown.
      
      This includes __transport_clear_lun_from_sessions(), the associated
      transport_lun_wait_for_tasks() logic, along with a handful of now
      unused se_cmd structure members and ->transport_state bits.
      
      Cc: Kent Overstreet <kmo@daterainc.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4a9a6c8d
    • N
      target: Add percpu refcounting for se_lun access · 5277797d
      Nicholas Bellinger 提交于
      This patch adds percpu refcounting for se_lun access that allows the
      association of an se_lun + se_cmd in transport_lookup_cmd_lun() to
      occur without an extra list_head for tracking outstanding I/O during
      se_lun shutdown.
      
      This effectively changes se_lun shutdown logic to wait for outstanding
      I/O percpu references to complete in transport_lun_remove_cmd() using
      se_lun->lun_ref_comp, instead of explicitly draining the per se_lun
      command list and waiting for individual se_cmd descriptor processing
      to complete.
      
      Cc: Kent Overstreet <kmo@daterainc.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      5277797d
  19. 24 10月, 2013 3 次提交
  20. 09 10月, 2013 3 次提交
  21. 02 10月, 2013 1 次提交