192108Sphk/*-
292108Sphk * Copyright (c) 2002 Poul-Henning Kamp
392108Sphk * Copyright (c) 2002 Networks Associates Technology, Inc.
492108Sphk * All rights reserved.
592108Sphk *
692108Sphk * This software was developed for the FreeBSD Project by Poul-Henning Kamp
792108Sphk * and NAI Labs, the Security Research Division of Network Associates, Inc.
892108Sphk * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
992108Sphk * DARPA CHATS research program.
1092108Sphk *
1192108Sphk * Redistribution and use in source and binary forms, with or without
1292108Sphk * modification, are permitted provided that the following conditions
1392108Sphk * are met:
1492108Sphk * 1. Redistributions of source code must retain the above copyright
1592108Sphk *    notice, this list of conditions and the following disclaimer.
1692108Sphk * 2. Redistributions in binary form must reproduce the above copyright
1792108Sphk *    notice, this list of conditions and the following disclaimer in the
1892108Sphk *    documentation and/or other materials provided with the distribution.
1992108Sphk * 3. The names of the authors may not be used to endorse or promote
2092108Sphk *    products derived from this software without specific prior written
2192108Sphk *    permission.
2292108Sphk *
2392108Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2492108Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2592108Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2692108Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2792108Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2892108Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2992108Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3092108Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3192108Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3292108Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3392108Sphk * SUCH DAMAGE.
3492108Sphk *
3592108Sphk * $FreeBSD$
3692108Sphk */
3792108Sphk
38104064Sphk#ifndef _GEOM_GEOM_SLICE_H_
39104064Sphk#define _GEOM_GEOM_SLICE_H_
40104064Sphk
4192108Sphkstruct g_slice {
4292108Sphk	off_t	offset;
4392108Sphk	off_t	length;
44105542Sphk	u_int	sectorsize;
4592108Sphk	struct	g_provider *provider;
4692108Sphk};
4792108Sphk
48113712Sphkstruct g_slice_hot {
49113712Sphk	off_t	offset;
50113712Sphk	off_t	length;
51113713Sphk	int	ract;
52113713Sphk	int	dact;
53113713Sphk	int	wact;
54113712Sphk};
55113712Sphk
5692108Sphktypedef int g_slice_start_t (struct bio *bp);
5792108Sphk
5892108Sphkstruct g_slicer {
59113712Sphk	u_int			nslice;
60113712Sphk	u_int			nprovider;
61113712Sphk	struct g_slice		*slices;
62113713Sphk
63113712Sphk	u_int			nhotspot;
64113712Sphk	struct g_slice_hot	*hotspot;
65113713Sphk
66113712Sphk	void			*softc;
67113712Sphk	g_slice_start_t		*start;
68113937Sphk	g_event_t		*hot;
6992108Sphk};
7092108Sphk
7193776Sphkg_dumpconf_t g_slice_dumpconf;
72243333Sjhint g_slice_config(struct g_geom *gp, u_int idx, int how, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...) __printflike(7, 8);
73114504Sphkvoid g_slice_spoiled(struct g_consumer *cp);
74155802Spjdvoid g_slice_orphan(struct g_consumer *cp);
75104064Sphk#define G_SLICE_CONFIG_CHECK	0
76104064Sphk#define G_SLICE_CONFIG_SET	1
77104064Sphk#define G_SLICE_CONFIG_FORCE	2
78107522Sphkstruct g_geom * g_slice_new(struct g_class *mp, u_int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start);
7992108Sphk
80113713Sphkint g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length, int ract, int dact, int wact);
81113713Sphk#define G_SLICE_HOT_ALLOW	1
82113713Sphk#define G_SLICE_HOT_DENY	2
83113713Sphk#define G_SLICE_HOT_START	4
84113713Sphk#define G_SLICE_HOT_CALL	8
85113713Sphk
86115506Sphkint g_slice_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp);
87115506Sphk
88107522Sphkvoid g_slice_finish_hot(struct bio *bp);
89107522Sphk
90104064Sphk#endif /* _GEOM_GEOM_SLICE_H_ */
91