xref: /dragonfly/sys/dev/raid/vinum/vinumio.h (revision 73610d44)
1 /*-
2  * Copyright (c) 1997, 1998
3  *	Nan Yang Computer Services Limited.  All rights reserved.
4  *
5  *  This software is distributed under the so-called ``Berkeley
6  *  License'':
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by Nan Yang Computer
19  *      Services Limited.
20  * 4. Neither the name of the Company nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * This software is provided ``as is'', and any express or implied
25  * warranties, including, but not limited to, the implied warranties of
26  * merchantability and fitness for a particular purpose are disclaimed.
27  * In no event shall the company or contributors be liable for any
28  * direct, indirect, incidental, special, exemplary, or consequential
29  * damages (including, but not limited to, procurement of substitute
30  * goods or services; loss of use, data, or profits; or business
31  * interruption) however caused and on any theory of liability, whether
32  * in contract, strict liability, or tort (including negligence or
33  * otherwise) arising in any way out of the use of this software, even if
34  * advised of the possibility of such damage.
35  */
36 
37 #include <sys/ioccom.h>
38 
39 #define L 'F'			/* ID letter of our ioctls */
40 
41 #ifdef VINUMDEBUG
42 #define MAX_IOCTL_REPLY 1024
43 #else
44 #define MAX_IOCTL_REPLY 256
45 #endif
46 
47 #ifdef VINUMDEBUG
48 struct debuginfo {
49 	int changeit;
50 	int param;
51 };
52 
53 #endif
54 
55 enum objecttype {
56 	drive_object,
57 	sd_object,
58 	plex_object,
59 	volume_object,
60 	invalid_object
61 };
62 
63 /*
64  * The state to set with VINUM_SETSTATE.  Since each object has a
65  * different set of states, we need to translate later.
66  */
67 enum objectstate {
68 	object_down,
69 	object_initializing,
70 	object_initialized,
71 	object_up
72 };
73 
74 /*
75  * This structure is used for modifying objects
76  * (VINUM_SETSTATE, VINUM_REMOVE, VINUM_RESETSTATS, VINUM_ATTACH,
77  * VINUM_DETACH, VINUM_REPLACE
78  */
79 struct vinum_ioctl_msg {
80 	int index;
81 	enum objecttype type;
82 	enum objectstate state;	/* state to set (VINUM_SETSTATE) */
83 	enum parityop op;	/* for parity ops */
84 	int force;		/* do it even if it doesn't make sense */
85 	int recurse;		/* recurse (VINUM_REMOVE) */
86 	int verify;		/* verify (initsd, rebuildparity) */
87 	int otherobject;	/* superordinate object (attach),
88 				 * replacement object (replace)	  */
89 	int rename;		/* rename object (attach) */
90 	int64_t offset;		/* offset of subdisk (for attach) */
91 	int blocksize;		/* size of block to revive (bytes) */
92 };
93 
94 /*
95  * VINUM_CREATE returns a buffer of this kind
96  */
97 struct _ioctl_reply {
98 	int error;
99 	char msg[MAX_IOCTL_REPLY];
100 };
101 
102 struct vinum_rename_msg {
103     int index;
104     int recurse;		/* rename subordinate objects too */
105     enum objecttype type;
106     char newname[MAXNAME];	/* new name to give to object */
107 };
108 
109 /*
110  * Ioctl requests.
111  * Size of buffer, including continuations
112  */
113 #define BUFSIZE		1024
114 
115 /* configure vinum */
116 #define VINUM_CREATE		_IOC(IOC_IN | IOC_OUT, L, 64, BUFSIZE)
117 
118 /* get global config */
119 #define VINUM_GETCONFIG		_IOR(L, 65, struct _vinum_conf)
120 
121 /* get drive config */
122 #define VINUM_DRIVECONFIG	_IOWR(L, 66, struct drive)
123 
124 /* get subdisk config */
125 #define VINUM_SDCONFIG		_IOWR(L, 67, struct sd)
126 
127 /* get plex config */
128 #define VINUM_PLEXCONFIG	_IOWR(L, 68, struct plex)
129 
130 /* get volume config */
131 #define VINUM_VOLCONFIG		_IOWR(L, 69, struct volume)
132 
133 /* get sd config for plex (plex, sdno) */
134 #define VINUM_PLEXSDCONFIG	_IOWR(L, 70, struct sd)
135 
136 /* get freelist element (drive, fe) */
137 #define VINUM_GETFREELIST	_IOWR(L, 71, struct drive_freelist)
138 
139 /* write config to disk */
140 #define VINUM_SAVECONFIG	_IOW(L, 72, int)
141 
142 /* trash config on disk */
143 #define VINUM_RESETCONFIG	_IOC(0, L, 73, 0)
144 
145 /* read config from disk */
146 #define VINUM_INIT		_IOC(0, L, 74, 0)
147 
148 #ifdef VINUMDEBUG
149 
150 /* call the debugger from ioctl () */
151 #define VINUM_DEBUG		_IOWR(L, 75, struct debuginfo)
152 
153 #endif
154 
155 /*
156  * Start an object.  Pass two integers:
157  * msg [0] index in vinum_conf.<object>
158  * msg [1] type of object (see below)
159  *
160  * Return ioctl_reply
161  */
162 /* start an object */
163 #define VINUM_SETSTATE 		_IOC(IOC_IN | IOC_OUT, L, 76, MAX_IOCTL_REPLY)
164 
165 /* release locks and write config to disk */
166 #define VINUM_RELEASECONFIG	_IOC(0, L, 77, 0)
167 
168 /* start a configuration operation */
169 #define VINUM_STARTCONFIG	_IOW(L, 78, int)
170 
171 /* get memory usage summary */
172 #define VINUM_MEMINFO 		_IOR(L, 79, struct meminfo)
173 
174 /* get specific malloc information [i] */
175 #define VINUM_MALLOCINFO	_IOWR(L, 80, struct mc)
176 
177 /* label a volume */
178 #define VINUM_LABEL 		_IOC(IOC_IN | IOC_OUT, L, 81, MAX_IOCTL_REPLY)
179 
180 /* initialize a subdisk */
181 #define VINUM_INITSD 		_IOW(L, 82, int)
182 
183 /* remove an object */
184 #define VINUM_REMOVE 		_IOWR(L, 83, struct _ioctl_reply)
185 
186 /* set read policy */
187 #define VINUM_READPOL 		_IOWR(L, 84, struct _ioctl_reply)
188 
189 /* diddle object state */
190 #define VINUM_SETSTATE_FORCE	_IOC(IOC_IN | IOC_OUT, L, 85, MAX_IOCTL_REPLY)
191 
192 /* reset object stats */
193 #define VINUM_RESETSTATS	_IOWR(L, 86, struct _ioctl_reply)
194 
195 /* attach an object */
196 #define VINUM_ATTACH		_IOWR(L, 87, struct _ioctl_reply)
197 
198 /* remove an object */
199 #define VINUM_DETACH		_IOWR(L, 88, struct _ioctl_reply)
200 
201 /* rename an object */
202 #define VINUM_RENAME		_IOWR(L, 89, struct _ioctl_reply)
203 
204 /* replace an object */
205 #define VINUM_REPLACE		_IOWR(L, 90, struct _ioctl_reply)
206 
207 #ifdef VINUMDEBUG
208 
209 /* get request info [i] from trace buffer */
210 #define VINUM_RQINFO		_IOWR(L, 91, struct rqinfo)
211 
212 #endif
213 
214 /* perform the kernel part of Vinum daemon */
215 #define VINUM_DAEMON		_IOC(0, L, 92, 0)
216 
217 /* check for presence of Vinum daemon */
218 #define VINUM_FINDDAEMON	_IOC(0, L, 93, 0)
219 
220 /* set daemon flags */
221 #define VINUM_SETDAEMON		_IOW(L, 94, int)
222 
223 /* get daemon flags */
224 #define VINUM_GETDAEMON		_IOR(L, 95, int)
225 
226 /* check/rebuild RAID-4/5 parity */
227 #define VINUM_PARITYOP   	_IOWR(L, 96, struct _ioctl_reply)
228 
229 /* move an object */
230 #define VINUM_MOVE		_IOWR(L, 98, struct _ioctl_reply)
231