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 * $Id: request.h,v 1.18 2000/05/07 04:05:33 grog Exp grog $
37 * $FreeBSD$
38 */
39
40 /* Information needed to set up a transfer */
41
42 enum xferinfo {
43 XFR_NORMAL_READ = 1,
44 XFR_NORMAL_WRITE = 2, /* write request in normal mode */
45 XFR_RECOVERY_READ = 4,
46 XFR_DEGRADED_WRITE = 8,
47 XFR_PARITYLESS_WRITE = 0x10,
48 XFR_NO_PARITY_STRIPE = 0x20, /* parity stripe is not available */
49 XFR_DATA_BLOCK = 0x40, /* data block in request */
50 XFR_PARITY_BLOCK = 0x80, /* parity block in request */
51 XFR_BAD_SUBDISK = 0x100, /* this subdisk is dead */
52 XFR_MALLOCED = 0x200, /* this buffer is malloced */
53 #if VINUMDEBUG
54 XFR_PHASE2 = 0x800, /* documentation only: 2nd phase write */
55 #endif
56 XFR_REVIVECONFLICT = 0x1000, /* possible conflict with a revive operation */
57 /* operations that need a parity block */
58 XFR_PARITYOP = (XFR_NORMAL_WRITE | XFR_RECOVERY_READ | XFR_DEGRADED_WRITE),
59 /* operations that use the group parameters */
60 XFR_GROUPOP = (XFR_DEGRADED_WRITE | XFR_RECOVERY_READ),
61 /* operations that that use the data parameters */
62 XFR_DATAOP = (XFR_NORMAL_READ | XFR_NORMAL_WRITE | XFR_PARITYLESS_WRITE),
63 /* operations requiring read before write */
64 XFR_RBW = (XFR_NORMAL_WRITE | XFR_DEGRADED_WRITE),
65 /* operations that need a malloced buffer */
66 XFR_NEEDS_MALLOC = (XFR_NORMAL_WRITE | XFR_RECOVERY_READ | XFR_DEGRADED_WRITE)
67 };
68
69 /*
70 * Describe one low-level request, part of a
71 * high-level request. This is an extended
72 * struct buf buffer, and the first element
73 * *must* be a struct buf. We pass this
74 * structure to the I/O routines instead of a
75 * struct buf in order to be able to locate the
76 * high-level request when it completes.
77 *
78 * All offsets and lengths are in sectors.
79 */
80
81 struct rqelement {
82 struct buf b; /* buf structure */
83 struct rqgroup *rqg; /* pointer to our group */
84 /* Information about the transfer */
85 daddr_t sdoffset; /* offset in subdisk */
86 int useroffset; /* offset in user buffer of normal data */
87 /*
88 * dataoffset and datalen refer to "individual" data
89 * transfers which involve only this drive (normal read,
90 * parityless write) and also degraded write.
91 *
92 * groupoffset and grouplen refer to the other "group"
93 * operations (normal write, recovery read) which involve
94 * more than one drive. Both the offsets are relative to
95 * the start of the local buffer.
96 */
97 int dataoffset; /* offset in buffer of the normal data */
98 int groupoffset; /* offset in buffer of group data */
99 short datalen; /* length of normal data (sectors) */
100 short grouplen; /* length of group data (sectors) */
101 short buflen; /* total buffer length to allocate */
102 short flags; /* really enum xferinfo (see above) */
103 /* Ways to find other components */
104 short sdno; /* subdisk number */
105 short driveno; /* drive number */
106 };
107
108 /*
109 * A group of requests built to satisfy an I/O
110 * transfer on a single plex.
111 */
112 struct rqgroup {
113 struct rqgroup *next; /* pointer to next group */
114 struct request *rq; /* pointer to the request */
115 short count; /* number of requests in this group */
116 short active; /* and number active */
117 short plexno; /* index of plex */
118 int badsdno; /* index of bad subdisk or -1 */
119 enum xferinfo flags; /* description of transfer */
120 struct rangelock *lock; /* lock for this transfer */
121 daddr_t lockbase; /* and lock address */
122 struct rqelement rqe[0]; /* and the elements of this request */
123 };
124
125 /*
126 * Describe one high-level request and the
127 * work we have to do to satisfy it.
128 */
129 struct request {
130 struct buf *bp; /* pointer to the high-level request */
131 enum xferinfo flags;
132 union {
133 int volno; /* volume index */
134 int plexno; /* or plex index */
135 } volplex;
136 int error; /* current error indication */
137 int sdno; /* reviving subdisk (XFR_REVIVECONFLICT) */
138 short isplex; /* set if this is a plex request */
139 short active; /* number of subrequests still active */
140 struct rqgroup *rqg; /* pointer to the first group of requests */
141 struct rqgroup *lrqg; /* and to the last group of requests */
142 struct request *next; /* link of waiting requests */
143 };
144
145 /*
146 * Extended buffer header for subdisk I/O. Includes
147 * a pointer to the user I/O request.
148 */
149 struct sdbuf {
150 struct buf b; /* our buffer */
151 struct buf *bp; /* and pointer to parent */
152 short driveno; /* drive index */
153 short sdno; /* and subdisk index */
154 };
155
156 /*
157 * Values returned by rqe and friends. Be careful
158 * with these: they are in order of increasing
159 * seriousness. Some routines check for
160 * > REQUEST_RECOVERED to indicate a failed request. XXX
161 */
162 enum requeststatus {
163 REQUEST_OK, /* request built OK */
164 REQUEST_RECOVERED, /* request OK, but involves RAID5 recovery */
165 REQUEST_DEGRADED, /* parts of request failed */
166 REQUEST_EOF, /* parts of request failed: outside plex */
167 REQUEST_DOWN, /* all of request failed: subdisk(s) down */
168 REQUEST_ENOMEM /* all of request failed: ran out of memory */
169 };
170
171 #ifdef VINUMDEBUG
172 /* Trace entry for request info (DEBUG_LASTREQS) */
173 enum rqinfo_type {
174 loginfo_unused, /* never been used */
175 loginfo_user_bp, /* this is the bp when strategy is called */
176 loginfo_user_bpl, /* and this is the bp at launch time */
177 loginfo_rqe, /* user RQE */
178 loginfo_iodone, /* iodone */
179 loginfo_raid5_data, /* write RAID-5 data block */
180 loginfo_raid5_parity, /* write RAID-5 parity block */
181 loginfo_sdio, /* subdisk I/O */
182 loginfo_sdiol, /* subdisk I/O launch */
183 loginfo_sdiodone, /* subdisk iodone */
184 loginfo_lockwait, /* wait for range lock */
185 loginfo_lock, /* lock range */
186 loginfo_unlock, /* unlock range */
187 };
188
189 union rqinfou { /* info to pass to logrq */
190 struct buf *bp;
191 struct rqelement *rqe; /* address of request, for correlation */
192 struct rangelock *lockinfo;
193 };
194
195 struct rqinfo {
196 enum rqinfo_type type; /* kind of event */
197 struct timeval timestamp; /* time it happened */
198 struct buf *bp; /* point to user buffer */
199 int devmajor; /* major and minor device info */
200 int devminor;
201 union {
202 struct buf b; /* yup, the *whole* buffer header */
203 struct rqelement rqe; /* and the whole rqe */
204 struct rangelock lockinfo;
205 } info;
206 };
207
208 #define RQINFO_SIZE 128 /* number of info slots in buffer */
209
210 void logrq(enum rqinfo_type type, union rqinfou info, struct buf *ubp);
211 #endif
212
213 /* Structures for the daemon */
214
215 /* types of request to the daemon */
216 enum daemonrq {
217 daemonrq_none, /* dummy to catch bugs */
218 daemonrq_ioerror, /* error occurred on I/O */
219 daemonrq_saveconfig, /* save configuration */
220 daemonrq_return, /* return to userland */
221 daemonrq_ping, /* show sign of life */
222 daemonrq_init, /* initialize a plex */
223 daemonrq_revive, /* revive a subdisk */
224 daemonrq_closedrive, /* close a drive */
225 };
226
227 /* info field for daemon requests */
228 union daemoninfo { /* and the request information */
229 struct request *rq; /* for daemonrq_ioerror */
230 struct sd *sd; /* for daemonrq_revive */
231 struct plex *plex; /* for daemonrq_init */
232 struct drive *drive; /* for daemonrq_closedrive */
233 int nothing; /* for passing NULL */
234 };
235
236 struct daemonq {
237 struct daemonq *next; /* pointer to next element in queue */
238 enum daemonrq type; /* type of request */
239 int privateinuse; /* private element, being used */
240 union daemoninfo info; /* and the request information */
241 };
242
243 void queue_daemon_request(enum daemonrq type, union daemoninfo info);
244
245 extern int daemon_options;
246
247 enum daemon_option {
248 daemon_verbose = 1, /* talk about what we're doing */
249 daemon_stopped = 2,
250 daemon_noupdate = 4, /* don't update the disk config, for recovery */
251 };
252
253 void freerq(struct request *rq);
254 void unlockrange(int plexno, struct rangelock *);
255 /* Local Variables: */
256 /* fill-column: 50 */
257 /* End: */
Cache object: aada4c7a2daa64f54eb060a34d53ac78
|