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