1. 09 1月, 2013 1 次提交
  2. 28 11月, 2012 3 次提交
  3. 18 11月, 2012 1 次提交
  4. 08 11月, 2012 1 次提交
    • N
      target: Fix possible TFO->write_pending() sense_reason_t silent WRITE corruption · b69c1fcf
      Nicholas Bellinger 提交于
      This patch fixes a possible case in transport_generic_new_cmd() where a
      failure from TFO->write_pending() from a fabric module return something
      other than -EAGAIN or -ENOMEM would cause a failed WRITE to silently
      succeed.
      
      Go ahead and return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE for this
      special case instead of only just making noise with WARN_ON().
      
      (v2: Fix incorrect exception return for all cases)
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      b69c1fcf
  5. 07 11月, 2012 6 次提交
  6. 27 10月, 2012 1 次提交
    • N
      target: Fix double-free of se_cmd in target_complete_tmr_failure · e13d5fef
      Nicholas Bellinger 提交于
      Fabric drivers currently expect to internally release se_cmd in the event
      of a TMR failure during target_submit_tmr(), which means the immediate call
      to transport_generic_free_cmd() after TFO->queue_tm_rsp() from within
      target_complete_tmr_failure() workqueue context is wrong.
      
      This is done as some fabrics expect TMR operations to be acknowledged
      before releasing the descriptor, so the assumption that core is releasing
      se_cmd associated TMR memory is incorrect.  This fixes a OOPs where
      transport_generic_free_cmd() was being called more than once.
      
      This bug was originally observed with tcm_qla2xxx fabric ports.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e13d5fef
  7. 03 10月, 2012 2 次提交
  8. 18 9月, 2012 5 次提交
  9. 08 9月, 2012 3 次提交
  10. 06 9月, 2012 3 次提交
  11. 24 8月, 2012 1 次提交
    • N
      target: Fix ->data_length re-assignment bug with SCSI overflow · 4c054ba6
      Nicholas Bellinger 提交于
      This patch fixes a long-standing bug with SCSI overflow handling
      where se_cmd->data_length was incorrectly being re-assigned to
      the larger CDB extracted allocation length, resulting in a number
      of fabric level errors that would end up causing a session reset
      in most cases.  So instead now:
      
       - Only re-assign se_cmd->data_length durining UNDERFLOW (to use the
         smaller value)
       - Use existing se_cmd->data_length for OVERFLOW (to use the smaller
         value)
      
      This fix has been tested with the following CDB to generate an
      SCSI overflow:
      
        sg_raw -r512 /dev/sdc 28 0 0 0 0 0 0 0 9 0
      
      Tested using iscsi-target, tcm_qla2xxx, loopback and tcm_vhost fabric
      ports.  Here is a bit more detail on each case:
      
       - iscsi-target: Bug with open-iscsi with overflow, sg_raw returns
                       -3584 bytes of data.
       - tcm_qla2xxx: Working as expected, returnins 512 bytes of data
       - loopback: sg_raw returns CHECK_CONDITION, from overflow rejection
                   in transport_generic_map_mem_to_cmd()
       - tcm_vhost: Same as loopback
      Reported-by: NRoland Dreier <roland@purestorage.com>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Boaz Harrosh <bharrosh@panasas.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4c054ba6
  12. 22 8月, 2012 1 次提交
  13. 18 8月, 2012 1 次提交
    • N
      target: Fix regression bug with handling of zero-length data CDBs · 74f4cf29
      Nicholas Bellinger 提交于
      This patch fixes a regression bug with the handling of zero-length
      data CDBs within transport_generic_new_cmd() code.  The bug was introduced
      with the following commit as part of the single task conversion work:
      
        commit 4101f0a8
        Author: Christoph Hellwig <hch@infradead.org>
        Date:   Tue Apr 24 00:25:03 2012 -0400
      
            target: always allocate a single task
      
      where the zero-length check for SCF_SCSI_DATA_SG_IO_CDB was incorrectly
      changed to SCF_SCSI_CONTROL_SG_IO_CDB because of the seperate comment
      in transport_generic_new_cmd() wrt to control CDBs zero-length handling
      introduced in:
      
        commit 91ec1d35
        Author: Nicholas Bellinger <nab@linux-iscsi.org>
        Date:   Fri Jan 13 12:01:34 2012 -0800
      
            target: Add workaround for zero-length control CDB handling
      
      So go ahead and change transport_generic_new_cmd() to handle control+data
      zero-length CDBs in the same manner for this special case.
      
      Tested with iscsi-target + loopback fabric port LUNs on 3.6-rc0 code.
      
      This patch will also need to be picked up for 3.5-stable.
      
      (hch: Add proper comment in transport_generic_new_cmd)
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      74f4cf29
  14. 17 8月, 2012 1 次提交
  15. 21 7月, 2012 1 次提交
  16. 18 7月, 2012 1 次提交
    • R
      target: Allow for target_submit_cmd() returning errors · d6dfc868
      Roland Dreier 提交于
      We want it to be possible for target_submit_cmd() to return errors up
      to its fabric module callers.  For now just update the prototype to
      return an int, and update all callers to handle non-zero return values
      as an error.
      
      This is immediately useful for tcm_qla2xxx to fix a long-standing active
      I/O session shutdown race, but tcm_fc, usb-gadget, and sbp-target the
      fabric maintainers need to check + ACK that handling a target_submit_cmd()
      failure due to session shutdown does not introduce regressions
      
      (nab: Respin against for-next after initial NACK + update docbook comment +
            fix double se_cmd init in exception path for usb-gadget)
      
      Cc: Chad Dupuis <chad.dupuis@qlogic.com>
      Cc: Arun Easi <arun.easi@qlogic.com>
      Cc: Chris Boot <bootc@bootc.net>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Cc: Mark Rustad <mark.d.rustad@intel.com>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Felipe Balbi <balbi@ti.com>
      Cc: Andy Grover <agrover@redhat.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      d6dfc868
  17. 17 7月, 2012 8 次提交
    • R
      target: Add generation of LOGICAL BLOCK ADDRESS OUT OF RANGE · e2397c70
      Roland Dreier 提交于
      Many SCSI commands are defined to return a CHECK CONDITION / ILLEGAL
      REQUEST with ASC set to LOGICAL BLOCK ADDRESS OUT OF RANGE if the
      initiator sends a command that accesses a too-big LBA.  Add an enum
      value and case entries so that target code can return this status.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e2397c70
    • R
      target: Remove se_session.sess_wait_list · 1c7b13fe
      Roland Dreier 提交于
      Since we set se_session.sess_tearing_down and stop new commands from
      being added to se_session.sess_cmd_list before we wait for commands to
      finish when freeing a session, there's no need for a separate
      sess_wait_list -- if we let new commands be added to sess_cmd_list
      after setting sess_tearing_down, that would be a bug that breaks the
      logic of waiting in-flight commands.
      
      Also rename target_splice_sess_cmd_list() to
      target_sess_cmd_list_set_waiting(), since we are no longer splicing
      onto a separate list.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      1c7b13fe
    • R
      target: Check sess_tearing_down in target_get_sess_cmd() · bc187ea6
      Roland Dreier 提交于
      Target core code assumes that target_splice_sess_cmd_list() has set
      sess_tearing_down and moved the list of pending commands to
      sess_wait_list, no more commands will be added to the session; if any
      are added, nothing keeps the se_session from being freed while the
      command is still in flight, which e.g. leads to use-after-free of
      se_cmd->se_sess in target_release_cmd_kref().
      
      To enforce this invariant, put a check of sess_tearing_down inside of
      sess_cmd_lock in target_get_sess_cmd(); any checks before this are
      racy and can lead to the use-after-free described above.  For example,
      the qla_target check in qlt_do_work() checks sess_tearing_down from
      work thread context but then drops all locks before calling
      target_submit_cmd() (as it must, since that is a sleeping function).
      
      However, since no locks are held, anything can happen with respect to
      the session it has looked up -- although it does correctly get
      sess_kref within its lock, so the memory won't be freed while
      target_submit_cmd() is actually running, nothing stops eg an ACL from
      being dropped and calling ->shutdown_session() (which calls into
      target_splice_sess_cmd_list()) before we get to target_get_sess_cmd().
      Once this happens, the se_session memory can be freed as soon as
      target_submit_cmd() returns and qlt_do_work() drops its reference,
      even though we've just added a command to sess_cmd_list.
      
      To prevent this use-after-free, check sess_tearing_down inside of
      sess_cmd_lock right before target_get_sess_cmd() adds a command to
      sess_cmd_list; this is synchronized with target_splice_sess_cmd_list()
      so that every command is either waited for or not added to the queue.
      
      (nab: Keep target_submit_cmd() returning void for now..)
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      bc187ea6
    • R
      target: Un-export target_get_sess_cmd() · 669ab62c
      Roland Dreier 提交于
      There are no in-tree users of target_get_sess_cmd() outside of
      target_core_transport.c.  Any new code should use the higher-level
      target_submit_cmd() interface.  So let's un-export target_get_sess_cmd()
      and make it static to the one file where it's actually used.
      
      (nab: Fix up minor fuzz to for-next)
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      669ab62c
    • C
      target: replace the processing thread with a TMR work queue · af877292
      Christoph Hellwig 提交于
      The last functionality of the target processing thread is offloading possibly
      long running task management requests from the submitter context.  To keep
      TMR semantics the same we need a single threaded ordered queue, which can
      be provided by a per-device workqueue with the right flags.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      af877292
    • C
      target: remove transport_generic_handle_cdb_map · f3146437
      Christoph Hellwig 提交于
      Remove this command submission path which is not used by any in-tree driver.
      This also removes the now unused new_cmd_map fabtric method, which a few
      drivers implemented despite never calling transport_generic_handle_cdb_map.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      f3146437
    • C
      target: simply fabric driver queue full processing · 7a6f0a1e
      Christoph Hellwig 提交于
      There is no need to schedule the delayed processing in a workqueue that
      offloads it to the target processing thread.  Instead execute it directly
      from the workqueue.  There will be a lot of future work in this area,
      which I'd likfe to defer for now as it is not nessecary for getting rid
      of the target processing thread.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      7a6f0a1e
    • C
      1389533e