1. 08 9月, 2012 2 次提交
    • P
      target: support zero-size allocation lengths in transport_kmap_data_sg · 3717ef0c
      Paolo Bonzini 提交于
      In order to support zero-size allocation lengths, do not assert
      that we have a scatterlist until after checking cmd->data_length.
      
      But once we do this, we can have two cases of transport_kmap_data_sg
      returning NULL: a zero-size allocation length, or an out-of-memory
      condition.  Report the latter using sense codes, so that the SCSI
      command that triggered it will fail.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      3717ef0c
    • P
      target: go through normal processing for zero-length PSCSI commands · 306c11b2
      Paolo Bonzini 提交于
      Right now, commands with a zero-size payload are skipped completely.
      This is wrong; such commands should be passed down to the device and
      processed normally.
      
      For physical backends, this ignores completely things such as START
      STOP UNIT.  For virtual backends, we have a hack in place to clear a
      unit attention state on a zero-size REQUEST SENSE, but we still do
      not report errors properly on zero-length commands---out-of-bounds
      0-block reads and writes, too small parameter list lengths, etc.
      
      This patch fixes this for PSCSI.  Uses of transport_kmap_data_sg are
      guarded with a check for non-zero cmd->data_length; for all other
      commands a zero length is handled properly in pscsi_execute_cmd.
      The sole exception will be for now REPORT LUNS, which is handled
      through the normal SPC emulation.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      306c11b2
  2. 06 9月, 2012 3 次提交
  3. 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
  4. 22 8月, 2012 1 次提交
  5. 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
  6. 17 8月, 2012 1 次提交
  7. 21 7月, 2012 1 次提交
  8. 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
  9. 17 7月, 2012 22 次提交
  10. 13 6月, 2012 1 次提交
  11. 17 5月, 2012 2 次提交
    • M
      target: Handle ATA_16 passthrough for pSCSI backend devices · 8da10935
      mengcong 提交于
      The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs
      with a SATA CD-ROM. This patch adds support to it so that PSCSI
      CD-ROM passthrough works with the cdrecord.
      
      (nab: Add !passthrough check to prevent non pSCSI backends from ATA_16)
      Signed-off-by: NCong Meng <mc@linux.vnet.ibm.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      8da10935
    • N
      target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bits · ba539743
      Nicholas Bellinger 提交于
      This patch fixes the MAINTENANCE_IN service action type checks to only
      look at the proper lower 5 bits of cdb byte 1.  This addresses the case
      where MI_REPORT_TARGET_PGS w/ extended header using the upper three bits of
      cdb byte 1 was not processed correctly in transport_generic_cmd_sequencer,
      as well as the three cases for standby, unavailable, and transition ALUA
      primary access state checks.
      
      Also add MAINTENANCE_IN to the excluded list in transport_generic_prepare_cdb()
      to prevent the PARAMETER DATA FORMAT bits from being cleared.
      
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Rob Evers <revers@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      ba539743
  12. 16 5月, 2012 1 次提交
  13. 12 5月, 2012 2 次提交
  14. 10 5月, 2012 1 次提交
    • N
      target: Remove max_sectors device attribute for modern se_task less code · 11e764bd
      Nicholas Bellinger 提交于
      This patch removes the original usage of dev_attr->max_sectors in favor of
      dev_attr->hw_max_sectors that is now being enforced by target core from
      within transport_generic_cmd_sequencer() for SCF_SCSI_DATA_SG_IO_CDB ops.
      
      After the recent se_task removal patches from hch, this value for IBLOCK
      backends being set via configfs by userspace from an saved max_sectors
      value that is turning out to be problematic, so it makes sense to go ahead
      and remove this now legacy attribute all-together.
      
      This patch also continues to make se_dev_set_default_attribs() do
      (sectors / block_size) alignment for what actually get used by
      target_core_mod to be safe here, following the same alignment currently
      used by fabric_max_sectors.
      Reported-by: NAndy Grover <agrover@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      11e764bd