xref: /illumos-gate/usr/src/lib/libpool/common/pool_kernel_impl.h (revision 7dbbfe7762f9eabac3999ee1a8b38311d428f7a8)
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 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * This file contains the definitions of types and supporting
36  * functions to implement the libpool kernel specific data
37  * manipulation facility.
38  *
39  * For more information on the libpool generic data manipulation
40  * facility, look at pool_impl.h.
41  *
42  * The central types for the generic data representation/storage
43  * facility are here enhanced to provide additional kernel specific
44  * information.
45  */
46 
47 /*
48  * pool_knl_elem_t is the kernel specific representation of the
49  * pool_elem_t structure.
50  */
51 typedef struct pool_knl_elem {
52 	/*
53 	 * Common to pool_elem_t
54 	 */
55 	pool_elem_t pke_elem;
56 	void *pke_pad1;
57 	void *pke_pad2;
58 	/*
59 	 * Common to pool_knl_elem_t
60 	 */
61 	nvlist_t *pke_properties;			/* Properties nvlist */
62 	struct pool_knl_elem *pke_parent;		/* Element parent */
63 	uint64_t pke_ltime;				/* Library timestamp */
64 } pool_knl_elem_t;
65 
66 typedef pool_knl_elem_t pool_knl_system_t;
67 
68 typedef struct pool_knl_resource {
69 	/*
70 	 * Common to pool_elem_t
71 	 */
72 	pool_elem_t pke_elem;
73 	/*
74 	 * Specific to pool_resource_t
75 	 */
76 	int (*pr_is_system)(const pool_resource_t *);
77 	int (*pr_can_associate)(const pool_resource_t *);
78 	/*
79 	 * Common to pool_knl_elem_t
80 	 */
81 	nvlist_t *pke_properties;			/* Properties nvlist */
82 	struct pool_knl_elem *pke_parent;		/* Element parent */
83 	uint64_t pke_ltime;				/* Library timestamp */
84 } pool_knl_resource_t;
85 
86 typedef pool_knl_elem_t pool_knl_component_t;
87 
88 typedef struct pool_knl_pool {
89 	/*
90 	 * Common to pool_elem_t
91 	 */
92 	pool_elem_t pke_elem;
93 	/*
94 	 * Specific to pool_t
95 	 */
96 	int (*pp_associate)(pool_t *, const pool_resource_t *);
97 	int (*pp_dissociate)(pool_t *, const pool_resource_t *);
98 	/*
99 	 * Common to pool_knl_elem_t
100 	 */
101 	nvlist_t *pke_properties;			/* Properties nvlist */
102 	struct pool_knl_elem *pke_parent;		/* Element parent */
103 	uint64_t pke_ltime;				/* Library timestamp */
104 	/*
105 	 * Specific to pool_knl_pool_t
106 	 */
107 	pool_knl_resource_t *pkp_assoc[4];		/* Pool resources */
108 } pool_knl_pool_t;
109 
110 /*
111  * pool_knl_result_set_t is the kernel specific representation of the
112  * pool_result_set_t structure.
113  *
114  */
115 typedef struct pool_knl_result_set {
116 	const pool_conf_t *prs_conf;			/* Configuration */
117 	int prs_active;					/* Query active? */
118 	int prs_index;					/* Result Index */
119 	pool_elem_t *(*prs_next)(pool_result_set_t *);
120 	pool_elem_t *(*prs_prev)(pool_result_set_t *);
121 	pool_elem_t *(*prs_first)(pool_result_set_t *);
122 	pool_elem_t *(*prs_last)(pool_result_set_t *);
123 	int (*prs_set_index)(pool_result_set_t *, int);
124 	int (*prs_get_index)(pool_result_set_t *);
125 	int (*prs_close)(pool_result_set_t *);
126 	int (*prs_count)(pool_result_set_t *);
127 	/*
128 	 * End of common part
129 	 */
130 	pool_knl_elem_t **pkr_list;			/* Result members */
131 	int pkr_count;					/* Result set count */
132 	int pkr_size;					/* Result set size */
133 } pool_knl_result_set_t;
134 
135 /*
136  * pool_knl_connection_t is the kernel specific representation of the
137  * pool_connection_t structure.
138  *
139  */
140 typedef struct pool_knl_connection {
141 	const char *pc_name;				/* Provider name */
142 	int pc_store_type;				/* Datastore type */
143 	int pc_oflags;					/* Open flags */
144 	int (*pc_close)(pool_conf_t *);
145 	int (*pc_validate)(const pool_conf_t *, pool_valid_level_t);
146 	int (*pc_commit)(pool_conf_t *);
147 	int (*pc_export)(const pool_conf_t *, const char *,
148 	    pool_export_format_t);
149 	int (*pc_rollback)(pool_conf_t *);
150 	pool_result_set_t *(*pc_exec_query)(const pool_conf_t *,
151 	    const pool_elem_t *, const char *,
152 	    pool_elem_class_t, pool_value_t **);
153 	pool_elem_t *(*pc_elem_create)(pool_conf_t *, pool_elem_class_t,
154 	    pool_resource_elem_class_t, pool_component_elem_class_t);
155 	int (*pc_remove)(pool_conf_t *);
156 	int (*pc_res_xfer)(pool_resource_t *, pool_resource_t *, uint64_t);
157 	int (*pc_res_xxfer)(pool_resource_t *, pool_resource_t *,
158 	    pool_component_t **);
159 	char *(*pc_get_binding)(pool_conf_t *, pid_t);
160 	int (*pc_set_binding)(pool_conf_t *, const char *, idtype_t, id_t);
161 	char *(*pc_get_resource_binding)(pool_conf_t *,
162 	    pool_resource_elem_class_t, pid_t);
163 	/*
164 	 * End of common part
165 	 */
166 	int pkc_fd;					/* Pool device */
167 	dict_hdl_t *pkc_elements;			/* Elements */
168 #if DEBUG
169 	dict_hdl_t *pkc_leaks;				/* Elements */
170 #endif	/* DEBUG */
171 	log_t *pkc_log;					/* Transaction log */
172 	hrtime_t pkc_ltime;				/* Snap updated */
173 	hrtime_t pkc_lotime;				/* Snap last updated */
174 } pool_knl_connection_t;
175 
176 #ifdef	__cplusplus
177 }
178 #endif
179 
180 #endif	/* _POOL_KERNEL_IMPL_H */
181