unstriped.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ================================
  2. Device-mapper "unstriped" target
  3. ================================
  4. Introduction
  5. ============
  6. The device-mapper "unstriped" target provides a transparent mechanism to
  7. unstripe a device-mapper "striped" target to access the underlying disks
  8. without having to touch the true backing block-device. It can also be
  9. used to unstripe a hardware RAID-0 to access backing disks.
  10. Parameters:
  11. <number of stripes> <chunk size> <stripe #> <dev_path> <offset>
  12. <number of stripes>
  13. The number of stripes in the RAID 0.
  14. <chunk size>
  15. The amount of 512B sectors in the chunk striping.
  16. <dev_path>
  17. The block device you wish to unstripe.
  18. <stripe #>
  19. The stripe number within the device that corresponds to physical
  20. drive you wish to unstripe. This must be 0 indexed.
  21. Why use this module?
  22. ====================
  23. An example of undoing an existing dm-stripe
  24. -------------------------------------------
  25. This small bash script will setup 4 loop devices and use the existing
  26. striped target to combine the 4 devices into one. It then will use
  27. the unstriped target ontop of the striped device to access the
  28. individual backing loop devices. We write data to the newly exposed
  29. unstriped devices and verify the data written matches the correct
  30. underlying device on the striped array::
  31. #!/bin/bash
  32. MEMBER_SIZE=$((128 * 1024 * 1024))
  33. NUM=4
  34. SEQ_END=$((${NUM}-1))
  35. CHUNK=256
  36. BS=4096
  37. RAID_SIZE=$((${MEMBER_SIZE}*${NUM}/512))
  38. DM_PARMS="0 ${RAID_SIZE} striped ${NUM} ${CHUNK}"
  39. COUNT=$((${MEMBER_SIZE} / ${BS}))
  40. for i in $(seq 0 ${SEQ_END}); do
  41. dd if=/dev/zero of=member-${i} bs=${MEMBER_SIZE} count=1 oflag=direct
  42. losetup /dev/loop${i} member-${i}
  43. DM_PARMS+=" /dev/loop${i} 0"
  44. done
  45. echo $DM_PARMS | dmsetup create raid0
  46. for i in $(seq 0 ${SEQ_END}); do
  47. echo "0 1 unstriped ${NUM} ${CHUNK} ${i} /dev/mapper/raid0 0" | dmsetup create set-${i}
  48. done;
  49. for i in $(seq 0 ${SEQ_END}); do
  50. dd if=/dev/urandom of=/dev/mapper/set-${i} bs=${BS} count=${COUNT} oflag=direct
  51. diff /dev/mapper/set-${i} member-${i}
  52. done;
  53. for i in $(seq 0 ${SEQ_END}); do
  54. dmsetup remove set-${i}
  55. done
  56. dmsetup remove raid0
  57. for i in $(seq 0 ${SEQ_END}); do
  58. losetup -d /dev/loop${i}
  59. rm -f member-${i}
  60. done
  61. Another example
  62. ---------------
  63. Intel NVMe drives contain two cores on the physical device.
  64. Each core of the drive has segregated access to its LBA range.
  65. The current LBA model has a RAID 0 128k chunk on each core, resulting
  66. in a 256k stripe across the two cores::
  67. Core 0: Core 1:
  68. __________ __________
  69. | LBA 512| | LBA 768|
  70. | LBA 0 | | LBA 256|
  71. ---------- ----------
  72. The purpose of this unstriping is to provide better QoS in noisy
  73. neighbor environments. When two partitions are created on the
  74. aggregate drive without this unstriping, reads on one partition
  75. can affect writes on another partition. This is because the partitions
  76. are striped across the two cores. When we unstripe this hardware RAID 0
  77. and make partitions on each new exposed device the two partitions are now
  78. physically separated.
  79. With the dm-unstriped target we're able to segregate an fio script that
  80. has read and write jobs that are independent of each other. Compared to
  81. when we run the test on a combined drive with partitions, we were able
  82. to get a 92% reduction in read latency using this device mapper target.
  83. Example dmsetup usage
  84. =====================
  85. unstriped ontop of Intel NVMe device that has 2 cores
  86. -----------------------------------------------------
  87. ::
  88. dmsetup create nvmset0 --table '0 512 unstriped 2 256 0 /dev/nvme0n1 0'
  89. dmsetup create nvmset1 --table '0 512 unstriped 2 256 1 /dev/nvme0n1 0'
  90. There will now be two devices that expose Intel NVMe core 0 and 1
  91. respectively::
  92. /dev/mapper/nvmset0
  93. /dev/mapper/nvmset1
  94. unstriped ontop of striped with 4 drives using 128K chunk size
  95. --------------------------------------------------------------
  96. ::
  97. dmsetup create raid_disk0 --table '0 512 unstriped 4 256 0 /dev/mapper/striped 0'
  98. dmsetup create raid_disk1 --table '0 512 unstriped 4 256 1 /dev/mapper/striped 0'
  99. dmsetup create raid_disk2 --table '0 512 unstriped 4 256 2 /dev/mapper/striped 0'
  100. dmsetup create raid_disk3 --table '0 512 unstriped 4 256 3 /dev/mapper/striped 0'