summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/avs/ns/dsw/dsw.h
blob: 3243e9a6e9ffb05d9dfe91d2cd7c10de9da6ac8b (plain)
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_DSW_H
#define	_DSW_H

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Miscellaneous defines
 */

#define	DSW_BITS	8	/* # of bits in a byte */
#define	DSW_SIZE	64	/* fba's in a DSW chunk */


/*
 * Ioctl definitions
 */

#define	_D_(x)			(('D'<<16)|('W'<<8)|(x))

#define	DSWIOC_ENABLE		_D_(1)	/* Configure DSW pair */
#define	DSWIOC_RESUME		_D_(2)	/* Resume a DSW pair */
#define	DSWIOC_SUSPEND		_D_(3)	/* Suspend a DSW pair */
#define	DSWIOC_COPY		_D_(4)	/* Copy DSW volume over its pair */
#define	DSWIOC_BITMAP		_D_(5)	/* Get bitmap */
#define	DSWIOC_STAT		_D_(6)	/* Get state of shadow */
#define	DSWIOC_DISABLE		_D_(7)	/* Deconfigure DSW pair */
#define	DSWIOC_SHUTDOWN		_D_(8)	/* Suspend all DSW pairs */
#define	DSWIOC_ABORT		_D_(9)	/* Abort Copy of DSW pair */
#define	DSWIOC_VERSION		_D_(10)	/* DataShadow version */
#define	DSWIOC_RESET		_D_(11)	/* Reset DataShadow set */
#define	DSWIOC_OFFLINE		_D_(12)	/* Offline volumes */
#define	DSWIOC_WAIT		_D_(13)	/* Wait for copy to complete */
#define	DSWIOC_LIST		_D_(14)	/* List current kernel shadow groups */
#define	DSWIOC_ACOPY		_D_(15)	/* Copy DSW volumes over their pairs */
#define	DSWIOC_EXPORT		_D_(16)	/* Export the shadow volume */
#define	DSWIOC_IMPORT		_D_(17)	/* Import shadow volume */
#define	DSWIOC_JOIN		_D_(18)	/* Rejoin previously exported shadow */
#define	DSWIOC_COPYP		_D_(19)	/* Set and get copy parameters */
#define	DSWIOC_OCREAT		_D_(20)	/* Create overflow volume */
#define	DSWIOC_OATTACH		_D_(21)	/* Attach overflow volume */
#define	DSWIOC_ODETACH		_D_(22)	/* Detach overflow volume */
#define	DSWIOC_OLIST		_D_(23)	/* List overflow volumes */
#define	DSWIOC_OSTAT		_D_(24)	/* Stat overflow volume */
#define	DSWIOC_SBITSSET		_D_(25)	/* Get # of bits set in shadow bitmap */
#define	DSWIOC_CBITSSET		_D_(26)	/* Get # of bits set in copy bitmap */
#define	DSWIOC_LISTLEN		_D_(27)	/* length of DSWIOC_LIST data */
#define	DSWIOC_OLISTLEN		_D_(28)	/* length of DSWIOC_OLIST data */
#define	DSWIOC_SEGMENT		_D_(29) /* Get segemented bitmaps */
#define	DSWIOC_MOVEGRP		_D_(30)	/* Move set from one group to another */
#define	DSWIOC_CLIST		_D_(31) /* get list of resource groups */
#define	DSWIOC_GLIST		_D_(32)	/* get list of groups */
#define	DSWIOC_CHANGETAG	_D_(33)	/* change the cluster tag of a set */
#define	DSWIOC_OSTAT2		_D_(34) /* Stat overflow volume enhanced */

/*
 * Config and status flags
 */

#define	DSW_GOLDEN	0x0001		/* the set is independent */

#define	DSW_COPYINGP	0x0100		/* Copy in progress */
#define	DSW_COPYINGM	0x0200		/* Copying master to shadow */
#define	DSW_COPYINGS	0x0400		/* Copying shadow to master */
#define	DSW_COPYING	0x0600		/* Copying, may be in progress */
#define	DSW_COPY_FLAGS	0x0700		/* Copy flags */
#define	DSW_COPYINGX	0x0800		/* Copy exit requested */
#define	DSW_OFFLINE	0xf000		/* An underlying volume offline */
#define	DSW_BMPOFFLINE	0x1000		/* Bitmap volume offline */
#define	DSW_SHDOFFLINE	0x2000		/* Shadow volume offline */
#define	DSW_MSTOFFLINE	0x4000		/* Master volume offline */
#define	DSW_OVROFFLINE	0x8000		/* Overflow volume offline */
#define	DSW_TREEMAP	0x10000		/* Shadow volume accessed by an index */
#define	DSW_OVERFLOW	0x20000		/* Shadow volume has overflowed */
#define	DSW_SHDEXPORT	0x40000		/* Shadow volume has been exported */
#define	DSW_SHDIMPORT	0x80000		/* Shadow volume has been imported */
#define	DSW_VOVERFLOW	0x100000	/* Shadow volume using overflow vol */
#define	DSW_HANGING	0x200000	/* Hanging master structure  */
#define	DSW_CFGOFFLINE	0x400000	/* config db is offline */
#define	DSW_OVRHDRDRTY	0x800000	/* Overflow header dirty */
#define	DSW_RESIZED	0x1000000	/* mst_size != shd_size */
#define	DSW_FRECLAIM	0x2000000	/* force the reclaim of an ovr vol */

/*
 * used for SNMP trap only.
 * These flags help distinguish between enable and resume,
 * suspend and disable.
 * Note that DSW_HANGING is set for both suspend and disable
 */
#define	DSW_SNMP_CLR		0	/* no flag is set	*/
#define	DSW_SNMP_DISABLE	1	/* Set is disabled	*/
#define	DSW_SNMP_SUSPEND	2	/* Set is suspended	*/
#define	DSW_SNMP_ENABLE		3	/* Set is enabled	*/
#define	DSW_SNMP_RESUME		4	/* Set is resumed	*/
#define	DSW_SNMP_OVER_ATTACH	5	/* overflow attached	*/
#define	DSW_SNMP_OVER_DETACH	6	/* overflow detached	*/
#define	DSW_SNMP_UPDATE		7	/* update operation	*/
#define	DSW_SNMP_COPIED		8	/* copy operation	*/

	/* Overflow volume flags */
#define	IIO_OFFLINE	0x0001		/* Volume is offline */
#define	IIO_HDR_WRTN	0x0002		/* Header written */
#define	IIO_CNTR_INVLD	0x0004		/* Overflow counters invalid */
#define	IIO_VOL_UPDATE	0x0008		/* Performing group update */

#define	DSW_NAMELEN	64		/* NSC_MAXPATH - don't change without */
					/* amending header version number */

#define	DSWDEV		"/dev/ii"
#define	II_IMPORTED_SHADOW "<imported_shadow>"

/*
 * Configuration parameter defines
 * ii_bitmap, ii_throttle_unit, ii_throttle_delay
 */
#define	II_KMEM		0	/* Load/store on resume/suspend, in memory */
#define	II_WTHRU	1	/* Read/write bitmap thru to bitmap volume */
#define	II_FWC		2	/* Read/write bitmap to FWC, else WTHRU */

#define	MIN_THROTTLE_UNIT	100	/* Min. number of units to transfer */
#define	MAX_THROTTLE_UNIT	60000	/* Max. number of units to transfer */
#define	MIN_THROTTLE_DELAY	2	/* Min. delay between unit transfer */
#define	MAX_THROTTLE_DELAY	10000	/* Max. delay between unit transfer */

/*
 * DSW user config structure
 */

typedef struct dsw_config_s {
	spcs_s_info_t status;
	char master_vol[DSW_NAMELEN];
	char shadow_vol[DSW_NAMELEN];
	char bitmap_vol[DSW_NAMELEN];
	char cluster_tag[DSW_NAMELEN];
	char group_name[DSW_NAMELEN];
	int flag;
} dsw_config_t;

/*
 * DSW segmented bitmap I/O structure
 */
typedef struct dsw_segment_s {
	spcs_s_info_t status;
	char shadow_vol[DSW_NAMELEN];
	unsigned seg_number;		/* 32KB Segment number to start at */
	unsigned char   *shd_bitmap;		/* pointer to shadow bitmap */
	int	shd_size;			/* size of shadow bitmap */
	unsigned char   *cpy_bitmap;		/* pointer to copy bitmap */
	int	cpy_size;			/* size of copy bitmap */
	unsigned char	*idx_bitmap;		/* pointer to index table */
	int	idx_size;			/* size of index table */
} dsw_segment_t;

/*
 * DSW user bitmap structure
 */

typedef struct dsw_bitmap_s {
	spcs_s_info_t status;
	char shadow_vol[DSW_NAMELEN];
	unsigned char	*shd_bitmap;		/* pointer to shadow bitmap */
	uint64_t shd_size;			/* size of shadow bitmap */
	uint64_t copy_size;			/* size of copy bitmap */
	unsigned char	*copy_bitmap;		/* pointer to copy bitmap */
} dsw_bitmap_t;


/*
 * DSW general ioctl structure
 */

typedef struct dsw_ioctl_s {
	spcs_s_info_t status;
	char shadow_vol[DSW_NAMELEN];
	int flags;
	pid_t pid;
} dsw_ioctl_t;


/*
 * DSW general atomic ioctl structure operating on several Image sets
 */

typedef struct dsw_aioctl_s {
	spcs_s_info_t status;
	int flags;
	int count;
	pid_t pid;
	char shadow_vol[DSW_NAMELEN];	/* start of list of image sets */
} dsw_aioctl_t;


/*
 * DSW stat ioctl structure
 */

typedef struct dsw_stat_s {
	spcs_s_info_t status;
	char shadow_vol[DSW_NAMELEN];
	int stat;
	uint64_t size;
	char overflow_vol[DSW_NAMELEN];
	uint64_t shdsize;
	uint64_t shdused;
	char group_name[DSW_NAMELEN];
	char cluster_tag[DSW_NAMELEN];
	uint64_t mtime;
} dsw_stat_t;


/*
 * DSW version ioctl structure
 */

typedef struct dsw_version_s {
	spcs_s_info_t status;
	int major;			/* Major release number */
	int minor;			/* Minor release number */
	int micro;			/* Micro release number */
	int baseline;			/* Baseline revision number */
} dsw_version_t;

/*
 * DSW get bits set in bitmap structure
 */

typedef struct dsw_bitsset_s {
	spcs_s_info_t status;
	char	shadow_vol[DSW_NAMELEN];
	uint64_t tot_size;		/* total number of bits in map */
	uint64_t tot_set;		/* number of bitmap bits set */
} dsw_bitsset_t;


/*
 * DSW list ioctl structure
 */

typedef struct dsw_list_s {
	spcs_s_info_t status;
	int list_size;			/* number of elements in list */
	int list_used;			/* number of elements returned */
	dsw_config_t *list;
} dsw_list_t;

/*
 * DSW copy parameter structure
 */

typedef struct dsw_copyp_s {
	spcs_s_info_t status;
	char shadow_vol[DSW_NAMELEN];
	int copy_unit;
	int copy_delay;
} dsw_copyp_t;

/*
 * DSW ostat ioctl structure
 */

typedef struct dsw_ostat_s {
	spcs_s_info_t status;
	char overflow_vol[DSW_NAMELEN];
	int drefcnt;
	uint64_t used;
	uint64_t unused;
	uint64_t nchunks;
	int crefcnt;
	int flags;
	int hversion;
	int hmagic;
} dsw_ostat_t;

/*
 * DSW move group structure
 */

typedef struct dsw_movegrp_s {
	spcs_s_info_t status;
	char shadow_vol[DSW_NAMELEN];
	char new_group[DSW_NAMELEN];
} dsw_movegrp_t;

/*
 * II_PIT_PROPS structure
 */
typedef struct pit_props_s {
	int iirc;
	int mstid;
	int shdid;
	int bmpid;
	int ovrid;
	char group[DSW_NAMELEN];
	char cluster[DSW_NAMELEN];
	int  has_overflow;
	int  flags;
	uint64_t  size;
	int64_t  shdchks;
	int64_t  copybits;
	int64_t  shdbits;
} pit_props_t;

/*
 * II_PIT_UPDATE structure
 */
typedef struct pit_update_s {
	int iirc;
	char direction;
} pit_update_t;

#ifdef _KERNEL
/*
 * 32 bit versions of ioctl structures
 */

typedef struct dsw_config32_s {
	spcs_s_info32_t status;
	char master_vol[DSW_NAMELEN];
	char shadow_vol[DSW_NAMELEN];
	char bitmap_vol[DSW_NAMELEN];
	char cluster_tag[DSW_NAMELEN];
	char group_name[DSW_NAMELEN];
	int flag;
} dsw_config32_t;

/*
 * DSW segmented bitmap I/O structure
 */
typedef struct dsw_segment32_s {
	spcs_s_info32_t status;
	char shadow_vol[DSW_NAMELEN];
	uint32_t seg_number;
	uint32_t shd_bitmap;
	int	 shd_size;
	uint32_t cpy_bitmap;
	int	 cpy_size;
	uint32_t idx_bitmap;
	int	 idx_size;
} dsw_segment32_t;

/*
 * DSW user bitmap structure
 */

typedef struct dsw_bitmap32_s {
	spcs_s_info32_t status;
	char shadow_vol[DSW_NAMELEN];
	uint32_t shd_bitmap;		/* 32 bit pointer value */
	uint64_t shd_size;
	uint64_t copy_size;
	uint32_t copy_bitmap;		/* 32 bit pointer value */
} dsw_bitmap32_t;

typedef struct dsw_ioctl32_s {
	spcs_s_info32_t status;
	char shadow_vol[DSW_NAMELEN];
	int flags;
	pid_t pid;
} dsw_ioctl32_t;

typedef struct dsw_stat32_s {
	spcs_s_info32_t status;
	char shadow_vol[DSW_NAMELEN];
	int stat;
	uint64_t size;
	char overflow_vol[DSW_NAMELEN];
	uint64_t shdsize;
	uint64_t shdused;
	char group_name[DSW_NAMELEN];
	char cluster_tag[DSW_NAMELEN];
	uint64_t mtime;
} dsw_stat32_t;

typedef struct dsw_version32_s {
	spcs_s_info32_t status;
	int major;			/* Major release number */
	int minor;			/* Minor release number */
	int micro;			/* Micro release number */
	int baseline;			/* Baseline revision number */
} dsw_version32_t;

typedef struct dsw_bitsset32_s {
	spcs_s_info32_t status;
	char	shadow_vol[DSW_NAMELEN];
	uint64_t	tot_size;	/* total number of bits in map */
	uint64_t	tot_set;	/* number of bitmap bits set */
} dsw_bitsset32_t;

typedef struct dsw_list32_s {
	spcs_s_info32_t status;
	int list_size;
	int list_used;
	uint32_t list;
} dsw_list32_t;

typedef struct dsw_aioctl32_s {
	spcs_s_info32_t status;
	int flags;
	int count;
	pid_t pid;
	char shadow_vol[DSW_NAMELEN];	/* start of list of image sets */
} dsw_aioctl32_t;

typedef struct dsw_copyp32_s {
	spcs_s_info32_t status;
	char shadow_vol[DSW_NAMELEN];
	int copy_unit;
	int copy_delay;
} dsw_copyp32_t;

typedef struct dsw_ostat32_s {
	spcs_s_info32_t status;
	char overflow_vol[DSW_NAMELEN];
	int drefcnt;
	uint64_t used;
	uint64_t unused;
	uint64_t nchunks;
	int crefcnt;
	int flags;
	int hversion;
	int hmagic;
} dsw_ostat32_t;

/*
 * DSW move group structure
 */

typedef struct dsw_movegrp32_s {
	spcs_s_info32_t status;
	char shadow_vol[DSW_NAMELEN];
	char new_group[DSW_NAMELEN];
} dsw_movegrp32_t;

#endif	/* _KERNEL */

/* dsw_copy dsw_ioctl_t flag bits */
#define	CV_BMP_ONLY	0x00000001	/* copy only chunks flagged by bitmap */
#define	CV_SHD2MST	0x00000002	/* copy shadow to master */
#define	CV_LOCK_PID	0x00000004	/* On copy/update, lock PIT by PID */
#define	CV_CLR_BMP	0x00000010	/* clear bits in bit map during copy */
#define	CV_IS_CLUSTER	0x00000020	/* struct refers to cluster */
#define	CV_IS_GROUP	0x00000040	/* struct refers to group (cpy/upd) */
#define	CV_SIBLING	0x00010000	/* internal copy_on_write flag */

/* nsc_control commands */

#define	II_CONTROL(x)	('I' << 24 | 'I' << 16 | (x))	/* 0x49490000 */

#define	II_PIT_COPY	II_CONTROL(1)	/* Perform an II Copy */
#define	II_PIT_UPDATE	II_CONTROL(2)	/* Perform an II Update */
#define	II_PIT_ABORT	II_CONTROL(3)	/* Perform an II Abort */
#define	II_PIT_WAIT	II_CONTROL(4)	/* Perform an II Wait */
#define	II_PIT_PROPS	II_CONTROL(5)	/* Perform an II Properties */

#ifdef __cplusplus
}
#endif

#endif	/* _DSW_H */