geom_int.h revision 112876
193250Sphk/*-
293250Sphk * Copyright (c) 2002 Poul-Henning Kamp
393250Sphk * Copyright (c) 2002 Networks Associates Technology, Inc.
493250Sphk * All rights reserved.
593250Sphk *
693250Sphk * This software was developed for the FreeBSD Project by Poul-Henning Kamp
793250Sphk * and NAI Labs, the Security Research Division of Network Associates, Inc.
893250Sphk * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
993250Sphk * DARPA CHATS research program.
1093250Sphk *
1193250Sphk * Redistribution and use in source and binary forms, with or without
1293250Sphk * modification, are permitted provided that the following conditions
1393250Sphk * are met:
1493250Sphk * 1. Redistributions of source code must retain the above copyright
1593250Sphk *    notice, this list of conditions and the following disclaimer.
1693250Sphk * 2. Redistributions in binary form must reproduce the above copyright
1793250Sphk *    notice, this list of conditions and the following disclaimer in the
1893250Sphk *    documentation and/or other materials provided with the distribution.
1993250Sphk * 3. The names of the authors may not be used to endorse or promote
2093250Sphk *    products derived from this software without specific prior written
2193250Sphk *    permission.
2293250Sphk *
2393250Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2493250Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2593250Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2693250Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2793250Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2893250Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2993250Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3093250Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3193250Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3293250Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3393250Sphk * SUCH DAMAGE.
3493250Sphk *
3593250Sphk * $FreeBSD: head/sys/geom/geom_int.h 112876 2003-03-31 18:35:37Z phk $
3693250Sphk */
3793250Sphk
3893250SphkLIST_HEAD(class_list_head, g_class);
3993250SphkTAILQ_HEAD(g_tailq_head, g_geom);
4093250SphkTAILQ_HEAD(event_tailq_head, g_event);
4193250Sphk
4293250Sphkextern struct event_tailq_head events;
43110523Sphkextern int g_collectstats;
4493250Sphkextern int g_debugflags;
45110759Sphk/*
46110759Sphk * 1	G_T_TOPOLOGY
47110759Sphk * 2	G_T_BIO
48110759Sphk * 4	G_T_ACCESS
49112476Sphk * 8	Enable sanity checks
50110759Sphk * 16	Allow footshooting on rank#1 providers
51112476Sphk * 32	G_T_DETAILS
52110759Sphk */
53112476Sphk#define G_F_DISKIOCTL	64
54112876Sphk#define G_F_CTLDUMP	128
5593250Sphk
56112476Sphk
5793250Sphk/*
5893250Sphk * Various internal actions are tracked by tagging g_event[s] onto
5993250Sphk * an internal eventqueue.
6093250Sphk */
6193250Sphkenum g_events {
6293250Sphk	EV_NEW_CLASS,		/* class */
6393250Sphk	EV_NEW_PROVIDER,	/* provider */
6493250Sphk	EV_SPOILED,		/* provider, consumer */
65104056Sphk	EV_CALL_ME,		/* func, arg */
6693250Sphk	EV_LAST
6793250Sphk};
6893250Sphk
6993250Sphkstruct g_event {
7093250Sphk	enum g_events 		event;
7193250Sphk	TAILQ_ENTRY(g_event)	events;
7293250Sphk	struct g_class		*class;
7393250Sphk	struct g_geom		*geom;
7493250Sphk	struct g_provider	*provider;
7593250Sphk	struct g_consumer	*consumer;
76104056Sphk	void			*arg;
77104056Sphk	g_call_me_t		*func;
7893250Sphk};
7993250Sphk
80110540Sphk/*
81110540Sphk * We actually have a number of drivers sharing the same major number
82110540Sphk * so we coordinate the major/minor usage here
83110540Sphk */
84110540Sphk#define GEOM_MAJOR		4
85110540Sphk#define GEOM_MINOR_STATS	0
86110540Sphk#define GEOM_MINOR_PROVIDERS	10
87110540Sphk
8893250Sphk/* geom_dump.c */
89104452Sphkvoid g_confxml(void *);
90104452Sphkvoid g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
91104452Sphkvoid g_confdot(void *);
92106101Sphkvoid g_conftxt(void *);
9393250Sphk
9493250Sphk/* geom_event.c */
9593250Sphkvoid g_event_init(void);
9693250Sphkvoid g_post_event(enum g_events ev, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
97112518Sphkvoid g_cancel_event(struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
9893250Sphkvoid g_run_events(void);
99112517Sphkvoid g_stall_events(void);
100112517Sphkvoid g_release_events(void);
10193250Sphk
10293250Sphk/* geom_subr.c */
10393774Sphkextern struct class_list_head g_classes;
10493250Sphkextern char *g_wait_event, *g_wait_sim, *g_wait_up, *g_wait_down;
10593250Sphk
10693250Sphk/* geom_io.c */
10793250Sphkvoid g_io_init(void);
10893250Sphkvoid g_io_schedule_down(struct thread *tp);
10993250Sphkvoid g_io_schedule_up(struct thread *tp);
11093250Sphk
11193250Sphk/* geom_kern.c / geom_kernsim.c */
11293250Sphkvoid g_init(void);
113112534Sphk
114112534Sphk/* geom_ctl.c */
115112534Sphkvoid g_ctl_init(void);
116