geom_int.h revision 112988
123660Speter/*-
225746Speter * Copyright (c) 2002 Poul-Henning Kamp
31573Srgrimes * Copyright (c) 2002 Networks Associates Technology, Inc.
41573Srgrimes * All rights reserved.
525401Sjb *
61573Srgrimes * This software was developed for the FreeBSD Project by Poul-Henning Kamp
71573Srgrimes * and NAI Labs, the Security Research Division of Network Associates, Inc.
81849Swollman * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
914224Speter * DARPA CHATS research program.
101849Swollman *
111573Srgrimes * Redistribution and use in source and binary forms, with or without
121573Srgrimes * modification, are permitted provided that the following conditions
131573Srgrimes * are met:
141573Srgrimes * 1. Redistributions of source code must retain the above copyright
151573Srgrimes *    notice, this list of conditions and the following disclaimer.
1625401Sjb * 2. Redistributions in binary form must reproduce the above copyright
1725401Sjb *    notice, this list of conditions and the following disclaimer in the
1825736Speter *    documentation and/or other materials provided with the distribution.
1925401Sjb * 3. The names of the authors may not be used to endorse or promote
201573Srgrimes *    products derived from this software without specific prior written
2125401Sjb *    permission.
2225401Sjb *
2325401Sjb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2424454Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2525401Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2625401Sjb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2714224Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2825401Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2925401Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3025401Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3125401Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3214224Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
338021Sache * SUCH DAMAGE.
348021Sache *
3525401Sjb * $FreeBSD: head/sys/geom/geom_int.h 112988 2003-04-02 20:41:18Z phk $
3625401Sjb */
3718421Sphk
3823660SpeterLIST_HEAD(class_list_head, g_class);
3925539SdfrTAILQ_HEAD(g_tailq_head, g_geom);
4025539SdfrTAILQ_HEAD(event_tailq_head, g_event);
4125539Sdfr
421573Srgrimesextern struct event_tailq_head events;
4325401Sjbextern int g_collectstats;
4425401Sjbextern int g_debugflags;
4525401Sjb/*
4625401Sjb * 1	G_T_TOPOLOGY
4725401Sjb * 2	G_T_BIO
4825736Speter * 4	G_T_ACCESS
4925736Speter * 8	Enable sanity checks
5025401Sjb * 16	Allow footshooting on rank#1 providers
5125401Sjb * 32	G_T_DETAILS
521573Srgrimes */
5325401Sjb#define G_F_DISKIOCTL	64
541573Srgrimes#define G_F_CTLDUMP	128
5525401Sjb
5625401Sjb
5725401Sjb/*
5825401Sjb * Various internal actions are tracked by tagging g_event[s] onto
5925401Sjb * an internal eventqueue.
6025401Sjb */
6125105Sbdeenum g_events {
622366Sbde	EV_NEW_CLASS,		/* class */
6325401Sjb	EV_NEW_PROVIDER,	/* provider */
6425401Sjb	EV_SPOILED,		/* provider, consumer */
6525105Sbde	EV_CALL_ME,		/* func, arg */
662366Sbde	EV_LAST
6725401Sjb};
681573Srgrimes
6925401Sjb#define G_N_EVENTREFS		20
7025401Sjb
7125736Speterstruct g_event {
7225736Speter	enum g_events 		event;
7325736Speter	TAILQ_ENTRY(g_event)	events;
7425105Sbde	void			*arg;
7525105Sbde	g_call_me_t		*func;
762366Sbde	void			*ref[G_N_EVENTREFS];
7725401Sjb};
7825401Sjb
7925401Sjb/*
8025105Sbde * We actually have a number of drivers sharing the same major number
8125105Sbde * so we coordinate the major/minor usage here
8225105Sbde */
832366Sbde#define GEOM_MAJOR		4
8425401Sjb#define GEOM_MINOR_STATS	0
8525401Sjb#define GEOM_MINOR_PROVIDERS	10
8625401Sjb
8725401Sjb/* geom_dump.c */
8825401Sjbvoid g_confxml(void *, int flag);
8925401Sjbvoid g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
901849Swollmanvoid g_confdot(void *, int flag);
911849Swollmanvoid g_conftxt(void *, int flag);
9225746Speter
9325746Speter/* geom_event.c */
941849Swollmanvoid g_event_init(void);
951849Swollmanvoid g_post_event(enum g_events ev, ...);
961849Swollmanvoid g_cancel_event(void *ref);
971849Swollmanvoid g_run_events(void);
981849Swollmanvoid g_stall_events(void);
9924522Sachevoid g_release_events(void);
10024522Sache
1011849Swollman/* geom_subr.c */
10214237Speterextern struct class_list_head g_classes;
10314237Speterextern char *g_wait_event, *g_wait_sim, *g_wait_up, *g_wait_down;
1041849Swollman
10525746Speter/* geom_io.c */
10613522Snatevoid g_io_init(void);
10713522Snatevoid g_io_schedule_down(struct thread *tp);
10814224Spetervoid g_io_schedule_up(struct thread *tp);
10914224Speter
11011151Sjoerg/* geom_kern.c / geom_kernsim.c */
1112443Sdgvoid g_init(void);
1128025Sache
11311151Sjoerg/* geom_ctl.c */
11411151Sjoergvoid g_ctl_init(void);
1151849Swollman