xref: /freebsd/sys/geom/geom_int.h (revision afcbcfaed01d0d67606a6dcc528e5178354e9a36)
1b1876192SPoul-Henning Kamp /*-
2b1876192SPoul-Henning Kamp  * Copyright (c) 2002 Poul-Henning Kamp
3b1876192SPoul-Henning Kamp  * Copyright (c) 2002 Networks Associates Technology, Inc.
4b1876192SPoul-Henning Kamp  * All rights reserved.
5b1876192SPoul-Henning Kamp  *
6b1876192SPoul-Henning Kamp  * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7b1876192SPoul-Henning Kamp  * and NAI Labs, the Security Research Division of Network Associates, Inc.
8b1876192SPoul-Henning Kamp  * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
9b1876192SPoul-Henning Kamp  * DARPA CHATS research program.
10b1876192SPoul-Henning Kamp  *
11b1876192SPoul-Henning Kamp  * Redistribution and use in source and binary forms, with or without
12b1876192SPoul-Henning Kamp  * modification, are permitted provided that the following conditions
13b1876192SPoul-Henning Kamp  * are met:
14b1876192SPoul-Henning Kamp  * 1. Redistributions of source code must retain the above copyright
15b1876192SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer.
16b1876192SPoul-Henning Kamp  * 2. Redistributions in binary form must reproduce the above copyright
17b1876192SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer in the
18b1876192SPoul-Henning Kamp  *    documentation and/or other materials provided with the distribution.
19b1876192SPoul-Henning Kamp  * 3. The names of the authors may not be used to endorse or promote
20b1876192SPoul-Henning Kamp  *    products derived from this software without specific prior written
21b1876192SPoul-Henning Kamp  *    permission.
22b1876192SPoul-Henning Kamp  *
23b1876192SPoul-Henning Kamp  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24b1876192SPoul-Henning Kamp  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25b1876192SPoul-Henning Kamp  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26b1876192SPoul-Henning Kamp  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27b1876192SPoul-Henning Kamp  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28b1876192SPoul-Henning Kamp  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29b1876192SPoul-Henning Kamp  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30b1876192SPoul-Henning Kamp  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31b1876192SPoul-Henning Kamp  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32b1876192SPoul-Henning Kamp  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33b1876192SPoul-Henning Kamp  * SUCH DAMAGE.
34b1876192SPoul-Henning Kamp  *
35b1876192SPoul-Henning Kamp  * $FreeBSD$
36b1876192SPoul-Henning Kamp  */
37b1876192SPoul-Henning Kamp 
38b1876192SPoul-Henning Kamp LIST_HEAD(class_list_head, g_class);
39b1876192SPoul-Henning Kamp TAILQ_HEAD(g_tailq_head, g_geom);
40b1876192SPoul-Henning Kamp TAILQ_HEAD(event_tailq_head, g_event);
41b1876192SPoul-Henning Kamp 
42b1876192SPoul-Henning Kamp extern struct event_tailq_head events;
43801bb689SPoul-Henning Kamp extern int g_collectstats;
44b1876192SPoul-Henning Kamp extern int g_debugflags;
458ebd558fSPoul-Henning Kamp /*
468ebd558fSPoul-Henning Kamp  * 1	G_T_TOPOLOGY
478ebd558fSPoul-Henning Kamp  * 2	G_T_BIO
488ebd558fSPoul-Henning Kamp  * 4	G_T_ACCESS
497da1ebfdSPoul-Henning Kamp  * 8	Enable sanity checks
508ebd558fSPoul-Henning Kamp  * 16	Allow footshooting on rank#1 providers
517da1ebfdSPoul-Henning Kamp  * 32	G_T_DETAILS
528ebd558fSPoul-Henning Kamp  */
537da1ebfdSPoul-Henning Kamp #define G_F_DISKIOCTL	64
54afa2a5aaSPoul-Henning Kamp #define G_F_CTLDUMP	128
557da1ebfdSPoul-Henning Kamp 
56b1876192SPoul-Henning Kamp 
57b1876192SPoul-Henning Kamp /*
58b1876192SPoul-Henning Kamp  * Various internal actions are tracked by tagging g_event[s] onto
59b1876192SPoul-Henning Kamp  * an internal eventqueue.
60b1876192SPoul-Henning Kamp  */
61b1876192SPoul-Henning Kamp enum g_events {
62b1876192SPoul-Henning Kamp 	EV_NEW_CLASS,		/* class */
63b1876192SPoul-Henning Kamp 	EV_NEW_PROVIDER,	/* provider */
64b1876192SPoul-Henning Kamp 	EV_SPOILED,		/* provider, consumer */
65346cd5feSPoul-Henning Kamp 	EV_CALL_ME,		/* func, arg */
66b1876192SPoul-Henning Kamp 	EV_LAST
67b1876192SPoul-Henning Kamp };
68b1876192SPoul-Henning Kamp 
69afcbcfaeSPoul-Henning Kamp #define G_N_EVENTREFS		20
70afcbcfaeSPoul-Henning Kamp 
71b1876192SPoul-Henning Kamp struct g_event {
72b1876192SPoul-Henning Kamp 	enum g_events 		event;
73b1876192SPoul-Henning Kamp 	TAILQ_ENTRY(g_event)	events;
74346cd5feSPoul-Henning Kamp 	void			*arg;
75346cd5feSPoul-Henning Kamp 	g_call_me_t		*func;
76afcbcfaeSPoul-Henning Kamp 	void			*ref[G_N_EVENTREFS];
77b1876192SPoul-Henning Kamp };
78b1876192SPoul-Henning Kamp 
7991cd3dc6SPoul-Henning Kamp /*
8091cd3dc6SPoul-Henning Kamp  * We actually have a number of drivers sharing the same major number
8191cd3dc6SPoul-Henning Kamp  * so we coordinate the major/minor usage here
8291cd3dc6SPoul-Henning Kamp  */
8391cd3dc6SPoul-Henning Kamp #define GEOM_MAJOR		4
8491cd3dc6SPoul-Henning Kamp #define GEOM_MINOR_STATS	0
8591cd3dc6SPoul-Henning Kamp #define GEOM_MINOR_PROVIDERS	10
8691cd3dc6SPoul-Henning Kamp 
87b1876192SPoul-Henning Kamp /* geom_dump.c */
88afcbcfaeSPoul-Henning Kamp void g_confxml(void *, int flag);
892874f1cfSPoul-Henning Kamp void g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
90afcbcfaeSPoul-Henning Kamp void g_confdot(void *, int flag);
91afcbcfaeSPoul-Henning Kamp void g_conftxt(void *, int flag);
92b1876192SPoul-Henning Kamp 
93b1876192SPoul-Henning Kamp /* geom_event.c */
94b1876192SPoul-Henning Kamp void g_event_init(void);
95afcbcfaeSPoul-Henning Kamp void g_post_event(enum g_events ev, ...);
96afcbcfaeSPoul-Henning Kamp void g_cancel_event(void *ref);
97b1876192SPoul-Henning Kamp void g_run_events(void);
98d943f1b0SPoul-Henning Kamp void g_stall_events(void);
99d943f1b0SPoul-Henning Kamp void g_release_events(void);
100b1876192SPoul-Henning Kamp 
101b1876192SPoul-Henning Kamp /* geom_subr.c */
1022654e1fcSPoul-Henning Kamp extern struct class_list_head g_classes;
103b1876192SPoul-Henning Kamp extern char *g_wait_event, *g_wait_sim, *g_wait_up, *g_wait_down;
104b1876192SPoul-Henning Kamp 
105b1876192SPoul-Henning Kamp /* geom_io.c */
106b1876192SPoul-Henning Kamp void g_io_init(void);
107b1876192SPoul-Henning Kamp void g_io_schedule_down(struct thread *tp);
108b1876192SPoul-Henning Kamp void g_io_schedule_up(struct thread *tp);
109b1876192SPoul-Henning Kamp 
110b1876192SPoul-Henning Kamp /* geom_kern.c / geom_kernsim.c */
111b1876192SPoul-Henning Kamp void g_init(void);
112d49d7ca5SPoul-Henning Kamp 
113d49d7ca5SPoul-Henning Kamp /* geom_ctl.c */
114d49d7ca5SPoul-Henning Kamp void g_ctl_init(void);
115