1. 07 7月, 2017 13 次提交
  2. 24 5月, 2017 1 次提交
    • M
      tcmu: fix crash during device removal · f3cdbe39
      Mike Christie 提交于
      We currently do
      
      tcmu_free_device ->tcmu_netlink_event(TCMU_CMD_REMOVED_DEVICE) ->
      uio_unregister_device -> kfree(tcmu_dev).
      
      The problem is that the kernel does not wait for userspace to
      do the close() on the uio device before freeing the tcmu_dev.
      We can then hit a race where the kernel frees the tcmu_dev before
      userspace does close() and so when close() -> release -> tcmu_release
      is done, we try to access a freed tcmu_dev.
      
      This patch made over the target-pending master branch moves the freeing
      of the tcmu_dev to when the last reference has been dropped.
      
      This also fixes a leak where if tcmu_configure_device was not called on a
      device we did not free udev->name which was allocated at tcmu_alloc_device time.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      f3cdbe39
  3. 05 5月, 2017 1 次提交
  4. 03 5月, 2017 1 次提交
    • X
      tcmu: Recalculate the tcmu_cmd size to save cmd area memories · fe25cc34
      Xiubo Li 提交于
      For the "struct tcmu_cmd_entry" in cmd area, the minimum size
      will be sizeof(struct tcmu_cmd_entry) == 112 Bytes. And it could
      fill about (sizeof(struct rsp) - sizeof(struct req)) /
      sizeof(struct iovec) == 68 / 16 ~= 4 data regions(iov[4]) by
      default.
      
      For most tcmu_cmds, the data block indexes allocated from the
      data area will be continuous. And for the continuous blocks they
      will be merged into the same region using only one iovec. For
      the current code, it will always allocates the same number of
      iovecs with blocks for each tcmu_cmd, and it will wastes much
      memories.
      
      For example, when the block size is 4K and the DATA_OUT buffer
      size is 64K, and the regions needed is less than 5(on my
      environment is almost 99.7%). The current code will allocate
      about 16 iovecs, and there will be (16 - 4) * sizeof(struct
      iovec) = 192 Bytes cmd area memories wasted.
      
      Here adds two helpers to calculate the base size and full size
      of the tcmu_cmd. And will recalculate them again when it make sure
      how many iovs is needed before insert it to cmd area.
      Signed-off-by: NXiubo Li <lixiubo@cmss.chinamobile.com>
      Acked-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      fe25cc34
  5. 02 5月, 2017 2 次提交
    • X
      tcmu: Add global data block pool support · b6df4b79
      Xiubo Li 提交于
      For each target there will be one ring, when the target number
      grows larger and larger, it could eventually runs out of the
      system memories.
      
      In this patch for each target ring, currently for the cmd area
      the size will be fixed to 8MB and for the data area the size
      will grow from 0 to max 256K * PAGE_SIZE(1G for 4K page size).
      
      For all the targets' data areas, they will get empty blocks
      from the "global data block pool", which has limited to 512K *
      PAGE_SIZE(2G for 4K page size) for now.
      
      When the "global data block pool" has been used up, then any
      target could wake up the unmap thread routine to shrink other
      targets' data area memories. And the unmap thread routine will
      always try to truncate the ring vma from the last using block
      offset.
      
      When user space has touched the data blocks out of tcmu_cmd
      iov[], the tcmu_page_fault() will try to return one zeroed blocks.
      
      Here we move the timeout's tcmu_handle_completions() into unmap
      thread routine, that's to say when the timeout fired, it will
      only do the tcmu_check_expired_cmd() and then wake up the unmap
      thread to do the completions() and then try to shrink its idle
      memories. Then the cmdr_lock could be a mutex and could simplify
      this patch because the unmap_mapping_range() or zap_* may go to
      sleep.
      Signed-off-by: NXiubo Li <lixiubo@cmss.chinamobile.com>
      Signed-off-by: NJianfei Hu <hujianfei@cmss.chinamobile.com>
      Acked-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      b6df4b79
    • X
      tcmu: Add dynamic growing data area feature support · 141685a3
      Xiubo Li 提交于
      Currently for the TCMU, the ring buffer size is fixed to 64K cmd
      area + 1M data area, and this will be bottlenecks for high iops.
      
      The struct tcmu_cmd_entry {} size is fixed about 112 bytes with
      iovec[N] & N <= 4, and the size of struct iovec is about 16 bytes.
      
      If N == 0, the ratio will be sizeof(cmd entry) : sizeof(datas) ==
      112Bytes : (N * 4096)Bytes = 28 : 0, no data area is need.
      
      If 0 < N <=4, the ratio will be sizeof(cmd entry) : sizeof(datas)
      == 112Bytes : (N * 4096)Bytes = 28 : (N * 1024), so the max will
      be 28 : 1024.
      
      If N > 4, the sizeof(cmd entry) will be [(N - 4) *16 + 112] bytes,
      and its corresponding data size will be [N * 4096], so the ratio
      of sizeof(cmd entry) : sizeof(datas) == [(N - 4) * 16 + 112)Bytes
      : (N * 4096)Bytes == 4/1024 - 12/(N * 1024), so the max is about
      4 : 1024.
      
      When N is bigger, the ratio will be smaller.
      
      As the initial patch, we will set the cmd area size to 2M, and
      the cmd area size to 32M. The TCMU will dynamically grows the data
      area from 0 to max 32M size as needed.
      
      The cmd area memory will be allocated through vmalloc(), and the
      data area's blocks will be allocated individually later when needed.
      
      The allocated data area block memory will be managed via radix tree.
      For now the bitmap still be the most efficient way to search and
      manage the block index, this could be update later.
      Signed-off-by: NXiubo Li <lixiubo@cmss.chinamobile.com>
      Signed-off-by: NJianfei Hu <hujianfei@cmss.chinamobile.com>
      Acked-by: NMike Christie <mchristi@redhat.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      141685a3
  6. 03 4月, 2017 1 次提交
  7. 30 3月, 2017 3 次提交
  8. 19 3月, 2017 5 次提交
  9. 25 2月, 2017 1 次提交
  10. 14 2月, 2017 1 次提交
  11. 15 12月, 2016 1 次提交
  12. 10 12月, 2016 2 次提交
    • B
      target/user: Add an #include directive · f5045724
      Bart Van Assche 提交于
      Since this driver uses kmap_atomic(), include the highmem header file.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: Andy Grover <agrover@redhat.com>
      f5045724
    • B
      target/user: Fix a data type in tcmu_queue_cmd() · ecaf597b
      Bart Van Assche 提交于
      This patch avoids that sparse reports the following error messages:
      
      drivers/target/target_core_user.c:547:13: warning: incorrect type in assignment (different base types)
      drivers/target/target_core_user.c:547:13:    expected int [signed] ret
      drivers/target/target_core_user.c:547:13:    got restricted sense_reason_t
      drivers/target/target_core_user.c:548:20: warning: restricted sense_reason_t degrades to integer
      drivers/target/target_core_user.c:557:16: warning: incorrect type in return expression (different base types)
      drivers/target/target_core_user.c:557:16:    expected restricted sense_reason_t
      drivers/target/target_core_user.c:557:16:    got int [signed] ret
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      ecaf597b
  13. 28 10月, 2016 3 次提交
    • J
      genetlink: mark families as __ro_after_init · 56989f6d
      Johannes Berg 提交于
      Now genl_register_family() is the only thing (other than the
      users themselves, perhaps, but I didn't find any doing that)
      writing to the family struct.
      
      In all families that I found, genl_register_family() is only
      called from __init functions (some indirectly, in which case
      I've add __init annotations to clarifly things), so all can
      actually be marked __ro_after_init.
      
      This protects the data structure from accidental corruption.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      56989f6d
    • J
      genetlink: statically initialize families · 489111e5
      Johannes Berg 提交于
      Instead of providing macros/inline functions to initialize
      the families, make all users initialize them statically and
      get rid of the macros.
      
      This reduces the kernel code size by about 1.6k on x86-64
      (with allyesconfig).
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      489111e5
    • J
      genetlink: no longer support using static family IDs · a07ea4d9
      Johannes Berg 提交于
      Static family IDs have never really been used, the only
      use case was the workaround I introduced for those users
      that assumed their family ID was also their multicast
      group ID.
      
      Additionally, because static family IDs would never be
      reserved by the generic netlink code, using a relatively
      low ID would only work for built-in families that can be
      registered immediately after generic netlink is started,
      which is basically only the control family (apart from
      the workaround code, which I also had to add code for so
      it would reserve those IDs)
      
      Thus, anything other than GENL_ID_GENERATE is flawed and
      luckily not used except in the cases I mentioned. Move
      those workarounds into a few lines of code, and then get
      rid of GENL_ID_GENERATE entirely, making it more robust.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a07ea4d9
  14. 20 10月, 2016 3 次提交
  15. 11 3月, 2016 2 次提交