1. 19 3月, 2017 9 次提交
    • 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
    • M
      tcmu: return on first Opt parse failure · 2579325c
      Mike Christie 提交于
      We only were returing failure if the last opt to be parsed failed.
      This has a return failure when we first detect a failure.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      2579325c
    • M
      tcmu: allow hw_max_sectors greater than 128 · 3abaa2bf
      Mike Christie 提交于
      tcmu hard codes the hw_max_sectors to 128 which is a litle small.
      Userspace uses the max_sectors to report the optimal IO size and
      some initiators perform better with larger IOs (open-iscsi seems
      to do better with 256 to 512 depending on the test).
      
      (Fix do not display hw max sectors twice - MNC)
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      3abaa2bf
    • N
      target: Drop pointless tfo->check_stop_free check · 9c28ca4f
      Nicholas Bellinger 提交于
      All in-tree fabric drivers provide a tfo->check_stop_free(),
      so there is no need to do the extra check within existing
      transport_cmd_check_stop_to_fabric() code.
      
      Just to be sure, add a check in target_fabric_tf_ops_check()
      to notify any out-of-tree drivers that might be missing it.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      9c28ca4f
  2. 08 3月, 2017 2 次提交
    • M
      target: Fix VERIFY_16 handling in sbc_parse_cdb · 13603685
      Max Lohrmann 提交于
      As reported by Max, the Windows 2008 R2 chkdsk utility expects
      VERIFY_16 to be supported, and does not handle the returned
      CHECK_CONDITION properly, resulting in an infinite loop.
      
      The kernel will log huge amounts of this error:
      
      kernel: TARGET_CORE[iSCSI]: Unsupported SCSI Opcode 0x8f, sending
      CHECK_CONDITION.
      Signed-off-by: NMax Lohrmann <post@wickenrode.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      13603685
    • N
      target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export · a04e54f2
      Nicholas Bellinger 提交于
      The following fixes a divide by zero OOPs with TYPE_TAPE
      due to pscsi_tape_read_blocksize() failing causing a zero
      sd->sector_size being propigated up via dev_attrib.hw_block_size.
      
      It also fixes another long-standing bug where TYPE_TAPE and
      TYPE_MEDIMUM_CHANGER where using pscsi_create_type_other(),
      which does not call scsi_device_get() to take the device
      reference.  Instead, rename pscsi_create_type_rom() to
      pscsi_create_type_nondisk() and use it for all cases.
      
      Finally, also drop a dump_stack() in pscsi_get_blocks() for
      non TYPE_DISK, which in modern target-core can get invoked
      via target_sense_desc_format() during CHECK_CONDITION.
      Reported-by: NMalcolm Haak <insanemal@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      a04e54f2
  3. 02 3月, 2017 2 次提交
  4. 27 2月, 2017 3 次提交
    • N
      target: Add counters for ABORT_TASK success + failure · c87ba9c4
      Nicholas Bellinger 提交于
      This patch introduces two counters for ABORT_TASK success +
      failure under:
      
         /sys/kernel/config/target/core/$HBA/$DEV/statistics/scsi_tgt_dev/
      
      that are useful for diagnosing various backend device latency
      and front fabric issues.
      
      Normally when folks see alot of aborts_complete happening,
      it means the backend device I/O completion latency is high,
      and not returning completions fast enough before host side
      timeouts trigger.
      
      And normally when folks see alot of aborts_no_task, it means
      completions are being posted by target-core into fabric driver
      code, but the responses aren't making it back to the host.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      c87ba9c4
    • N
      iscsi-target: Fix early login failure statistics misses · 17c61ad6
      Nicholas Bellinger 提交于
      Due to the long standing checks in iscsit_snmp_get_tiqn()
      that assume conn->sess->tpg dereference of tpg->tpg_tiqn
      for iscsit_collect_login_stats() usage, some of the early
      login failure cases like ISCSI_LOGIN_STATUS_TGT_FORBIDDEN
      where not getting incremented, due to sess->tpg assignment
      happening later in iscsi_login_zero_tsih_s2().
      
      Instead, use the earlier conn->tpg assignment done by
      iscsi_target_locate_portal() -> iscsit_get_tpg_from_np()
      so the existing counters are incremented correctly for
      the various early login failure cases.
      
      Also, go ahead and drop the old rate limiting check in
      iscsit_collect_login_stats(), so we get the true number
      of failed login attempts in the existing statistics.
      Reported-by: NRyan Stiles <ras@datera.io>
      Cc: Ryan Stiles <ras@datera.io>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      17c61ad6
    • N
      target: Fix NULL dereference during LUN lookup + active I/O shutdown · bd4e2d29
      Nicholas Bellinger 提交于
      When transport_clear_lun_ref() is shutting down a se_lun via
      configfs with new I/O in-flight, it's possible to trigger a
      NULL pointer dereference in transport_lookup_cmd_lun() due
      to the fact percpu_ref_get() doesn't do any __PERCPU_REF_DEAD
      checking before incrementing lun->lun_ref.count after
      lun->lun_ref has switched to atomic_t mode.
      
      This results in a NULL pointer dereference as LUN shutdown
      code in core_tpg_remove_lun() continues running after the
      existing ->release() -> core_tpg_lun_ref_release() callback
      completes, and clears the RCU protected se_lun->lun_se_dev
      pointer.
      
      During the OOPs, the state of lun->lun_ref in the process
      which triggered the NULL pointer dereference looks like
      the following on v4.1.y stable code:
      
      struct se_lun {
        lun_link_magic = 4294932337,
        lun_status = TRANSPORT_LUN_STATUS_FREE,
      
        .....
      
        lun_se_dev = 0x0,
        lun_sep = 0x0,
      
        .....
      
        lun_ref = {
          count = {
            counter = 1
          },
          percpu_count_ptr = 3,
          release = 0xffffffffa02fa1e0 <core_tpg_lun_ref_release>,
          confirm_switch = 0x0,
          force_atomic = false,
          rcu = {
            next = 0xffff88154fa1a5d0,
            func = 0xffffffff8137c4c0 <percpu_ref_switch_to_atomic_rcu>
          }
        }
      }
      
      To address this bug, use percpu_ref_tryget_live() to ensure
      once __PERCPU_REF_DEAD is visable on all CPUs and ->lun_ref
      has switched to atomic_t, all new I/Os will fail to obtain
      a new lun->lun_ref reference.
      
      Also use an explicit percpu_ref_kill_and_confirm() callback
      to block on ->lun_ref_comp to allow the first stage and
      associated RCU grace period to complete, and then block on
      ->lun_ref_shutdown waiting for the final percpu_ref_put()
      to drop the last reference via transport_lun_remove_cmd()
      before continuing with core_tpg_remove_lun() shutdown.
      Reported-by: NRob Millner <rlm@daterainc.com>
      Tested-by: NRob Millner <rlm@daterainc.com>
      Cc: Rob Millner <rlm@daterainc.com>
      Tested-by: NVaibhav Tandon <vst@datera.io>
      Cc: Vaibhav Tandon <vst@datera.io>
      Tested-by: NBryant G. Ly <bryantly@linux.vnet.ibm.com>
      Cc: <stable@vger.kernel.org> # v3.14+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      bd4e2d29
  5. 25 2月, 2017 1 次提交
  6. 21 2月, 2017 2 次提交
  7. 19 2月, 2017 7 次提交
  8. 14 2月, 2017 1 次提交
  9. 11 2月, 2017 1 次提交
  10. 09 2月, 2017 12 次提交