Change the kernel dev_t, representing a pointer to a specinfo structure,
[dragonfly.git] / sys / dev / raid / vinum / vinumext.h
CommitLineData
984263bc
MD
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: vinumext.h,v 1.26 2000/05/16 07:38:08 grog Exp grog $
37 * $FreeBSD: src/sys/dev/vinum/vinumext.h,v 1.25.2.3 2001/05/11 02:11:06 grog Exp $
b13267a5 38 * $DragonFly: src/sys/dev/raid/vinum/vinumext.h,v 1.10 2006/09/10 01:26:36 dillon Exp $
984263bc
MD
39 */
40
41/* vinumext.h: external definitions */
42
43extern struct _vinum_conf vinum_conf; /* configuration information */
44
45#ifdef VINUMDEBUG
46extern int debug; /* debug flags */
47#endif
48
49/* Physical read and write drive */
10f3fee5
MD
50#define read_drive(a, b, c, d) driveio (a, b, c, d, BUF_CMD_READ)
51#define write_drive(a, b, c, d) driveio (a, b, c, d, BUF_CMD_WRITE)
984263bc
MD
52
53#define CHECKALLOC(ptr, msg) \
54 if (ptr == NULL) \
55 { \
56 printf (msg); \
57 longjmp (command_fail, -1); \
58 }
59#ifndef _KERNEL
60struct vnode;
61struct proc;
62#endif
63
64#ifdef _KERNEL
65int vinum_inactive(int);
66void free_vinum(int);
67int give_sd_to_plex(int plexno, int sdno);
68void give_sd_to_drive(int sdno);
69int give_plex_to_volume(int volno, int plexno);
70struct drive *check_drive(char *);
71enum drive_label_info read_drive_label(struct drive *, int);
72int parse_config(char *, struct keywordset *, int);
73int parse_user_config(char *cptr, struct keywordset *keyset);
74u_int64_t sizespec(char *spec);
75int volume_index(struct volume *volume);
76int plex_index(struct plex *plex);
77int sd_index(struct sd *sd);
78int drive_index(struct drive *drive);
79int my_plex(int volno, int plexno);
80int my_sd(int plexno, int sdno);
81int get_empty_drive(void);
82int find_drive(const char *name, int create);
83int find_drive_by_dev(const char *devname, int create);
84int get_empty_sd(void);
85int find_subdisk(const char *name, int create);
86void return_drive_space(int driveno, int64_t offset, int length);
87void free_sd(int sdno);
88void free_volume(int volno);
89int get_empty_plex(void);
90int find_plex(const char *name, int create);
91void free_plex(int plexno);
92int get_empty_volume(void);
93int find_volume(const char *name, int create);
94void config_subdisk(int);
95void config_plex(int);
96void config_volume(int);
97void config_drive(int);
98void updateconfig(int);
99void update_sd_config(int sdno, int kernelstate);
100void update_plex_config(int plexno, int kernelstate);
101void update_volume_config(int volno, int kernelstate);
102void update_config(void);
103void drive_io_done(struct buf *);
104void save_config(void);
105void daemon_save_config(void);
106void write_config(char *, int);
107int start_config(int);
108void finish_config(int);
109void remove(struct vinum_ioctl_msg *msg);
110void remove_drive_entry(int driveno, int force);
111void remove_sd_entry(int sdno, int force, int recurse);
112void remove_plex_entry(int plexno, int force, int recurse);
113void remove_volume_entry(int volno, int force, int recurse);
114
115void checkdiskconfig(char *);
116int open_drive(struct drive *, struct proc *, int);
117void close_drive(struct drive *drive);
118void close_locked_drive(struct drive *drive);
10f3fee5 119int driveio(struct drive *, char *, size_t, off_t, buf_cmd_t);
984263bc
MD
120int set_drive_parms(struct drive *drive);
121int init_drive(struct drive *, int);
122/* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */
123void throw_rude_remark(int, char *,...);
124
125/* XXX die die */
126void format_config(char *config, int len);
127void checkkernel(char *op);
128void free_drive(struct drive *drive);
129void down_drive(struct drive *drive);
130void remove_drive(int driveno);
131
132int vinum_scandisk(char *drivename[], int drives);
133
134/* I/O */
135d_open_t vinumopen;
136d_close_t vinumclose;
137d_strategy_t vinumstrategy;
138d_ioctl_t vinumioctl;
139d_dump_t vinumdump;
140d_psize_t vinumsize;
fef8985e 141d_poll_t vinumpoll;
984263bc 142
b13267a5 143int vinumstart(cdev_t dev, struct bio *bio, int reviveok);
984263bc 144int launch_requests(struct request *rq, int reviveok);
81b5c339 145void sdio(struct bio *bio);
984263bc
MD
146
147/* XXX Do we need this? */
b13267a5 148int vinumpart(cdev_t);
984263bc
MD
149
150extern jmp_buf command_fail; /* return here if config fails */
fef8985e 151extern struct dev_ops vinum_ops;
984263bc
MD
152
153#ifdef VINUMDEBUG
154/* Memory allocation and request tracing */
155void vinum_meminfo(caddr_t data);
156int vinum_mallocinfo(caddr_t data);
157int vinum_rqinfo(caddr_t data);
158void LongJmp(jmp_buf, int);
984263bc
MD
159#else
160void longjmp(jmp_buf, int); /* the kernel doesn't define this */
161#endif
162int setjmp(jmp_buf);
163
e4c9c0c8 164char *basename(char *);
984263bc
MD
165void expand_table(void **, int, int);
166
167struct request;
168struct rqgroup *allocrqg(struct request *rq, int elements);
169void deallocrqg(struct rqgroup *rqg);
170
171/* Device number decoding */
b13267a5
MD
172int Volno(cdev_t x);
173int Plexno(cdev_t x);
174int Sdno(cdev_t x);
984263bc
MD
175
176/* State transitions */
177int set_drive_state(int driveno, enum drivestate state, enum setstateflags flags);
178int set_sd_state(int sdno, enum sdstate state, enum setstateflags flags);
179enum requeststatus checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend);
180int set_plex_state(int plexno, enum plexstate state, enum setstateflags flags);
181int set_volume_state(int volumeno, enum volumestate state, enum setstateflags flags);
182void update_sd_state(int sdno);
183void forceup(int plexno);
184void update_plex_state(int plexno);
185void update_volume_state(int volno);
186void invalidate_subdisks(struct plex *, enum sdstate);
187void get_volume_label(char *name, int plexes, u_int64_t size, struct disklabel *lp);
188int write_volume_label(int);
189void start_object(struct vinum_ioctl_msg *);
190void stop_object(struct vinum_ioctl_msg *);
191void setstate(struct vinum_ioctl_msg *msg);
192void setstate_by_force(struct vinum_ioctl_msg *msg);
193void vinum_label(int);
194int vinum_writedisklabel(struct volume *, struct disklabel *);
195int initsd(int, int);
196struct buf *parityrebuild(struct plex *, u_int64_t, int, enum parityop, struct rangelock **, off_t *);
197enum requeststatus sddownstate(struct request *rq);
198
199int restart_plex(int plexno);
200int revive_read(struct sd *sd);
201int revive_block(int sdno);
202void parityops(struct vinum_ioctl_msg *);
203
204/* Auxiliary functions */
205enum sdstates sdstatemap(struct plex *plex);
206enum volplexstate vpstate(struct plex *plex);
207#endif
208
209enum keyword get_keyword(char *, struct keywordset *);
210void listconfig(void);
211char *drive_state(enum drivestate);
212char *volume_state(enum volumestate);
213char *plex_state(enum plexstate);
214char *plex_org(enum plexorg);
215char *sd_state(enum sdstate);
216enum drivestate DriveState(char *text);
217enum sdstate SdState(char *text);
218enum plexstate PlexState(char *text);
219enum volumestate VolState(char *text);
220struct drive *validdrive(int driveno, struct _ioctl_reply *);
221struct sd *validsd(int sdno, struct _ioctl_reply *);
222struct plex *validplex(int plexno, struct _ioctl_reply *);
223struct volume *validvol(int volno, struct _ioctl_reply *);
224int tokenize(char *, char *[]);
225void resetstats(struct vinum_ioctl_msg *msg);
226
227/* Locking */
228#ifdef VINUMDEBUG
229int lockdrive(struct drive *drive, char *, int);
230#else
231int lockdrive(struct drive *drive);
232#endif
233void unlockdrive(struct drive *drive);
234int lockvol(struct volume *vol);
235void unlockvol(struct volume *vol);
236int lockplex(struct plex *plex);
237void unlockplex(struct plex *plex);
238struct rangelock *lockrange(daddr_t stripe, struct buf *bp, struct plex *plex);
239int lock_config(void);
240void unlock_config(void);
241
242