1. 22 Sep, 2020 3 commits
    • Bodo Stroesser's avatar
      scsi: target: tcmu: Optimize scatter_data_area() · 3c9a7c58
      Bodo Stroesser authored
      scatter_data_area() has two purposes:
      
       1) Create the iovs for the data area buffer of a SCSI cmd.
      
       2) If there is data in DMA_TO_DEVICE direction, copy
          the data from sg_list to data area buffer.
      
      Both are done in a common loop.
      
      In case of DMA_FROM_DEVICE data transfer, scatter_data_area() is called
      with parameter copy_data = false. But this flag is just used to skip
      memcpy() for data, while radix_tree_lookup still is called for every dbi of
      the area area buffer, and kmap and kunmap are called for every page from
      sg_list and data_area as well as flush_dcache_page() for the data area
      pages.  Since the only thing to do with copy_data = false would be to set
      up the iovs, this is a noticeable overhead.  Rework the iov creation in the
      main loop of scatter_data_area() providing the new function
      new_block_to_iov().  Based on this, create the short new function
      tcmu_setup_iovs() that only writes the iovs with no overhead.  This new
      function is now called instead of scatter_data_area() for bidi buffers and
      for data buffers in those cases where memcpy() would have been skipped.
      
      Link: https://lore.kernel.org/r/20200910155041.17654-4-bstroesser@ts.fujitsu.comAcked-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      3c9a7c58
    • Bodo Stroesser's avatar
      scsi: target: tcmu: Optimize queue_cmd_ring() · 7e98905e
      Bodo Stroesser authored
      queue_cmd_ring() needs to check whether there is enough space in cmd ring
      and data area for the cmd to queue.
      
      Currently the sequence is:
      
       1) Calculate size the cmd will occupy on the ring based on estimation of
          needed iovs.
      
       2) Check whether there is enough space on the ring based on size from 1)
      
       3) Allocate buffers in data area.
      
       4) Calculate number of iovs the command really needs while copying
          incoming data (if any) to data area.
      
       5) Re-calculate real size of cmd on ring based on real number of iovs.
      
       6) Set up possible padding and cmd on the ring.
      
      Step 1) must not underestimate the cmd size so use max possible number of
      iovs for the given I/O data size. The resulting overestimation can be
      really high so this sequence is not ideal. The earliest the real number of
      iovs can be calculated is after data buffer allocation. Therefore rework
      the code to implement the following sequence:
      
       A) Allocate buffers on data area and calculate number of necessary iovs
          during this.
      
       B) Calculate real size of cmd on ring based on number of iovs.
      
       C) Check whether there is enough space on the ring.
      
       D) Set up possible padding and cmd on the ring.
      
      The new sequence enforces the split of new function tcmu_alloc_data_space()
      from is_ring_space_avail(). Using this function, change queue_cmd_ring()
      according to the new sequence.
      
      Change routines called by tcmu_alloc_data_space() to allow calculating and
      returning the iov count. Remove counting of iovs in scatter_data_area().
      
      Link: https://lore.kernel.org/r/20200910155041.17654-3-bstroesser@ts.fujitsu.comAcked-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      7e98905e
    • Bodo Stroesser's avatar
      scsi: target: tcmu: Join tcmu_cmd_get_data_length() and tcmu_cmd_get_block_cnt() · 52ef2743
      Bodo Stroesser authored
      Simplify code by joining tcmu_cmd_get_data_length() and
      tcmu_cmd_get_block_cnt() into tcmu_cmd_set_block_cnts().  The new function
      sets tcmu_cmd->dbi_cnt and also the new field tcmu_cmd->dbi_bidi_cnt which
      is needed for further enhancements in following patches.  Simplify some
      code by using tcmu_cmd->dbi(_bidi)_cnt instead of calculation from length.
      
      Please note: The calculation of the number of dbis needed for bidi was
      wrong. It was based on the length of the first bidi sg only. I changed it
      to correctly sum up entire length of all bidi sgs.
      
      Link: https://lore.kernel.org/r/20200910155041.17654-2-bstroesser@ts.fujitsu.comAcked-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      52ef2743
  2. 16 Sep, 2020 15 commits
  3. 15 Sep, 2020 15 commits
  4. 10 Sep, 2020 7 commits