1. 19 3月, 2017 6 次提交
    • M
      target: fix race during implicit transition work flushes · 760bf578
      Mike Christie 提交于
      This fixes the following races:
      
      1. core_alua_do_transition_tg_pt could have read
      tg_pt_gp_alua_access_state and gone into this if chunk:
      
      if (!explicit &&
              atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state) ==
                 ALUA_ACCESS_STATE_TRANSITION) {
      
      and then core_alua_do_transition_tg_pt_work could update the
      state. core_alua_do_transition_tg_pt would then only set
      tg_pt_gp_alua_pending_state and the tg_pt_gp_alua_access_state would
      not get updated with the second calls state.
      
      2. core_alua_do_transition_tg_pt could be setting
      tg_pt_gp_transition_complete while the tg_pt_gp_transition_work
      is already completing. core_alua_do_transition_tg_pt then waits on the
      completion that will never be called.
      
      To handle these issues, we just call flush_work which will return when
      core_alua_do_transition_tg_pt_work has completed so there is no need
      to do the complete/wait. And, if core_alua_do_transition_tg_pt_work
      was running, instead of trying to sneak in the state change, we just
      schedule up another core_alua_do_transition_tg_pt_work call.
      
      Note that this does not handle a possible race where there are multiple
      threads call core_alua_do_transition_tg_pt at the same time. I think
      we need a mutex in target_tg_pt_gp_alua_access_state_store.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      760bf578
    • M
      target: allow userspace to set state to transitioning · 1ca4d4fa
      Mike Christie 提交于
      Userspace target_core_user handlers like tcmu-runner may want to set the
      ALUA state to transitioning while it does implicit transitions. This
      patch allows that state when set from configfs.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      1ca4d4fa
    • M
      target: fix ALUA transition timeout handling · d7175373
      Mike Christie 提交于
      The implicit transition time tells initiators the min time
      to wait before timing out a transition. We currently schedule
      the transition to occur in tg_pt_gp_implicit_trans_secs
      seconds so there is no room for delays. If
      core_alua_do_transition_tg_pt_work->core_alua_update_tpg_primary_metadata
      needs to write out info to a remote file, then the initiator can
      easily time out the operation.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      d7175373
    • M
      target: Use system workqueue for ALUA transitions · 207ee841
      Mike Christie 提交于
      If tcmu-runner is processing a STPG and needs to change the kernel's
      ALUA state then we cannot use the same work queue for task management
      requests and ALUA transitions, because we could deadlock. The problem
      occurs when a STPG times out before tcmu-runner is able to
      call into target_tg_pt_gp_alua_access_state_store->
      core_alua_do_port_transition -> core_alua_do_transition_tg_pt ->
      queue_work. In this case, the tmr is on the work queue waiting for
      the STPG to complete, but the STPG transition is now queued behind
      the waiting tmr.
      
      Note:
      This bug will also be fixed by this patch:
      http://www.spinics.net/lists/target-devel/msg14560.html
      which switches the tmr code to use the system workqueues.
      
      For both, I am not sure if we need a dedicated workqueue since
      it is not a performance path and I do not think we need WQ_MEM_RECLAIM
      to make forward progress to free up memory like the block layer does.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      207ee841
    • M
      target: fail ALUA transitions for pscsi · 0a414572
      Mike Christie 提交于
      We do not setup the LU group for pscsi devices, so if you write
      a state to alua_access_state that will cause a transition you will
      get a NULL pointer dereference.
      
      This patch will fail attempts to try and transition the path
      for backend devices that set the TRANSPORT_FLAG_PASSTHROUGH_ALUA
      flag.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      0a414572
    • M
      target: allow ALUA setup for some passthrough backends · 530c6891
      Mike Christie 提交于
      This patch allows passthrough backends to use the core/base LIO
      ALUA setup and state checks, but still handle the execution of
      commands.
      
      This will allow the target_core_user module to execute STPG and RTPG
      in userspace, and not have to duplicate the ALUA state checks, path
      information (needed so we can check if command is executable on
      specific paths) and setup (rtslib sets/updates the configfs ALUA
      interface like it does for iblock or file).
      
      For STPG, the target_core_user userspace daemon, tcmu-runner will
      still execute the STPG, and to update the core/base LIO state it
      will use the existing configfs interface. For RTPG, tcmu-runner
      will loop over configfs and/or cache the state.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      530c6891
  2. 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
  3. 10 5月, 2016 1 次提交
  4. 23 6月, 2015 2 次提交
  5. 17 6月, 2015 1 次提交
  6. 16 6月, 2015 2 次提交
  7. 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
  8. 01 6月, 2015 4 次提交
    • N
      target: Drop se_lun->lun_active for existing percpu lun_ref · 9e37d042
      Nicholas Bellinger 提交于
      With se_port_t and t10_alua_tg_pt_gp_member being absored into se_lun,
      there is no need for an extra atomic_t based reference count for PR
      ALL_TG_PT=1 and ALUA access state transition.
      
      Go ahead and use the existing percpu se_lun->lun_ref instead, and
      convert the two special cases to percpu_ref_tryget_live() to avoid
      se_lun if transport_clear_lun_ref() has already been invoked to
      shutdown the se_lun.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      9e37d042
    • N
      target: Drop lun_sep_lock for se_lun->lun_se_dev RCU usage · 4cc987ea
      Nicholas Bellinger 提交于
      With se_port and t10_alua_tg_pt_gp_member being absored into se_lun,
      there is no need for an extra lock to protect se_lun->lun_se_dev
      assignment.
      
      This patch also converts backend drivers to use call_rcu() release
      to allow any se_device readers to complete.  The call_rcu() instead
      of kfree_rcu() is required here because se_device is embedded into
      the backend driver specific structure.
      
      Also, convert se_lun->lun_stats to use atomic_long_t within the
      target_complete_ok_work() completion callback, and add FIXME for
      transport_lookup_tmr_lun() with se_lun->lun_ref.
      
      Finally, update sbp_update_unit_directory() special case usage with
      proper rcu_dereference_raw() and configfs symlink comment.
      Reported-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Chris Boot <bootc@bootc.net>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4cc987ea
    • C
      target: Subsume se_port + t10_alua_tg_pt_gp_member into se_lun · adf653f9
      Christoph Hellwig 提交于
      This patch eliminates all se_port + t10_alua_tg_pt_gp_member usage,
      and converts current users to direct se_lun pointer dereference.
      
      This includes the removal of core_export_port(), core_release_port()
      core_dev_export() and core_dev_unexport().  Along with conversion
      of special case se_lun pointer dereference within PR ALL_TG_PT=1
      and ALUA access state transition UNIT_ATTENTION handling.
      
      Also, update core_enable_device_list_for_node() to reference the
      new per se_lun->lun_deve_list when creating a new entry, or
      replacing an existing one via RCU.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      adf653f9
    • N
      target: Convert se_node_acl->device_list[] to RCU hlist · 29a05dee
      Nicholas Bellinger 提交于
      This patch converts se_node_acl->device_list[] table for mappedluns
      to modern RCU hlist_head usage in order to support an arbitrary number
      of node_acl lun mappings.
      
      It converts transport_lookup_*_lun() fast-path code to use RCU read path
      primitives when looking up se_dev_entry.  It adds a new hlist_head at
      se_node_acl->lun_entry_hlist for this purpose.
      
      For transport_lookup_cmd_lun() code, it works with existing per-cpu
      se_lun->lun_ref when associating se_cmd with se_lun + se_device.
      Also, go ahead and update core_create_device_list_for_node() +
      core_free_device_list_for_node() to use ->lun_entry_hlist.
      
      It also converts se_dev_entry->pr_ref_count access to use modern
      struct kref counting, and updates core_disable_device_list_for_node()
      to kref_put() and block on se_deve->pr_comp waiting for outstanding PR
      special-case PR references to drop, then invoke kfree_rcu() to wait
      for the RCU grace period to complete before releasing memory.
      
      So now that se_node_acl->lun_entry_hlist fast path access uses RCU
      protected pointers, go ahead and convert remaining non-fast path
      RCU updater code using ->lun_entry_lock to struct mutex to allow
      callers to block while walking se_node_acl->lun_entry_hlist.
      
      Finally drop the left-over core_clear_initiator_node_from_tpg() that
      originally cleared lun_access during se_node_acl shutdown, as post
      RCU conversion it now becomes duplicated logic.
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      29a05dee
  9. 31 5月, 2015 2 次提交
  10. 25 11月, 2014 1 次提交
  11. 02 10月, 2014 1 次提交
    • J
      target: encapsulate smp_mb__after_atomic() · 33940d09
      Joern Engel 提交于
      The target code has a rather generous helping of smp_mb__after_atomic()
      throughout the code base.  Most atomic operations were followed by one
      and none were preceded by smp_mb__before_atomic(), nor accompanied by a
      comment explaining the need for a barrier.
      
      Instead of trying to prove for every case whether or not it is needed,
      this patch introduces atomic_inc_mb() and atomic_dec_mb(), which
      explicitly include the memory barriers before and after the atomic
      operation.  For now they are defined in a target header, although they
      could be of general use.
      
      Most of the existing atomic/mb combinations were replaced by the new
      helpers.  In a few cases the atomic was sandwiched in
      spin_lock/spin_unlock and I simply removed the barrier.
      
      I suspect that in most cases the correct conversion would have been to
      drop the barrier.  I also suspect that a few cases exist where a) the
      barrier was necessary and b) a second barrier before the atomic would
      have been necessary and got added by this patch.
      Signed-off-by: NJoern Engel <joern@logfs.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      33940d09
  12. 06 6月, 2014 1 次提交
  13. 18 4月, 2014 1 次提交
  14. 14 3月, 2014 1 次提交
    • P
      target: silence GCC warning in target_alua_state_check · 1e3ab99d
      Paul Bolle 提交于
      Building target_core_alua.o triggers a GCC warning:
          drivers/target/target_core_alua.c: In function ‘target_alua_state_check’:
          drivers/target/target_core_alua.c:773:18: warning: ‘alua_ascq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             cmd->scsi_ascq = alua_ascq;
                            ^
      
      This is a false positive. A little trial and error shows it is
      apparently caused by core_alua_state_lba_dependent(). It must be hard
      for GCC to track the branches of a switch statement, inside a
      list_for_each_entry loop, inside a while loop.
      
      But if we add a small (inline) helper function we can reorganize the
      code a bit. That also allows to drop alua_ascq which, obviously, gets
      rid of this warning.
      Signed-off-by: NPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      1e3ab99d
  15. 13 2月, 2014 1 次提交
    • N
      target: Fix 32-bit + CONFIG_LBDAF=n link error w/ sector_div · cdf55949
      Nicholas Bellinger 提交于
      This patch changes core_alua_state_lba_dependent() to use do_div()
      instead sector_div() to avoid the following link error on 32-bit
      with CONFIG_LBDAF=n as reported by Jim:
      
      buildlog-1391099072.txt-drivers/built-in.o: In function `target_alua_state_check':
      buildlog-1391099072.txt-(.text+0x928d93): undefined reference to `__umoddi3'
      buildlog-1391099072.txt:make: *** [vmlinux] Error 1 --
      buildlog-1391101753.txt-  CC      init/version.o
      buildlog-1391101753.txt-  LD      init/built-in.o
      buildlog-1391101753.txt-drivers/built-in.o: In function `core_alua_state_lba_dependent':
      buildlog-1391101753.txt-/home/jim/linux/drivers/target/target_core_alua.c:503: undefined reference to `__umoddi3'
      buildlog-1391101753.txt:make: *** [vmlinux] Error 1
      Reported-by: NJim Davis <jim.epost@gmail.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      cdf55949
  16. 10 1月, 2014 3 次提交
  17. 18 12月, 2013 4 次提交
  18. 21 11月, 2013 4 次提交
  19. 11 9月, 2013 3 次提交
    • N
      target: Update copyright ownership/year information to 2013 · 4c76251e
      Nicholas Bellinger 提交于
      Update copyright ownership/year information for target-core,
      loopback, iscsi-target, tcm_qla2xx, vhost and iser-target.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4c76251e
    • G
      target: Fix >= v3.9+ regression in PR APTPL + ALUA metadata write-out · f730f915
      Gera Kazakov 提交于
      This patch fixes a >= v3.9+ regression in __core_scsi3_write_aptpl_to_file()
      + core_alua_write_tpg_metadata() write-out, where a return value of -EIO was
      incorrectly being returned upon success.
      
      This bug was originally introduced in:
      
      commit 0e9b10a9
      Author: Al Viro <viro@zeniv.linux.org.uk>
      Date:   Sat Feb 23 15:22:43 2013 -0500
      
          target: writev() on single-element vector is pointless
      
      However, given that the return of core_scsi3_update_and_write_aptpl()
      was not used to determine if a command should be returned with non GOOD
      status, this bug was not being triggered in PR logic until v3.11-rc1 by
      commit:
      
      commit 459f213b
      Author: Andy Grover <agrover@redhat.com>
      Date:   Thu May 16 10:41:02 2013 -0700
      
          target: Allocate aptpl_buf inside update_and_write_aptpl()
      
      So, go ahead and only return -EIO if kernel_write() returned a
      negative value.
      Reported-by: NGera Kazakov <gkazakov@msn.com>
      Signed-off-by: NGera Kazakov <gkazakov@msn.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: stable@vger.kernel.org # 3.9+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      f730f915
    • N
      target: Avoid non-existent tg_pt_gp_mem in target_alua_state_check · 89c12cc9
      Nicholas Bellinger 提交于
      This patch adds an check for a non-existent port->sep_alua_tg_pt_gp_mem
      within target_alua_state_check(), which is not present for internally
      dispatched EXTENDED_COPY WRITE I/O to the destination target port.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Martin Petersen <martin.petersen@oracle.com>
      Cc: Chris Mason <chris.mason@fusionio.com>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Zach Brown <zab@redhat.com>
      Cc: James Bottomley <JBottomley@Parallels.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: NNicholas Bellinger <nab@daterainc.com>
      89c12cc9