geom_int.h revision 110759
168651Skris/*-
268651Skris * Copyright (c) 2002 Poul-Henning Kamp
368651Skris * Copyright (c) 2002 Networks Associates Technology, Inc.
468651Skris * All rights reserved.
568651Skris *
668651Skris * This software was developed for the FreeBSD Project by Poul-Henning Kamp
768651Skris * and NAI Labs, the Security Research Division of Network Associates, Inc.
868651Skris * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
968651Skris * DARPA CHATS research program.
1068651Skris *
1168651Skris * Redistribution and use in source and binary forms, with or without
1268651Skris * modification, are permitted provided that the following conditions
1368651Skris * are met:
1468651Skris * 1. Redistributions of source code must retain the above copyright
1568651Skris *    notice, this list of conditions and the following disclaimer.
1668651Skris * 2. Redistributions in binary form must reproduce the above copyright
1768651Skris *    notice, this list of conditions and the following disclaimer in the
18109998Smarkm *    documentation and/or other materials provided with the distribution.
1968651Skris * 3. The names of the authors may not be used to endorse or promote
2068651Skris *    products derived from this software without specific prior written
2168651Skris *    permission.
2268651Skris *
2368651Skris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2468651Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2668651Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2768651Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28109998Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2968651Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3168651Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3268651Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33109998Smarkm * SUCH DAMAGE.
3468651Skris *
3568651Skris * $FreeBSD: head/sys/geom/geom_int.h 110759 2003-02-12 09:48:27Z phk $
36109998Smarkm */
3768651Skris
38109998SmarkmLIST_HEAD(class_list_head, g_class);
39109998SmarkmTAILQ_HEAD(g_tailq_head, g_geom);
4068651SkrisTAILQ_HEAD(event_tailq_head, g_event);
4168651Skris
4268651Skrisextern struct event_tailq_head events;
4368651Skrisextern int g_collectstats;
4468651Skrisextern int g_debugflags;
4568651Skris/*
4668651Skris * 1	G_T_TOPOLOGY
4768651Skris * 2	G_T_BIO
4868651Skris * 4	G_T_ACCESS
4968651Skris * 8	enable sanity checks
5068651Skris * 16	Allow footshooting on rank#1 providers
5168651Skris */
5268651Skris
5368651Skris/*
5468651Skris * Various internal actions are tracked by tagging g_event[s] onto
55109998Smarkm * an internal eventqueue.
5668651Skris */
57109998Smarkmenum g_events {
58109998Smarkm	EV_NEW_CLASS,		/* class */
5968651Skris	EV_NEW_PROVIDER,	/* provider */
6068651Skris	EV_SPOILED,		/* provider, consumer */
6168651Skris	EV_CALL_ME,		/* func, arg */
6268651Skris	EV_LAST
6368651Skris};
6468651Skris
6568651Skrisstruct g_event {
6668651Skris	enum g_events 		event;
6768651Skris	TAILQ_ENTRY(g_event)	events;
6868651Skris	struct g_class		*class;
6968651Skris	struct g_geom		*geom;
7068651Skris	struct g_provider	*provider;
7168651Skris	struct g_consumer	*consumer;
7268651Skris	void			*arg;
7368651Skris	g_call_me_t		*func;
7468651Skris};
7568651Skris
7668651Skris/*
7768651Skris * We actually have a number of drivers sharing the same major number
7868651Skris * so we coordinate the major/minor usage here
7968651Skris */
8068651Skris#define GEOM_MAJOR		4
8168651Skris#define GEOM_MINOR_STATS	0
8268651Skris#define GEOM_MINOR_PROVIDERS	10
8368651Skris
8468651Skris/* geom_dump.c */
8568651Skrisvoid g_confxml(void *);
8668651Skrisvoid g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
8768651Skrisvoid g_confdot(void *);
8868651Skrisvoid g_conftxt(void *);
8968651Skris
9068651Skris/* geom_event.c */
9168651Skrisvoid g_event_init(void);
9268651Skrisvoid g_post_event(enum g_events ev, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
9368651Skrisvoid g_run_events(void);
9468651Skris
95109998Smarkm/* geom_subr.c */
9668651Skrisextern struct class_list_head g_classes;
9768651Skrisextern char *g_wait_event, *g_wait_sim, *g_wait_up, *g_wait_down;
9868651Skris
9968651Skris/* geom_io.c */
10068651Skrisvoid g_io_init(void);
10168651Skrisvoid g_io_schedule_down(struct thread *tp);
10268651Skrisvoid g_io_schedule_up(struct thread *tp);
10368651Skris
10468651Skris/* geom_kern.c / geom_kernsim.c */
10568651Skrisvoid g_init(void);
10668651Skris
10768651Skris/* geom_stats.c */
10868651Skrisvoid g_stat_init(void);
10968651Skrisstruct g_stat *g_stat_new(void *id);
11068651Skrisvoid g_stat_delete(struct g_stat *);
11168651Skris