4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 */
25
26 #ifndef _SYS_SA_IMPL_H
27 #define _SYS_SA_IMPL_H
28
29 #include <sys/dmu.h>
30 #include <sys/refcount.h>
31 #include <sys/list.h>
32
33 /*
34 * Array of known attributes and their
35 * various characteristics.
36 */
37 typedef struct sa_attr_table {
38 sa_attr_type_t sa_attr;
39 uint8_t sa_registered;
40 uint16_t sa_length;
41 sa_bswap_type_t sa_byteswap;
42 char *sa_name;
43 } sa_attr_table_t;
193 typedef enum sa_buf_type {
194 SA_BONUS = 1,
195 SA_SPILL = 2
196 } sa_buf_type_t;
197
198 typedef enum sa_data_op {
199 SA_LOOKUP,
200 SA_UPDATE,
201 SA_ADD,
202 SA_REPLACE,
203 SA_REMOVE
204 } sa_data_op_t;
205
206 /*
207 * Opaque handle used for most sa functions
208 *
209 * This needs to be kept as small as possible.
210 */
211
212 struct sa_handle {
213 kmutex_t sa_lock;
214 dmu_buf_t *sa_bonus;
215 dmu_buf_t *sa_spill;
216 objset_t *sa_os;
217 void *sa_userp;
218 sa_idx_tab_t *sa_bonus_tab; /* idx of bonus */
219 sa_idx_tab_t *sa_spill_tab; /* only present if spill activated */
220 };
221
222 #define SA_GET_DB(hdl, type) \
223 (dmu_buf_impl_t *)((type == SA_BONUS) ? hdl->sa_bonus : hdl->sa_spill)
224
225 #define SA_GET_HDR(hdl, type) \
226 ((sa_hdr_phys_t *)((dmu_buf_impl_t *)(SA_GET_DB(hdl, \
227 type))->db.db_data))
228
229 #define SA_IDX_TAB_GET(hdl, type) \
230 (type == SA_BONUS ? hdl->sa_bonus_tab : hdl->sa_spill_tab)
231
232 #define IS_SA_BONUSTYPE(a) \
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
25 */
26
27 #ifndef _SYS_SA_IMPL_H
28 #define _SYS_SA_IMPL_H
29
30 #include <sys/dmu.h>
31 #include <sys/refcount.h>
32 #include <sys/list.h>
33
34 /*
35 * Array of known attributes and their
36 * various characteristics.
37 */
38 typedef struct sa_attr_table {
39 sa_attr_type_t sa_attr;
40 uint8_t sa_registered;
41 uint16_t sa_length;
42 sa_bswap_type_t sa_byteswap;
43 char *sa_name;
44 } sa_attr_table_t;
194 typedef enum sa_buf_type {
195 SA_BONUS = 1,
196 SA_SPILL = 2
197 } sa_buf_type_t;
198
199 typedef enum sa_data_op {
200 SA_LOOKUP,
201 SA_UPDATE,
202 SA_ADD,
203 SA_REPLACE,
204 SA_REMOVE
205 } sa_data_op_t;
206
207 /*
208 * Opaque handle used for most sa functions
209 *
210 * This needs to be kept as small as possible.
211 */
212
213 struct sa_handle {
214 dmu_buf_user_t sa_dbu;
215 kmutex_t sa_lock;
216 dmu_buf_t *sa_bonus;
217 dmu_buf_t *sa_spill;
218 objset_t *sa_os;
219 void *sa_userp;
220 sa_idx_tab_t *sa_bonus_tab; /* idx of bonus */
221 sa_idx_tab_t *sa_spill_tab; /* only present if spill activated */
222 };
223
224 #define SA_GET_DB(hdl, type) \
225 (dmu_buf_impl_t *)((type == SA_BONUS) ? hdl->sa_bonus : hdl->sa_spill)
226
227 #define SA_GET_HDR(hdl, type) \
228 ((sa_hdr_phys_t *)((dmu_buf_impl_t *)(SA_GET_DB(hdl, \
229 type))->db.db_data))
230
231 #define SA_IDX_TAB_GET(hdl, type) \
232 (type == SA_BONUS ? hdl->sa_bonus_tab : hdl->sa_spill_tab)
233
234 #define IS_SA_BONUSTYPE(a) \
|