switch.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. =========
  2. dm-switch
  3. =========
  4. The device-mapper switch target creates a device that supports an
  5. arbitrary mapping of fixed-size regions of I/O across a fixed set of
  6. paths. The path used for any specific region can be switched
  7. dynamically by sending the target a message.
  8. It maps I/O to underlying block devices efficiently when there is a large
  9. number of fixed-sized address regions but there is no simple pattern
  10. that would allow for a compact representation of the mapping such as
  11. dm-stripe.
  12. Background
  13. ----------
  14. Dell EqualLogic and some other iSCSI storage arrays use a distributed
  15. frameless architecture. In this architecture, the storage group
  16. consists of a number of distinct storage arrays ("members") each having
  17. independent controllers, disk storage and network adapters. When a LUN
  18. is created it is spread across multiple members. The details of the
  19. spreading are hidden from initiators connected to this storage system.
  20. The storage group exposes a single target discovery portal, no matter
  21. how many members are being used. When iSCSI sessions are created, each
  22. session is connected to an eth port on a single member. Data to a LUN
  23. can be sent on any iSCSI session, and if the blocks being accessed are
  24. stored on another member the I/O will be forwarded as required. This
  25. forwarding is invisible to the initiator. The storage layout is also
  26. dynamic, and the blocks stored on disk may be moved from member to
  27. member as needed to balance the load.
  28. This architecture simplifies the management and configuration of both
  29. the storage group and initiators. In a multipathing configuration, it
  30. is possible to set up multiple iSCSI sessions to use multiple network
  31. interfaces on both the host and target to take advantage of the
  32. increased network bandwidth. An initiator could use a simple round
  33. robin algorithm to send I/O across all paths and let the storage array
  34. members forward it as necessary, but there is a performance advantage to
  35. sending data directly to the correct member.
  36. A device-mapper table already lets you map different regions of a
  37. device onto different targets. However in this architecture the LUN is
  38. spread with an address region size on the order of 10s of MBs, which
  39. means the resulting table could have more than a million entries and
  40. consume far too much memory.
  41. Using this device-mapper switch target we can now build a two-layer
  42. device hierarchy:
  43. Upper Tier - Determine which array member the I/O should be sent to.
  44. Lower Tier - Load balance amongst paths to a particular member.
  45. The lower tier consists of a single dm multipath device for each member.
  46. Each of these multipath devices contains the set of paths directly to
  47. the array member in one priority group, and leverages existing path
  48. selectors to load balance amongst these paths. We also build a
  49. non-preferred priority group containing paths to other array members for
  50. failover reasons.
  51. The upper tier consists of a single dm-switch device. This device uses
  52. a bitmap to look up the location of the I/O and choose the appropriate
  53. lower tier device to route the I/O. By using a bitmap we are able to
  54. use 4 bits for each address range in a 16 member group (which is very
  55. large for us). This is a much denser representation than the dm table
  56. b-tree can achieve.
  57. Construction Parameters
  58. =======================
  59. <num_paths> <region_size> <num_optional_args> [<optional_args>...] [<dev_path> <offset>]+
  60. <num_paths>
  61. The number of paths across which to distribute the I/O.
  62. <region_size>
  63. The number of 512-byte sectors in a region. Each region can be redirected
  64. to any of the available paths.
  65. <num_optional_args>
  66. The number of optional arguments. Currently, no optional arguments
  67. are supported and so this must be zero.
  68. <dev_path>
  69. The block device that represents a specific path to the device.
  70. <offset>
  71. The offset of the start of data on the specific <dev_path> (in units
  72. of 512-byte sectors). This number is added to the sector number when
  73. forwarding the request to the specific path. Typically it is zero.
  74. Messages
  75. ========
  76. set_region_mappings <index>:<path_nr> [<index>]:<path_nr> [<index>]:<path_nr>...
  77. Modify the region table by specifying which regions are redirected to
  78. which paths.
  79. <index>
  80. The region number (region size was specified in constructor parameters).
  81. If index is omitted, the next region (previous index + 1) is used.
  82. Expressed in hexadecimal (WITHOUT any prefix like 0x).
  83. <path_nr>
  84. The path number in the range 0 ... (<num_paths> - 1).
  85. Expressed in hexadecimal (WITHOUT any prefix like 0x).
  86. R<n>,<m>
  87. This parameter allows repetitive patterns to be loaded quickly. <n> and <m>
  88. are hexadecimal numbers. The last <n> mappings are repeated in the next <m>
  89. slots.
  90. Status
  91. ======
  92. No status line is reported.
  93. Example
  94. =======
  95. Assume that you have volumes vg1/switch0 vg1/switch1 vg1/switch2 with
  96. the same size.
  97. Create a switch device with 64kB region size::
  98. dmsetup create switch --table "0 `blockdev --getsz /dev/vg1/switch0`
  99. switch 3 128 0 /dev/vg1/switch0 0 /dev/vg1/switch1 0 /dev/vg1/switch2 0"
  100. Set mappings for the first 7 entries to point to devices switch0, switch1,
  101. switch2, switch0, switch1, switch2, switch1::
  102. dmsetup message switch 0 set_region_mappings 0:0 :1 :2 :0 :1 :2 :1
  103. Set repetitive mapping. This command::
  104. dmsetup message switch 0 set_region_mappings 1000:1 :2 R2,10
  105. is equivalent to::
  106. dmsetup message switch 0 set_region_mappings 1000:1 :2 :1 :2 :1 :2 :1 :2 \
  107. :1 :2 :1 :2 :1 :2 :1 :2 :1 :2