File: devmapper.h

package info (click to toggle)
evms 2.5.2-1.sarge2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 14,248 kB
  • ctags: 15,488
  • sloc: ansic: 201,340; perl: 12,421; sh: 4,262; makefile: 1,516; yacc: 316; sed: 16
file content (333 lines) | stat: -rw-r--r-- 9,742 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/*
 *   (C) Copyright IBM Corp. 2001, 2003
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program;  if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Module: devmapper.h
 */

#ifndef _DEVMAPPER_H_INCLUDED_
#define _DEVMAPPER_H_INCLUDED_ 1

/* If you add entries to this enum, be sure to update dm_target_type_info
 * in engine/dm.c.
 */
typedef enum {
	DM_TARGET_LINEAR = 0,
	DM_TARGET_STRIPE,
	DM_TARGET_MIRROR,
	DM_TARGET_SNAPSHOT,
	DM_TARGET_SNAPSHOT_ORG,
	DM_TARGET_MULTIPATH,
	DM_TARGET_CRYPT,
	DM_TARGET_BBR,
	DM_TARGET_SPARSE,
	DM_TARGET_ERROR,
	DM_TARGET_ZERO,
	DM_TARGET_RAID0,
	DM_TARGET_RAID1,
	DM_TARGET_RAID5
} dm_target_type;

/* This should be defined as the last entry in the above enum. */
#define DM_TARGET_MAX DM_TARGET_RAID5

typedef union {
	struct dm_device		*linear;
	struct dm_target_stripe		*stripe;
	struct dm_target_mirror		*mirror;
	struct dm_target_snapshot	*snapshot;
	struct dm_target_bbr		*bbr;
	struct dm_target_sparse		*sparse;
	struct dm_target_multipath	*multipath;
	struct dm_target_crypt		*crypt;
	struct dm_target_raid		*raid;
} dm_type_data;

/**
 * struct dm_target
 *
 * @start:	Starting offset within the DM device of this target.
 * @length:	Length of this target.
 * @type:	Type of target: DM_TARGET_*
 * @data:	Union of pointers to type-based private data.
 * @params:	String representation of type and data. The engine will
 *		fill in this field during a create call. The plug-ins should
 *		*not* access this field.
 * @next:	Pointer to create a list of targets for a device.
 *
 * Structure to describe one target within a Device Mapper device.
 **/
typedef struct dm_target {
	u_int64_t		start;
	u_int64_t		length;
	dm_target_type		type;
	dm_type_data		data;
	unsigned char		*params;
	struct dm_target	*next;
} dm_target_t;

/**
 * struct dm_device
 *
 * @major:	Major number of the device.
 * @minor:	Minor number of the device.
 * @start:	Starting sector offset within the device.
 *
 * Structure to describe a simple device. This structure is used directly
 * to describe a linear target, and is also used as a field in the other
 * targets' private data structures.
 **/
typedef struct dm_device {
	int32_t		major;
	int32_t		minor;
	u_int64_t	start;
} dm_device_t;

/**
 * struct dm_target_stripe
 *
 * @num_stripes:	Number of devices that make up the striped target.
 * @chunk_size:		Granularity of the data striping (in sectors).
 *			Must be power-of-2.
 * @devices:		Array of device structures. num_stripes specifies
 *			the number of elements in this array.
 *
 * Private structure to describe a striped target.
 **/
typedef struct dm_target_stripe {
	u_int32_t		num_stripes;
	u_int32_t		chunk_size;
	struct dm_device	*devices;
} dm_target_stripe_t;

/**
 * struct dm_target_mirror
 *
 * @num_mirrors:	Number of devices that make up the mirror target.
 * @chunk_size:		Granularity of data being copied.
 * @persistent:		TRUE if mirror should survive a reboot.
 * @devices:		Array of device structures. num_mirrors specifies the
 *			number of elements in this array.
 *
 * Private structure to describe a mirror target.
 **/
typedef struct dm_target_mirror {
	u_int32_t		num_mirrors;
	u_int32_t		chunk_size;
	u_int32_t		persistent;
	struct dm_device	*devices;
} dm_target_mirror_t;

/**
 * struct dm_target_snapshot
 *
 * @origin:		Location of origin device (start is ignored).
 * @origin_parent:	Location of origin-parent device (start is ignored).
 * @snapshot:		Location of snapshot device (start is ignored).
 * @persistent:		!=0 for persistent snapshot. ==0 for non-persistent.
 * @chunk_size:		Granularity of copy-on-writes (in sectors, must be
 *			multiple of PAGE_SIZE).
 *
 * Private structure to describe a snapshot target.
 **/
typedef struct dm_target_snapshot {
	struct dm_device	origin;
	struct dm_device	origin_parent;
	struct dm_device	snapshot;
	u_int32_t		persistent;
	u_int32_t		chunk_size;
} dm_target_snapshot_t;

/**
 * struct dm_target_bbr
 *
 * @device:			Location of the underlying device. (start is ignored)
 * @table1_lba:			LBA of first BBR table copy.
 * @table2_lba:			LBA of second BBR table copy.
 * @replacement_blocks_lba:	LBA of start of replacement blocks.
 * @table_size:			Size of each BBR table (in sectors).
 * @num_replacement_blocks:	Total number of replacement blocks.
 * @block_size:			Size of each replacement block.
 *
 * Private structure to describe a BBR target.
 **/
typedef struct dm_target_bbr {
	struct dm_device	device;
	u_int64_t		table1_lba;
	u_int64_t		table2_lba;
	u_int64_t		replacement_blocks_lba;
	u_int64_t		table_size;
	u_int64_t		num_replacement_blocks;
	u_int32_t		block_size;
} dm_target_bbr_t;

/**
 * struct dm_target_sparse
 *
 * @device:	Location of the underlying device.
 * @num_chunks:	Number of chunks in the device.
 * @chunk_size:	Size of each chunk (in sectors). Must be power-of-2.
 *
 * Private structure to describe a sparse target.
 **/
typedef struct dm_target_sparse {
	struct dm_device	device;
	u_int32_t		num_chunks;
	u_int32_t		chunk_size;
} dm_target_sparse_t;

/* 
 * Allowed string length for DM Path Selector Type Parms that
 * are used in the constructor string when activating a multipath
 * device.
 **/
#define DM_PATH_ARGS_SIZE	128
#define DM_SELECTOR_NAME_SIZE	32

/**
 * struct dm_path
 *
 * @device:		Location of one path (start is ignored).
 * @has_failed:		0==path is active,  1==path is failed
 * @fail_count:		Number of I/O errors remaining before the path fails.
 * @path_args:		NULL -or- constructor string to be passed to the PST
 *                      for this path.
 *
 * Private structure to describe a single path to a multipath device
 **/
typedef struct dm_path {
	struct dm_device	device;
	u_int32_t		has_failed;
	u_int32_t		fail_count;
	char			path_args[DM_PATH_ARGS_SIZE];
} dm_path_t;

/**
 * struct dm_priority_group
 *
 * @selector:		Path Selector Type, e.g. "round-robin"
 * @num_paths:		Number of paths to the device managed by this group
 * @num_path_args:	Number of per-path arguments to pass to the path-selector.
 * @path:		Array of path descriptors. num_paths specifies the
 *			number of elements in this array.
 *
 * Private structure to describe a priority group within a multipath device.
 **/
typedef struct dm_priority_group {
	char		selector[DM_SELECTOR_NAME_SIZE];
	u_int32_t	num_paths;
	u_int32_t	num_path_args;
 	struct dm_path	*path;
} dm_priority_group_t;

/**
 * struct dm_target_multipath
 *
 * @num_groups:		Number of priority groups.
 * @group:		Array of priority groups, num_groups specifies the
 *			number of elements in this array.
 *
 * Private structure to describe a multipath target
 **/
typedef struct dm_target_multipath {
	u_int32_t			num_groups;
	struct dm_priority_group	*group;
} dm_target_multipath_t;

/**
 * struct dm_target_crypt
 *
 * @device:		Location of the underlying device.
 * @iv_offset:
 * @cypher:
 * @key:
 *
 * Private structure to describe a crypto target.
 **/
typedef struct dm_target_crypt {
	struct dm_device	device;
	u_int64_t		iv_offset;
	char			cypher[EVMS_NAME_SIZE];
	char			key[EVMS_NAME_SIZE];
} dm_target_crypt_t;

/**
 * struct dm_target_raid
 *
 * @num_elements: Number of devices that make up the raid target.
 * @chunk_size:	Stripe size or mirror region size (in sectors).
 * @shared_flag:
 * @log:	Log string for desired logging. NULL = core log. This string
 *		consists of a log type name, number of parameters, followed
 *		by the required parameters. This allows for customized log
 *		superblocks. The chunk size will also be appended to the log
 *		constructor, and should NOT be counted in the number of
 *		parameters.
 * @logdevices:	Array of device structures where the log will be stored.
 *		num_elements specifies the number of elements in this array.
 *		If log == NULL, this field will be ignored.
 * @devices:	Array of device structures. num_elements specifies the number
 *		of elements in this array.
 *
 * Private structure to describe a raid target.
 **/
typedef struct dm_target_raid {
	u_int32_t		num_elements;
	u_int32_t		chunk_size;
	u_int32_t		shared_flag;
	char			*log;
	struct dm_device	*logdevices;
	struct dm_device	*devices;
} dm_target_raid_t;

/**
 * struct dm_device_list
 *
 * @dev_major:	Device major number.
 * @dev_minor:	Device minor number.
 * @name:	Device name.
 * @next:	Next device in the list.
 *
 * The dm_get_devices common-service will return a list of these structures.
 * Each structure represents the name and device-number of an active Device-
 * Mapper device.
 **/
typedef struct dm_device_list {
	u_int32_t		dev_major;
	u_int32_t		dev_minor;
	char			name[EVMS_NAME_SIZE+1];
	struct dm_device_list	* next;
} dm_device_list_t;

/**
 * struct dm_module_list
 *
 * @name:	Name of this DM module.
 * @version:	Version of this DM module.
 * @next:	Next DM module in the list.
 *
 * The dm_get_modules common-service will return a list of these structures.
 * Each structure represents the name and version of a loaded Device-Mapper
 * target module.
 **/
typedef struct dm_module_list {
	char			name[EVMS_NAME_SIZE+1];
	evms_version_t		version;
	struct dm_module_list	* next;
} dm_module_list_t;

#endif