1. 31 5月, 2015 5 次提交
  2. 15 4月, 2015 1 次提交
    • C
      target: simplify the target template registration API · 9ac8928e
      Christoph Hellwig 提交于
      Instead of calling target_fabric_configfs_init() +
      target_fabric_configfs_register() / target_fabric_configfs_deregister()
      target_fabric_configfs_free() from every target driver, rewrite the API
      so that we have simple register/unregister functions that operate on
      a const operations vector.
      
      This patch also fixes a memory leak in several target drivers. Several
      target drivers namely called target_fabric_configfs_deregister()
      without calling target_fabric_configfs_free().
      
      A large part of this patch is based on earlier changes from
      Bart Van Assche <bart.vanassche@sandisk.com>.
      
      (v2: Add a new TF_CIT_SETUP_DRV macro so that the core configfs code
      can declare attributes as either core only or for drivers)
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      9ac8928e
  3. 08 4月, 2015 1 次提交
    • N
      vhost/scsi: Add fabric_prot_type attribute support · b1d75fe5
      Nicholas Bellinger 提交于
      This patch updates vhost-scsi to add a new fabric_prot_type TPG
      attribute, used for controlling LLD level protection into LIO when
      the backend device does not support T10-PI.
      
      This is required for vhost-scsi to enable WRITE_STRIP + READ_INSERT
      operations using software emulation + crct10dif instruction offload.
      
      It's disabled by default and controls which se_sesion->sess_prot_type
      are set at vhost_scsi_make_nexus() session registration time.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Martin Petersen <martin.petersen@oracle.com>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      b1d75fe5
  4. 20 3月, 2015 1 次提交
    • B
      loop/usb/vhost-scsi/xen-scsiback: Fix use of __transport_register_session · 2f450cc1
      Bart Van Assche 提交于
      This patch changes loopback, usb-gadget, vhost-scsi and xen-scsiback
      fabric code to invoke transport_register_session() instead of the
      unprotected flavour, to ensure se_tpg->session_lock is taken when
      adding new session list nodes to se_tpg->tpg_sess_list.
      
      Note that since these four fabric drivers already hold their own
      internal TPG mutexes when accessing se_tpg->tpg_sess_list, and
      consist of a single se_session created through configfs attribute
      access, no list corruption can currently occur.
      
      So for correctness sake, go ahead and use the se_tpg->session_lock
      protected version for these four fabric drivers.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      2f450cc1
  5. 06 2月, 2015 1 次提交
    • D
      vhost/scsi: potential memory corruption · 59c816c1
      Dan Carpenter 提交于
      This code in vhost_scsi_make_tpg() is confusing because we limit "tpgt"
      to UINT_MAX but the data type of "tpg->tport_tpgt" and that is a u16.
      
      I looked at the context and it turns out that in
      vhost_scsi_set_endpoint(), "tpg->tport_tpgt" is used as an offset into
      the vs_tpg[] array which has VHOST_SCSI_MAX_TARGET (256) elements so
      anything higher than 255 then it is invalid.  I have made that the limit
      now.
      
      In vhost_scsi_send_evt() we mask away values higher than 255, but now
      that the limit has changed, we don't need the mask.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      59c816c1
  6. 05 2月, 2015 8 次提交
  7. 04 2月, 2015 1 次提交
  8. 07 1月, 2015 1 次提交
    • N
      vhost-scsi: Add missing virtio-scsi -> TCM attribute conversion · 46243860
      Nicholas Bellinger 提交于
      While looking at hch's recent conversion to drop the MSG_*_TAG
      definitions, I noticed a long standing bug in vhost-scsi where
      the VIRTIO_SCSI_S_* attribute definitions where incorrectly
      being passed directly into target_submit_cmd_map_sgls().
      
      This patch adds the missing virtio-scsi to TCM/SAM task attribute
      conversion.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: stable@vger.kernel.org # 3.5
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      46243860
  9. 09 12月, 2014 1 次提交
  10. 29 10月, 2014 1 次提交
    • N
      vhost-scsi: Take configfs group dependency during VHOST_SCSI_SET_ENDPOINT · ab8edab1
      Nicholas Bellinger 提交于
      This patch addresses a bug where individual vhost-scsi configfs endpoint
      groups can be removed from below while active exports to QEMU userspace
      still exist, resulting in an OOPs.
      
      It adds a configfs_depend_item() in vhost_scsi_set_endpoint() to obtain
      an explicit dependency on se_tpg->tpg_group in order to prevent individual
      vhost-scsi WWPN endpoints from being released via normal configfs methods
      while an QEMU ioctl reference still exists.
      
      Also, add matching configfs_undepend_item() in vhost_scsi_clear_endpoint()
      to release the dependency, once QEMU's reference to the individual group
      at /sys/kernel/config/target/vhost/$WWPN/$TPGT is released.
      
      (Fix up vhost_scsi_clear_endpoint() error path - DanC)
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Cc: <stable@vger.kernel.org> # 3.6+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      ab8edab1
  11. 23 6月, 2014 1 次提交
  12. 12 6月, 2014 1 次提交
    • N
      vhost-scsi: Include prot_bytes into expected data transfer length · 9f977ef7
      Nicholas Bellinger 提交于
      This patch updates vhost_scsi_get_tag() to accept the combined
      expected data transfer length + T10 PI bytes as the value passed
      into target_submit_cmd().
      
      This is required now that target-core logic in commit 14ef9200
      expects to subtract se_cmd->prot_length from se_cmd->data_length.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      9f977ef7
  13. 09 6月, 2014 2 次提交
    • M
      vhost: move memory pointer to VQs · 47283bef
      Michael S. Tsirkin 提交于
      commit 2ae76693b8bcabf370b981cd00c36cd41d33fabc
          vhost: replace rcu with mutex
      replaced rcu sync for memory accesses with VQ mutex locl/unlock.
      This is correct since all accesses are under VQ mutex, but incomplete:
      we still do useless rcu lock/unlock operations, someone might copy this
      code into some other context where this won't be right.
      This use of RCU is also non standard and hard to understand.
      Let's copy the pointer to each VQ structure, this way
      the access rules become straight-forward, and there's
      no need for RCU anymore.
      Reported-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      47283bef
    • M
      vhost: move acked_features to VQs · ea16c514
      Michael S. Tsirkin 提交于
      Refactor code to make sure features are only accessed
      under VQ mutex. This makes everything simpler, no need
      for RCU here anymore.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      ea16c514
  14. 03 6月, 2014 4 次提交
    • N
      vhost/scsi: Enable T10 PI IOV -> SGL memory mapping · 95e7c434
      Nicholas Bellinger 提交于
      This patch updates vhost_scsi_handle_vq() to check for the existance
      of virtio_scsi_cmd_req_pi comparing vq->iov[0].iov_len in order to
      calculate seperate data + protection SGLs from data_num.
      
      Also update tcm_vhost_submission_work() to pass the pre-allocated
      cmd->tvc_prot_sgl[] memory into target_submit_cmd_map_sgls(), and
      update vhost_scsi_get_tag() parameters to accept scsi_tag, lun, and
      task_attr.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@dev.mellanox.co.il>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      95e7c434
    • N
      vhost/scsi: Add T10 PI IOV -> SGL memory mapping logic · e31885dd
      Nicholas Bellinger 提交于
      This patch adds vhost_scsi_map_iov_to_prot() to perform the mapping of
      T10 data integrity memory between virtio iov + struct scatterlist using
      get_user_pages_fast() following existing code.
      
      As with vhost_scsi_map_iov_to_sgl(), this does sanity checks against the
      total prot_sgl_count vs. pre-allocated SGLs, and loops across protection
      iovs using vhost_scsi_map_to_sgl() to perform the actual memory mapping.
      
      Also update tcm_vhost_release_cmd() to release associated tvc_prot_sgl[]
      struct page.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Sagi Grimberg <sagig@dev.mellanox.co.il>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e31885dd
    • N
      vhost/scsi: Add preallocation of protection SGLs · b1935f68
      Nicholas Bellinger 提交于
      This patch updates tcm_vhost_make_nexus() to pre-allocate per descriptor
      tcm_vhost_cmd->tvc_prot_sgl[] used to expose protection SGLs from within
      virtio-scsi guest memory to vhost-scsi.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      b1935f68
    • N
      vhost/scsi: Move sanity check into vhost_scsi_map_iov_to_sgl · 5a01d082
      Nicholas Bellinger 提交于
      Move the overflow check for sgl_count > TCM_VHOST_PREALLOC_SGLS into
      vhost_scsi_map_iov_to_sgl() so that it's based on the total number
      of SGLs for all IOVs, instead of single IOVs.
      
      Also, rename TCM_VHOST_PREALLOC_PAGES -> TCM_VHOST_PREALLOC_UPAGES
      to better describe pointers to user-space pages.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      5a01d082
  15. 18 4月, 2014 1 次提交
  16. 07 4月, 2014 2 次提交
    • N
      target: Pass in transport supported PI at session initialization · e70beee7
      Nicholas Bellinger 提交于
      In order to support local WRITE_INSERT + READ_STRIP operations for
      non PI enabled fabrics, the fabric driver needs to be able signal
      what protection offload operations are supported.
      
      This is done at session initialization time so the modes can be
      signaled by individual se_wwn + se_portal_group endpoints, as well
      as optionally across different transports on the same endpoint.
      
      For iser-target, set TARGET_PROT_ALL if the underlying ib_device
      has already signaled PI offload support, and allow this to be
      exposed via a new iscsit_transport->iscsit_get_sup_prot_ops()
      callback.
      
      For loopback, set TARGET_PROT_ALL to signal SCSI initiator mode
      operation.
      
      For all other drivers, set TARGET_PROT_NORMAL to disable fabric
      level PI.
      
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Cc: Quinn Tran <quinn.tran@qlogic.com>
      Cc: Giridhar Malavali <giridhar.malavali@qlogic.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e70beee7
    • N
      target: Add TFO->abort_task for aborted task resources release · 131e6abc
      Nicholas Bellinger 提交于
      Now that TASK_ABORTED status is not generated for all cases by
      TMR ABORT_TASK + LUN_RESET, a new TFO->abort_task() caller is
      necessary in order to give fabric drivers a chance to unmap
      hardware / software resources before the se_cmd descriptor is
      released via the normal TFO->release_cmd() codepath.
      
      This patch adds TFO->aborted_task() in core_tmr_abort_task()
      in place of the original transport_send_task_abort(), and
      also updates all fabric drivers to implement this caller.
      
      The fabric drivers that include changes to perform cleanup
      via ->aborted_task() are:
      
        - iscsi-target
        - iser-target
        - srpt
        - tcm_qla2xxx
      
      The fabric drivers that currently set ->aborted_task() to
      NOPs are:
      
        - loopback
        - tcm_fc
        - usb-gadget
        - sbp-target
        - vhost-scsi
      
      For the latter five, there appears to be no additional cleanup
      required before invoking TFO->release_cmd() to release the
      se_cmd descriptor.
      
      v2 changes:
        - Move ->aborted_task() call into transport_cmd_finish_abort (Alex)
      
      Cc: Alex Leung <amleung21@yahoo.com>
      Cc: Mark Rustad <mark.d.rustad@intel.com>
      Cc: Roland Dreier <roland@kernel.org>
      Cc: Vu Pham <vu@mellanox.com>
      Cc: Chris Boot <bootc@bootc.net>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Giridhar Malavali <giridhar.malavali@qlogic.com>
      Cc: Saurav Kashyap <saurav.kashyap@qlogic.com>
      Cc: Quinn Tran <quinn.tran@qlogic.com>
      Cc: Sagi Grimberg <sagig@mellanox.com>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      131e6abc
  17. 25 2月, 2014 1 次提交
  18. 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
  19. 18 1月, 2014 1 次提交
    • 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
  20. 07 12月, 2013 1 次提交
  21. 26 10月, 2013 1 次提交
    • N
      vhost/scsi: Fix incorrect usage of get_user_pages_fast write parameter · 60a01f55
      Nicholas Bellinger 提交于
      This patch addresses a long-standing bug where the get_user_pages_fast()
      write parameter used for setting the underlying page table entry permission
      bits was incorrectly set to write=1 for data_direction=DMA_TO_DEVICE, and
      passed into get_user_pages_fast() via vhost_scsi_map_iov_to_sgl().
      
      However, this parameter is intended to signal WRITEs to pinned userspace
      PTEs for the virtio-scsi DMA_FROM_DEVICE -> READ payload case, and *not*
      for the virtio-scsi DMA_TO_DEVICE -> WRITE payload case.
      
      This bug would manifest itself as random process segmentation faults on
      KVM host after repeated vhost starts + stops and/or with lots of vhost
      endpoints + LUNs.
      
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Asias He <asias@redhat.com>
      Cc: <stable@vger.kernel.org> # 3.6+
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      60a01f55
  22. 17 10月, 2013 1 次提交
  23. 02 10月, 2013 1 次提交
  24. 18 9月, 2013 1 次提交