1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_POOL_KERNEL_IMPL_H
28*7c478bd9Sstevel@tonic-gate #define	_POOL_KERNEL_IMPL_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
31*7c478bd9Sstevel@tonic-gate extern "C" {
32*7c478bd9Sstevel@tonic-gate #endif
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate  * This file contains the definitions of types and supporting
36*7c478bd9Sstevel@tonic-gate  * functions to implement the libpool kernel specific data
37*7c478bd9Sstevel@tonic-gate  * manipulation facility.
38*7c478bd9Sstevel@tonic-gate  *
39*7c478bd9Sstevel@tonic-gate  * For more information on the libpool generic data manipulation
40*7c478bd9Sstevel@tonic-gate  * facility, look at pool_impl.h.
41*7c478bd9Sstevel@tonic-gate  *
42*7c478bd9Sstevel@tonic-gate  * The central types for the generic data representation/storage
43*7c478bd9Sstevel@tonic-gate  * facility are here enhanced to provide additional kernel specific
44*7c478bd9Sstevel@tonic-gate  * information.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * pool_knl_elem_t is the kernel specific representation of the
49*7c478bd9Sstevel@tonic-gate  * pool_elem_t structure.
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate typedef struct pool_knl_elem {
52*7c478bd9Sstevel@tonic-gate 	/*
53*7c478bd9Sstevel@tonic-gate 	 * Common to pool_elem_t
54*7c478bd9Sstevel@tonic-gate 	 */
55*7c478bd9Sstevel@tonic-gate 	pool_elem_t pke_elem;
56*7c478bd9Sstevel@tonic-gate 	void *pke_pad1;
57*7c478bd9Sstevel@tonic-gate 	void *pke_pad2;
58*7c478bd9Sstevel@tonic-gate 	/*
59*7c478bd9Sstevel@tonic-gate 	 * Common to pool_knl_elem_t
60*7c478bd9Sstevel@tonic-gate 	 */
61*7c478bd9Sstevel@tonic-gate 	nvlist_t *pke_properties;			/* Properties nvlist */
62*7c478bd9Sstevel@tonic-gate 	struct pool_knl_elem *pke_parent;		/* Element parent */
63*7c478bd9Sstevel@tonic-gate 	uint64_t pke_ltime;				/* Library timestamp */
64*7c478bd9Sstevel@tonic-gate } pool_knl_elem_t;
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate typedef pool_knl_elem_t pool_knl_system_t;
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate typedef struct pool_knl_resource {
69*7c478bd9Sstevel@tonic-gate 	/*
70*7c478bd9Sstevel@tonic-gate 	 * Common to pool_elem_t
71*7c478bd9Sstevel@tonic-gate 	 */
72*7c478bd9Sstevel@tonic-gate 	pool_elem_t pke_elem;
73*7c478bd9Sstevel@tonic-gate 	/*
74*7c478bd9Sstevel@tonic-gate 	 * Specific to pool_resource_t
75*7c478bd9Sstevel@tonic-gate 	 */
76*7c478bd9Sstevel@tonic-gate 	int (*pr_is_system)(const pool_resource_t *);
77*7c478bd9Sstevel@tonic-gate 	int (*pr_can_associate)(const pool_resource_t *);
78*7c478bd9Sstevel@tonic-gate 	/*
79*7c478bd9Sstevel@tonic-gate 	 * Common to pool_knl_elem_t
80*7c478bd9Sstevel@tonic-gate 	 */
81*7c478bd9Sstevel@tonic-gate 	nvlist_t *pke_properties;			/* Properties nvlist */
82*7c478bd9Sstevel@tonic-gate 	struct pool_knl_elem *pke_parent;		/* Element parent */
83*7c478bd9Sstevel@tonic-gate 	uint64_t pke_ltime;				/* Library timestamp */
84*7c478bd9Sstevel@tonic-gate } pool_knl_resource_t;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate typedef pool_knl_elem_t pool_knl_component_t;
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate typedef struct pool_knl_pool {
89*7c478bd9Sstevel@tonic-gate 	/*
90*7c478bd9Sstevel@tonic-gate 	 * Common to pool_elem_t
91*7c478bd9Sstevel@tonic-gate 	 */
92*7c478bd9Sstevel@tonic-gate 	pool_elem_t pke_elem;
93*7c478bd9Sstevel@tonic-gate 	/*
94*7c478bd9Sstevel@tonic-gate 	 * Specific to pool_t
95*7c478bd9Sstevel@tonic-gate 	 */
96*7c478bd9Sstevel@tonic-gate 	int (*pp_associate)(pool_t *, const pool_resource_t *);
97*7c478bd9Sstevel@tonic-gate 	int (*pp_dissociate)(pool_t *, const pool_resource_t *);
98*7c478bd9Sstevel@tonic-gate 	/*
99*7c478bd9Sstevel@tonic-gate 	 * Common to pool_knl_elem_t
100*7c478bd9Sstevel@tonic-gate 	 */
101*7c478bd9Sstevel@tonic-gate 	nvlist_t *pke_properties;			/* Properties nvlist */
102*7c478bd9Sstevel@tonic-gate 	struct pool_knl_elem *pke_parent;		/* Element parent */
103*7c478bd9Sstevel@tonic-gate 	uint64_t pke_ltime;				/* Library timestamp */
104*7c478bd9Sstevel@tonic-gate 	/*
105*7c478bd9Sstevel@tonic-gate 	 * Specific to pool_knl_pool_t
106*7c478bd9Sstevel@tonic-gate 	 */
107*7c478bd9Sstevel@tonic-gate 	pool_knl_resource_t *pkp_assoc[4];		/* Pool resources */
108*7c478bd9Sstevel@tonic-gate } pool_knl_pool_t;
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * pool_knl_result_set_t is the kernel specific representation of the
112*7c478bd9Sstevel@tonic-gate  * pool_result_set_t structure.
113*7c478bd9Sstevel@tonic-gate  *
114*7c478bd9Sstevel@tonic-gate  */
115*7c478bd9Sstevel@tonic-gate typedef struct pool_knl_result_set {
116*7c478bd9Sstevel@tonic-gate 	const pool_conf_t *prs_conf;			/* Configuration */
117*7c478bd9Sstevel@tonic-gate 	int prs_active;					/* Query active? */
118*7c478bd9Sstevel@tonic-gate 	int prs_index;					/* Result Index */
119*7c478bd9Sstevel@tonic-gate 	pool_elem_t *(*prs_next)(pool_result_set_t *);
120*7c478bd9Sstevel@tonic-gate 	pool_elem_t *(*prs_prev)(pool_result_set_t *);
121*7c478bd9Sstevel@tonic-gate 	pool_elem_t *(*prs_first)(pool_result_set_t *);
122*7c478bd9Sstevel@tonic-gate 	pool_elem_t *(*prs_last)(pool_result_set_t *);
123*7c478bd9Sstevel@tonic-gate 	int (*prs_set_index)(pool_result_set_t *, int);
124*7c478bd9Sstevel@tonic-gate 	int (*prs_get_index)(pool_result_set_t *);
125*7c478bd9Sstevel@tonic-gate 	int (*prs_close)(pool_result_set_t *);
126*7c478bd9Sstevel@tonic-gate 	int (*prs_count)(pool_result_set_t *);
127*7c478bd9Sstevel@tonic-gate 	/*
128*7c478bd9Sstevel@tonic-gate 	 * End of common part
129*7c478bd9Sstevel@tonic-gate 	 */
130*7c478bd9Sstevel@tonic-gate 	pool_knl_elem_t **pkr_list;			/* Result members */
131*7c478bd9Sstevel@tonic-gate 	int pkr_count;					/* Result set count */
132*7c478bd9Sstevel@tonic-gate 	int pkr_size;					/* Result set size */
133*7c478bd9Sstevel@tonic-gate } pool_knl_result_set_t;
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /*
136*7c478bd9Sstevel@tonic-gate  * pool_knl_connection_t is the kernel specific representation of the
137*7c478bd9Sstevel@tonic-gate  * pool_connection_t structure.
138*7c478bd9Sstevel@tonic-gate  *
139*7c478bd9Sstevel@tonic-gate  */
140*7c478bd9Sstevel@tonic-gate typedef struct pool_knl_connection {
141*7c478bd9Sstevel@tonic-gate 	const char *pc_name;				/* Provider name */
142*7c478bd9Sstevel@tonic-gate 	int pc_store_type;				/* Datastore type */
143*7c478bd9Sstevel@tonic-gate 	int pc_oflags;					/* Open flags */
144*7c478bd9Sstevel@tonic-gate 	int (*pc_close)(pool_conf_t *);
145*7c478bd9Sstevel@tonic-gate 	int (*pc_validate)(const pool_conf_t *, pool_valid_level_t);
146*7c478bd9Sstevel@tonic-gate 	int (*pc_commit)(pool_conf_t *);
147*7c478bd9Sstevel@tonic-gate 	int (*pc_export)(const pool_conf_t *, const char *,
148*7c478bd9Sstevel@tonic-gate 	    pool_export_format_t);
149*7c478bd9Sstevel@tonic-gate 	int (*pc_rollback)(pool_conf_t *);
150*7c478bd9Sstevel@tonic-gate 	pool_result_set_t *(*pc_exec_query)(const pool_conf_t *,
151*7c478bd9Sstevel@tonic-gate 	    const pool_elem_t *, const char *,
152*7c478bd9Sstevel@tonic-gate 	    pool_elem_class_t, pool_value_t **);
153*7c478bd9Sstevel@tonic-gate 	pool_elem_t *(*pc_elem_create)(pool_conf_t *, pool_elem_class_t,
154*7c478bd9Sstevel@tonic-gate 	    pool_resource_elem_class_t, pool_component_elem_class_t);
155*7c478bd9Sstevel@tonic-gate 	int (*pc_remove)(pool_conf_t *);
156*7c478bd9Sstevel@tonic-gate 	int (*pc_res_xfer)(pool_resource_t *, pool_resource_t *, uint64_t);
157*7c478bd9Sstevel@tonic-gate 	int (*pc_res_xxfer)(pool_resource_t *, pool_resource_t *,
158*7c478bd9Sstevel@tonic-gate 	    pool_component_t **);
159*7c478bd9Sstevel@tonic-gate 	char *(*pc_get_binding)(pool_conf_t *, pid_t);
160*7c478bd9Sstevel@tonic-gate 	int (*pc_set_binding)(pool_conf_t *, const char *, idtype_t, id_t);
161*7c478bd9Sstevel@tonic-gate 	char *(*pc_get_resource_binding)(pool_conf_t *,
162*7c478bd9Sstevel@tonic-gate 	    pool_resource_elem_class_t, pid_t);
163*7c478bd9Sstevel@tonic-gate 	/*
164*7c478bd9Sstevel@tonic-gate 	 * End of common part
165*7c478bd9Sstevel@tonic-gate 	 */
166*7c478bd9Sstevel@tonic-gate 	int pkc_fd;					/* Pool device */
167*7c478bd9Sstevel@tonic-gate 	dict_hdl_t *pkc_elements;			/* Elements */
168*7c478bd9Sstevel@tonic-gate #if DEBUG
169*7c478bd9Sstevel@tonic-gate 	dict_hdl_t *pkc_leaks;				/* Elements */
170*7c478bd9Sstevel@tonic-gate #endif	/* DEBUG */
171*7c478bd9Sstevel@tonic-gate 	log_t *pkc_log;					/* Transaction log */
172*7c478bd9Sstevel@tonic-gate 	hrtime_t pkc_ltime;				/* Snap updated */
173*7c478bd9Sstevel@tonic-gate 	hrtime_t pkc_lotime;				/* Snap last updated */
174*7c478bd9Sstevel@tonic-gate } pool_knl_connection_t;
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
177*7c478bd9Sstevel@tonic-gate }
178*7c478bd9Sstevel@tonic-gate #endif
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate #endif	/* _POOL_KERNEL_IMPL_H */
181