← Documents Documentation/admin-guide/device-mapper/switch.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Device Mapper

dm-switch

수많은 고정 크기 region의 임의 path mapping을 bitmap으로 압축하고 message로 동적 변경하는 two-tier storage routing target입니다.

Source pathDocumentation/admin-guide/device-mapper/switch.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

임의 region routing

switch.rst:1-40

Distributed iSCSI array에서 실제 block owner로 직접 I/O를 보내 forwarding을 줄입니다.

두 계층과 bitmap

switch.rst:41-90

Upper dm-switch가 member를 선택하고 lower multipath가 direct·failover path를 관리합니다.

Message와 예제

switch.rst:91-141

Hex region/path token, 반복 pattern과 세 volume을 사용한 64 KiB region table을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

고정 region을 path에 동적으로 mapping

1-14

Device Mapper의 `switch` target은 고정 크기 I/O region을 고정된 path 집합에 임의로 mapping하는 device를 만듭니다. 특정 region이 사용할 path는 target에 message를 보내 동적으로 바꿀 수 있습니다.

고정 크기 address region 수가 매우 많고 `dm-stripe`처럼 mapping을 간결하게 표현할 단순 pattern이 없을 때 underlying block device로 I/O를 효율적으로 mapping합니다.

Dynamic region switching
I/O sector고정 크기 region index 계산Region table lookupPath 0..N-1
`set_region_mappings`Region table update이후 I/O의 path 변경

Region table lookup으로 path를 선택하고 control message로 개별 mapping을 갱신합니다.

dm-switch 적용 조건
특성`dm-switch`
Region 크기고정
Region 수매우 많을 수 있음
Mapping pattern임의
Runtime 변경Message로 지원

정규 stripe pattern 대신 큰 임의 mapping table이 필요한 경우에 적합합니다.

Distributed frameless iSCSI storage

15-40

Dell EqualLogic과 일부 iSCSI storage array는 distributed frameless architecture를 사용합니다. Storage group은 서로 독립적인 controller, disk storage와 network adapter를 가진 여러 storage array, 즉 'member'로 구성됩니다.

LUN을 만들면 여러 member에 분산하지만 initiator에는 세부 배치를 숨깁니다. 사용 중인 member 수와 관계없이 storage group은 하나의 target discovery portal을 노출합니다. 각 iSCSI session은 한 member의 ethernet port에 연결됩니다.

LUN data는 어느 iSCSI session으로 보내도 됩니다. 접근 block이 다른 member에 있으면 필요한 곳으로 I/O를 forwarding하며 initiator에는 보이지 않습니다. Storage layout도 동적이므로 부하를 균형 있게 맞추기 위해 disk block을 member 사이에서 이동할 수 있습니다.

Distributed member forwarding
InitiatoriSCSI session AMember ABlock이 Member B에 있음내부 forwardingMember B disk
Dynamic layoutLoad balance 필요Block을 member 간 이동

Initiator는 어느 session으로든 I/O를 보낼 수 있고 array group이 실제 block owner로 전달합니다.

이 구조는 storage group과 initiator의 관리·구성을 단순화합니다. Multipathing에서는 host와 target의 여러 network interface를 쓰는 여러 iSCSI session을 구성해 network bandwidth를 늘릴 수 있습니다.

Initiator가 모든 path에 단순 round-robin으로 I/O를 보내고 array member가 필요한 forwarding을 수행하게 할 수도 있지만, data가 실제로 있는 올바른 member로 직접 보내면 성능상 이점이 있습니다.

I/O path 선택 비교
방식Array 동작성능 특성
모든 path round-robin잘못된 member가 실제 owner로 forwarding추가 hop 가능
올바른 member에 direct해당 member가 바로 처리Forwarding 회피

두 방식 모두 동작하지만 member 내부 forwarding을 피하는 직접 경로가 더 효율적입니다.

Bitmap upper tier와 member별 multipath lower tier

41-67

Device Mapper table은 device의 서로 다른 region을 서로 다른 target에 mapping할 수 있습니다. 하지만 이 architecture에서 LUN은 수십 MB 정도의 address region으로 분산되므로 table entry가 백만 개를 넘고 지나치게 많은 memory를 소비할 수 있습니다.

`dm-switch`를 사용하면 두 계층 device hierarchy를 만들 수 있습니다. Upper tier는 I/O를 보낼 array member를 결정하고, lower tier는 특정 member로 가는 path 사이에서 load balance합니다.

두 계층 I/O routing
Host I/OUpper: `dm-switch` bitmapArray member 선택Lower: member별 `dm-multipath`Direct path 선택Member disk

Region ownership 선택과 network path load balancing을 서로 다른 Device Mapper 계층이 담당합니다.

Lower tier에는 member마다 `dm-multipath` device 하나가 있습니다. 각 device는 해당 array member로 직접 가는 path 집합을 하나의 preferred priority group에 넣고 기존 path selector로 load balance합니다. Failover를 위해 다른 member로 가는 path를 담은 non-preferred priority group도 구성합니다.

Upper tier는 `dm-switch` device 하나입니다. Bitmap으로 I/O 위치를 lookup해 적절한 lower-tier device를 선택합니다. 16-member group이면 address range마다 4-bit만 사용하므로 dm table B-tree보다 훨씬 조밀하게 표현할 수 있습니다.

Bitmap 밀도
Member 수Region당 bit의미
164-bit0~15 member 번호 표현
백만 region약 500 KiB bitmap4,000,000 bit 기준
Lower-tier failoverPreferred group은 해당 member의 direct path, non-preferred group은 다른 member를 통한 failover path입니다.

Path 수를 표현하는 데 필요한 bit 수만 region마다 사용합니다.

Path 수, region 크기와 device offset

68-90

Constructor 형식은 다음과 같습니다.

    <num_paths> <region_size> <num_optional_args> [<optional_args>...] [<dev_path> <offset>]+
dm-switch constructor
Parameter의미단위·제약
`<num_paths>`I/O를 분산할 path 수고정 path 집합
`<region_size>`각 region 크기512-byte sector 수
`<num_optional_args>`Optional argument 수현재는 반드시 0
`<dev_path>`특정 path를 나타내는 block devicePath마다 한 개
`<offset>`해당 path의 data 시작 위치512-byte sector, 보통 0

Region geometry를 정의하고 사용할 각 block-device path를 나열합니다.

각 region은 사용 가능한 어느 path로든 redirect할 수 있습니다. 현재 지원하는 optional argument가 없으므로 `<num_optional_args>`는 0이어야 합니다.

Request를 특정 path로 전달할 때 logical sector number에 `<offset>`을 더합니다. Offset은 보통 0입니다.

Path offset 적용
Logical request sectorRegion으로 path 선택+ path `<offset>`Underlying `<dev_path>` sector

Region table이 선택한 path의 고유 시작 offset을 logical sector에 더합니다.

Region mapping과 반복 pattern message

91-112

`set_region_mappings` message로 region table을 수정해 각 region을 어느 path로 redirect할지 지정합니다.

set_region_mappings <index>:<path_nr> [<index>]:<path_nr> [<index>]:<path_nr>...

`<index>`는 constructor의 region size로 정한 region 번호입니다. Index를 생략하면 이전 index에 1을 더한 다음 region을 사용합니다. 값은 `0x` 같은 prefix 없이 hexadecimal로 씁니다.

`<path_nr>`는 0부터 `<num_paths> - 1`까지의 path 번호이며 이것도 prefix 없는 hexadecimal입니다.

R<n>,<m>

`R<n>,<m>`은 반복 pattern을 빠르게 load합니다. `<n>`과 `<m>`은 hexadecimal이며, 마지막 `<n>`개 mapping을 이어지는 `<m>`개 slot에 반복합니다.

Mapping token
Token의미
`<index>:<path_nr>`지정 region을 지정 path로 mapping
`:<path_nr>`이전 index + 1 region을 지정 path로 mapping
`R<n>,<m>`마지막 n개 mapping을 다음 m slot에 반복

명시적 index, 연속 index 생략과 반복 압축을 함께 사용할 수 있습니다.

Mapping message 적용
`set_region_mappings`명시적 index 설정생략 index 자동 증가반복 token 확장Region bitmap 갱신

Hex token을 순서대로 해석해 bitmap region entry를 갱신합니다.

Status line 없음

113-117

`dm-switch` target은 status line을 보고하지 않습니다.

Status interface
항목지원 여부
Status line보고하지 않음

Runtime region mapping은 status 출력이 아니라 message로 관리합니다.

세 path와 첫 일곱 region mapping

118-133

같은 크기의 `vg1/switch0`, `vg1/switch1`, `vg1/switch2` volume이 있다고 가정합니다. 다음 table은 64 KiB region 크기의 switch device를 만듭니다. 512-byte sector 128개가 64 KiB입니다.

    dmsetup create switch --table "0 `blockdev --getsz /dev/vg1/switch0`
	switch 3 128 0 /dev/vg1/switch0 0 /dev/vg1/switch1 0 /dev/vg1/switch2 0"
예제 switch 구성
`switch` deviceRegion size 128 sectorsPath 0: switch0Path 1: switch1Path 2: switch2

세 같은 크기 volume을 path 0, 1, 2로 등록하고 region마다 선택합니다.

첫 7개 region을 차례로 `switch0`, `switch1`, `switch2`, `switch0`, `switch1`, `switch2`, `switch1`에 mapping합니다. 첫 token `0:0` 뒤에는 index를 생략하므로 region 번호가 자동 증가합니다.

    dmsetup message switch 0 set_region_mappings 0:0 :1 :2 :0 :1 :2 :1
Region 0-6 mapping
RegionPathDevice
00`switch0`
11`switch1`
22`switch2`
30`switch0`
41`switch1`
52`switch2`
61`switch1`

Message token과 선택 path를 펼쳐 표시합니다.

Hexadecimal R2,10 pattern 확장

134-141

다음 명령은 hexadecimal region `1000`에서 path 1, 다음 region에서 path 2를 설정한 뒤 마지막 두 mapping을 다음 hexadecimal `10`, 즉 16개 slot에 반복합니다.

    dmsetup message switch 0 set_region_mappings 1000:1 :2 R2,10

따라서 path 1과 2가 번갈아 나오는 16개 token을 직접 나열한 다음 명령과 같습니다.

    dmsetup message switch 0 set_region_mappings 1000:1 :2 :1 :2 :1 :2 :1 :2 \
	:1 :2 :1 :2 :1 :2 :1 :2 :1 :2
`R2,10` 확장
`1000:1``:2`마지막 n=2 patternm=0x10 slot`:1 :2` × 8

마지막 두 mapping `:1 :2`를 8회 반복해 다음 16개 region slot을 채웁니다.

Hexadecimal parameter
16진 의미10진 의미
`1000`Region index `0x1000`4096
`2`반복 pattern 길이 `0x2`2
`10`채울 slot 수 `0x10`16

Prefix 없이 쓰지만 모든 숫자는 16진수로 해석합니다.