1277487Skib/*-
2277487Skib * Copyright (c) 2002 Poul-Henning Kamp
3277487Skib * Copyright (c) 2002 Networks Associates Technology, Inc.
4277487Skib * All rights reserved.
5277487Skib *
6277487Skib * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7277487Skib * and NAI Labs, the Security Research Division of Network Associates, Inc.
8277487Skib * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
9277487Skib * DARPA CHATS research program.
10277487Skib *
11277487Skib * Redistribution and use in source and binary forms, with or without
12277487Skib * modification, are permitted provided that the following conditions
13277487Skib * are met:
14277487Skib * 1. Redistributions of source code must retain the above copyright
15277487Skib *    notice, this list of conditions and the following disclaimer.
16277487Skib * 2. Redistributions in binary form must reproduce the above copyright
17277487Skib *    notice, this list of conditions and the following disclaimer in the
18277487Skib *    documentation and/or other materials provided with the distribution.
19277487Skib * 3. The names of the authors may not be used to endorse or promote
20277487Skib *    products derived from this software without specific prior written
21277487Skib *    permission.
22277487Skib *
23277487Skib * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24277487Skib * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25277487Skib * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26277487Skib * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27277487Skib * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28277487Skib * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29277487Skib * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30277487Skib * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31277487Skib * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32277487Skib * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33277487Skib * SUCH DAMAGE.
34277487Skib *
35277487Skib * $FreeBSD$
36277487Skib */
37277487Skib
38277487Skib#ifndef _GEOM_GEOM_SLICE_H_
39277487Skib#define _GEOM_GEOM_SLICE_H_
40277487Skib
41277487Skibstruct g_slice {
42277487Skib	off_t	offset;
43277487Skib	off_t	length;
44277487Skib	u_int	sectorsize;
45277487Skib	struct	g_provider *provider;
46277487Skib};
47277487Skib
48277487Skibstruct g_slice_hot {
49277487Skib	off_t	offset;
50277487Skib	off_t	length;
51277487Skib	int	ract;
52277487Skib	int	dact;
53277487Skib	int	wact;
54277487Skib};
55277487Skib
56277487Skibtypedef int g_slice_start_t (struct bio *bp);
57277487Skib
58277487Skibstruct g_slicer {
59277487Skib	u_int			nslice;
60277487Skib	u_int			nprovider;
61277487Skib	struct g_slice		*slices;
62277487Skib
63277487Skib	u_int			nhotspot;
64277487Skib	struct g_slice_hot	*hotspot;
65277487Skib
66277487Skib	void			*softc;
67277487Skib	g_slice_start_t		*start;
68277487Skib	g_event_t		*hot;
69277487Skib};
70277487Skib
71277487Skibg_dumpconf_t g_slice_dumpconf;
72277487Skibint 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);
73277487Skibvoid g_slice_spoiled(struct g_consumer *cp);
74277487Skibvoid g_slice_orphan(struct g_consumer *cp);
75277487Skib#define G_SLICE_CONFIG_CHECK	0
76277487Skib#define G_SLICE_CONFIG_SET	1
77277487Skib#define G_SLICE_CONFIG_FORCE	2
78277487Skibstruct 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);
79277487Skib
80277487Skibint g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length, int ract, int dact, int wact);
81277487Skib#define G_SLICE_HOT_ALLOW	1
82277487Skib#define G_SLICE_HOT_DENY	2
83277487Skib#define G_SLICE_HOT_START	4
84277487Skib#define G_SLICE_HOT_CALL	8
85277487Skib
86277487Skibint g_slice_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp);
87277487Skib
88277487Skibvoid g_slice_finish_hot(struct bio *bp);
89277487Skib
90277487Skib#endif /* _GEOM_GEOM_SLICE_H_ */
91277487Skib