1. 14 3月, 2014 2 次提交
  2. 07 3月, 2014 1 次提交
    • S
      Target/sbc: Fix sbc_copy_prot for offset scatters · 16c0ae02
      Sagi Grimberg 提交于
      When copying between device and command protection scatters
      we must take into account that device scatters might be offset
      and we might copy outside scatter range. Thus for each cmd prot
      scatter we must take the min between cmd prot scatter, dev prot
      scatter, and whats left (and loop in case we havn't copied enough
      from/to cmd prot scatter).
      
      Example (single t_prot_sg of len 2048):
      kernel: sbc_dif_copy_prot: se_cmd=ffff880380aaf970, left=2048, len=2048, dev_prot_sg_offset=3072, dev_prot_sg_len=4096
      kernel: isert: se_cmd=ffff880380aaf970 PI error found type 0 at sector 0x2600 expected 0x0 vs actual 0x725f, lba=2580
      
      Instead of copying 2048 from offset 3072 (copying junk outside sg
      limit 4096), we must to copy 1024 and continue to next sg until
      we complete cmd prot scatter.
      
      This issue was found using iSER T10-PI offload over rd_mcp (wasn't
      discovered with fileio since file_dev prot sglists are never offset).
      
      Changes from v1:
      - Fix sbc_copy_prot copy length miss-calculation
      
      Changes from v0:
      - Removed psg->offset consideration for psg_len computation
      - Removed sg->offset consideration for offset condition
      - Added copied consideraiton for len computation
      - Added copied offset to paddr when doing memcpy
      Signed-off-by: NSagi Grimberg <sagig@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      16c0ae02
  3. 05 3月, 2014 3 次提交
    • N
      iscsi/iser-target: Fix isert_conn->state hung shutdown issues · defd8848
      Nicholas Bellinger 提交于
      This patch addresses a couple of different hug shutdown issues
      related to wait_event() + isert_conn->state.  First, it changes
      isert_conn->conn_wait + isert_conn->conn_wait_comp_err from
      waitqueues to completions, and sets ISER_CONN_TERMINATING from
      within isert_disconnect_work().
      
      Second, it splits isert_free_conn() into isert_wait_conn() that
      is called earlier in iscsit_close_connection() to ensure that
      all outstanding commands have completed before continuing.
      
      Finally, it breaks isert_cq_comp_err() into seperate TX / RX
      related code, and adds logic in isert_cq_rx_comp_err() to wait
      for outstanding commands to complete before setting ISER_CONN_DOWN
      and calling complete(&isert_conn->conn_wait_comp_err).
      Acked-by: NSagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Cc: <stable@vger.kernel.org> #3.10+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      defd8848
    • N
      iscsi/iser-target: Use list_del_init for ->i_conn_node · 5159d763
      Nicholas Bellinger 提交于
      There are a handful of uses of list_empty() for cmd->i_conn_node
      within iser-target code that expect to return false once a cmd
      has been removed from the per connect list.
      
      This patch changes all uses of list_del -> list_del_init in order
      to ensure that list_empty() returns false as expected.
      Acked-by: NSagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Cc: <stable@vger.kernel.org> #3.10+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      5159d763
    • N
      iscsi-target: Fix iscsit_get_tpg_from_np tpg_state bug · a2a99cea
      Nicholas Bellinger 提交于
      This patch fixes a bug in iscsit_get_tpg_from_np() where the
      tpg->tpg_state sanity check was looking for TPG_STATE_FREE,
      instead of != TPG_STATE_ACTIVE.
      
      The latter is expected during a normal TPG shutdown once the
      tpg_state goes into TPG_STATE_INACTIVE in order to reject any
      new incoming login attempts.
      
      Cc: <stable@vger.kernel.org> #3.10+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      a2a99cea
  4. 24 2月, 2014 3 次提交
  5. 13 2月, 2014 6 次提交
  6. 30 1月, 2014 2 次提交
    • N
      target: Fix percpu_ref_put race in transport_lun_remove_cmd · 5259a06e
      Nicholas Bellinger 提交于
      This patch fixes a percpu_ref_put race for se_lun->lun_ref in
      transport_lun_remove_cmd() where ->lun_ref could end up being
      put more than once per command via different target completion
      and fabric release contexts.
      
      It adds a cmpxchg() for se_cmd->lun_ref_active to ensure that
      percpu_ref_put() is only ever called once per se_cmd.
      
      This bug was manifesting itself as a LUN shutdown regression
      bug in >= v3.13 code, where percpu_ref_kill() would end up
      hanging indefinately due to the incorrect percpu_ref count.
      
      (Change se_cmd->lun_ref_active from bool -> int to force at
       least a 4-byte cmpxchg with MIPS ll/sc ins. - Fengguang)
      Reported-by: NTommy Apel <tommyapeldk@gmail.com>
      Cc: Tommy Apel <tommyapeldk@gmail.com>
      Cc: <stable@vger.kernel.org> #3.13+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      5259a06e
    • A
      target/iscsi: Fix network portal creation race · ee291e63
      Andy Grover 提交于
      When creating network portals rapidly, such as when restoring a
      configuration, LIO's code to reuse existing portals can return a false
      negative if the thread hasn't run yet and set np_thread_state to
      ISCSI_NP_THREAD_ACTIVE. This causes an error in the network stack
      when attempting to bind to the same address/port.
      
      This patch sets NP_THREAD_ACTIVE before the np is placed on g_np_list,
      so even if the thread hasn't run yet, iscsit_get_np will return the
      existing np.
      
      Also, convert np_lock -> np_mutex + hold across adding new net portal
      to g_np_list to prevent a race where two threads may attempt to create
      the same network portal, resulting in one of them failing.
      
      (nab: Add missing mutex_unlocks in iscsit_add_np failure paths)
      (DanC: Fix incorrect spin_unlock -> spin_unlock_bh)
      Signed-off-by: NAndy Grover <agrover@redhat.com>
      Cc: <stable@vger.kernel.org> #3.1+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      ee291e63
  7. 25 1月, 2014 3 次提交
  8. 24 1月, 2014 1 次提交
    • K
      percpu_ida: Make percpu_ida_alloc + callers accept task state bitmask · 6f6b5d1e
      Kent Overstreet 提交于
      This patch changes percpu_ida_alloc() + callers to accept task state
      bitmask for prepare_to_wait() for code like target/iscsi that needs
      it for interruptible sleep, that is provided in a subsequent patch.
      
      It now expects TASK_UNINTERRUPTIBLE when the caller is able to sleep
      waiting for a new tag, or TASK_RUNNING when the caller cannot sleep,
      and is forced to return a negative value when no tags are available.
      
      v2 changes:
        - Include blk-mq + tcm_fc + vhost/scsi + target/iscsi changes
        - Drop signal_pending_state() call
      v3 changes:
        - Only call prepare_to_wait() + finish_wait() when != TASK_RUNNING
          (PeterZ)
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: NKent Overstreet <kmo@daterainc.com>
      Cc: <stable@vger.kernel.org> #3.12+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      6f6b5d1e
  9. 19 1月, 2014 7 次提交
    • N
      iscsi-target: Pre-allocate more tags to avoid ack starvation · 4a4caa29
      Nicholas Bellinger 提交于
      This patch addresses an traditional iscsi-target fabric ack starvation
      issue where iscsit_allocate_cmd() -> percpu_ida_alloc_state() ends up
      hitting slow path percpu-ida code, because iscsit_ack_from_expstatsn()
      is expected to free ack'ed tags after tag allocation.
      
      This is done to take into account the tags waiting to be acknowledged
      and released in iscsit_ack_from_expstatsn(), but who's number are not
      directly limited by the CmdSN Window queue_depth being enforced by
      the target.
      
      So that said, this patch bumps up the pre-allocated number of
      per session tags to:
      
        (max(queue_depth, ISCSIT_MIN_TAGS) * 2) + ISCSIT_EXTRA_TAGS
      
      for good measure to avoid the percpu_ida_alloc_state() slow path.
      
      Cc: <stable@vger.kernel.org> #3.12+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4a4caa29
    • N
      tcm_loop: Enable DIF/DIX modes in SCSI host LLD · 59dedde2
      Nicholas Bellinger 提交于
      This patch updates tcm_loop_driver_probe() to set protection
      information using scsi_host_set_prot() and scsi_host_set_guard(),
      which currently enabled all modes of DIF/DIX protection, minus
      DIX TYPE0.
      
      Also, update tcm_loop_submission_work() to pass struct scsi_cmnd
      related protection into target_submit_cmd_map_sgls() during CDB
      dispatch.
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      59dedde2
    • N
      target/rd: Add DIF protection into rd_execute_rw · 6e611119
      Nicholas Bellinger 提交于
      This patch adds support for DIF protection into rd_execute_rw() code
      for WRITE/READ I/O using sbc_dif_verify_[write,read]() logic.
      
      It also adds rd_get_prot_table() for locating protection SGLs
      assoicated with the ramdisk backend device.
      
      v2 changes:
        - Make rd_execute_rw() to u32 sectors count instead of sector_t
        - Drop SCF_PROT usage
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      6e611119
    • N
      target/rd: Add support for protection SGL setup + release · d7e8eb5d
      Nicholas Bellinger 提交于
      This patch adds rd_build_prot_space() + rd_release_prot_space() logic
      to setup + release protection information scatterlists.
      
      It also adds rd_init_prot() + rd_free_prot() se_subsystem_api
      callbacks used by target core code for setup + release of
      protection information.
      
      v2 changes:
        - Drop unused sg_table from rd_release_prot_space (Wei)
        - Drop rd_release_prot_space call from rd_free_device
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      d7e8eb5d
    • N
      target/rd: Refactor rd_build_device_space + rd_release_device_space · 4442dc8a
      Nicholas Bellinger 提交于
      This patch refactors rd_build_device_space() + rd_release_device_space()
      into rd_allocate_sgl_table() + rd_release_device_space() so that they
      may be used seperatly for setup + release of protection information
      scatterlists.
      
      Also add explicit memset of pages within rd_allocate_sgl_table() based
      upon passed 'init_payload' value.
      
      v2 changes:
        - Drop unused sg_table from rd_release_device_space (Wei)
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4442dc8a
    • N
      target/file: Add DIF protection support to fd_execute_rw · 42201b55
      Nicholas Bellinger 提交于
      This patch adds support for DIF protection into fd_execute_rw() code
      for WRITE/READ I/O using sbc_dif_verify_[write,read]() logic.
      
      It adds fd_do_prot_rw() for handling interface with FILEIO PI, and
      uses a locally allocated fd_prot->prot_buf + fd_prot->prot_sg for
      interacting with SBC DIF verify emulation code.
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      42201b55
    • N
      target/file: Add DIF protection init/format support · 0f5e2ec4
      Nicholas Bellinger 提交于
      This patch adds support for DIF protection init/format support into
      the FILEIO backend.
      
      It involves using a seperate $FILE.protection for storing PI that is
      opened via fd_init_prot() using the common pi_prot_type attribute.
      The actual formatting of the protection is done via fd_format_prot()
      using the common pi_prot_format attribute, that will populate the
      initial PI data based upon the currently configured pi_prot_type.
      
      Based on original FILEIO code from Sagi.
      
      v1 changes:
        - Fix sparse warnings in fd_init_format_buf (Fengguang)
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      0f5e2ec4
  10. 18 1月, 2014 10 次提交
    • N
      target/iblock: Add blk_integrity + BIP passthrough support · ecebbf6c
      Nicholas Bellinger 提交于
      This patch adds blk_integrity passthrough support for block_device
      backends using IBLOCK.
      
      This includes iblock_alloc_bip() + setup of bio_integrity_payload
      information that attaches to the leading struct bio once bio_list
      is populated during fast-path iblock_execute_rw() I/O dispatch.
      
      It also updates setup in iblock_configure_device() to detect modes
      of protection + se dev->dev_attrib.pi_prot_type accordingly, along
      with creating required bio_set integrity mempools.
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      ecebbf6c
    • N
      target: Add protection SGLs to target_submit_cmd_map_sgls · def2b339
      Nicholas Bellinger 提交于
      This patch adds support to target_submit_cmd_map_sgls() for
      accepting 'sgl_prot' + 'sgl_prot_count' parameters for
      DIF protection information.
      
      Note the passed parameters are stored at se_cmd->t_prot_sg
      and se_cmd->t_prot_nents respectively.
      
      Also, update tcm_loop and vhost-scsi fabrics usage of
      target_submit_cmd_map_sgls() to take into account the
      new parameters.
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      def2b339
    • N
      target/configfs: Expose protection device attributes · 2ed22c9c
      Nicholas Bellinger 提交于
      This patch adds support for exposing DIF protection device
      attributes via configfs.  This includes:
      
         pi_prot_type: Protection Type (0, 1, 3 currently support)
         pi_prot_format: Protection Format Operation (FILEIO only)
      
      Within se_dev_set_pi_prot_type() it also adds the se_subsystem_api
      device callbacks to setup per device protection information.
      
      v2 changes:
        - Drop pi_guard_type + pi_prot_version related code (MKP)
        - Add pi_prot_format logic (Sagi)
        - Add ->free_prot callback in target_free_device
        - Add hw_pi_prot_type read-only attribute
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      2ed22c9c
    • N
      target/spc: Expose ATO bit in control mode page · 0c30f421
      Nicholas Bellinger 提交于
      This patch updates spc_modesense_control() to set the Application
      Tag Owner (ATO) bit when when DIF emulation is enabled by the
      backend device.
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      0c30f421
    • N
      target/sbc: Add P_TYPE + PROT_EN bits to READ_CAPACITY_16 · 56dac14c
      Nicholas Bellinger 提交于
      This patch updates sbc_emulate_readcapacity_16() to set
      P_TYPE and PROT_EN bits when DIF emulation is enabled by
      the backend device.
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      56dac14c
    • N
      target/spc: Add protection related bits to INQUIRY EVPD=0x86 · 43bb95c7
      Nicholas Bellinger 提交于
      This patch updates spc_emulate_evpd_86() (extended INQUIRY) to
      report GRD_CHK (Guard Check) and REF_CHK (Reference Check) bits
      when DIF emulation is enabled by the backend device.
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      43bb95c7
    • N
      target/spc: Add protection bit to standard INQUIRY output · bdbad2bd
      Nicholas Bellinger 提交于
      This patch updates spc_emulate_inquiry_std() to set the
      PROTECT bit when DIF emulation is enabled by the backend
      device.
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      bdbad2bd
    • N
      target/sbc: Add DIF TYPE1+TYPE3 read/write verify emulation · 41861fa8
      Nicholas Bellinger 提交于
      This patch adds support for DIF read/write verify emulation
      for TARGET_DIF_TYPE1_PROT + TARGET_DIF_TYPE3_PROT operation.
      
      This includes sbc_dif_verify_write() + sbc_dif_verify_read()
      calls accessable by backend drivers to perform DIF verify
      for SGL based data and protection information.
      
      Also included is sbc_dif_copy_prot() logic to copy protection
      information to/from backend provided protection SGLs.
      
      Based on scsi_debug.c DIF TYPE1+TYPE3 emulation.
      
      v2 changes:
        - Select CRC_T10DIF for TARGET_CORE in Kconfig (Fengguang)
        - Drop IP checksum logic from sbc_dif_v1_verify (MKP)
        - Fix offset on app_tag = 0xffff in sbc_dif_verify_read()
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      41861fa8
    • N
      target/sbc: Add DIF setup in sbc_check_prot + sbc_parse_cdb · 499bf77b
      Nicholas Bellinger 提交于
      This patch adds sbc_check_prot() for performing various DIF
      related CDB sanity checks, along with setting cmd->prot_type
      once sanity checks have passed.
      
      Also, add calls in sbc_parse_cdb() for READ_[10,12,16] +
      WRITE_[10,12,16] to perform DIF sanity checking.
      
      v2 changes:
        - Make sbc_check_prot defined as static (Fengguang + Wei)
        - Remove unprotected READ/WRITE warning (mkp)
        - Populate cmd->prot_type + friends (Sagi)
        - Drop SCF_PROT usage
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      499bf77b
    • N
      target: Add DIF CHECK_CONDITION ASC/ASCQ exception cases · fcc4f17b
      Nicholas Bellinger 提交于
      This patch adds support for DIF related CHECK_CONDITION ASC/ASCQ
      exception cases into transport_send_check_condition_and_sense().
      
      This includes:
      
        LOGICAL BLOCK GUARD CHECK FAILED
        LOGICAL BLOCK APPLICATION TAG CHECK FAILED
        LOGICAL BLOCK REFERENCE TAG CHECK FAILED
      
      that used by DIF TYPE1 and TYPE3 failure cases.
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      fcc4f17b
  11. 10 1月, 2014 2 次提交