111935SMark.Shellenbaum@Sun.COM /* 211935SMark.Shellenbaum@Sun.COM * CDDL HEADER START 311935SMark.Shellenbaum@Sun.COM * 411935SMark.Shellenbaum@Sun.COM * The contents of this file are subject to the terms of the 511935SMark.Shellenbaum@Sun.COM * Common Development and Distribution License (the "License"). 611935SMark.Shellenbaum@Sun.COM * You may not use this file except in compliance with the License. 711935SMark.Shellenbaum@Sun.COM * 811935SMark.Shellenbaum@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 911935SMark.Shellenbaum@Sun.COM * or http://www.opensolaris.org/os/licensing. 1011935SMark.Shellenbaum@Sun.COM * See the License for the specific language governing permissions 1111935SMark.Shellenbaum@Sun.COM * and limitations under the License. 1211935SMark.Shellenbaum@Sun.COM * 1311935SMark.Shellenbaum@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 1411935SMark.Shellenbaum@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1511935SMark.Shellenbaum@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 1611935SMark.Shellenbaum@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 1711935SMark.Shellenbaum@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 1811935SMark.Shellenbaum@Sun.COM * 1911935SMark.Shellenbaum@Sun.COM * CDDL HEADER END 2011935SMark.Shellenbaum@Sun.COM */ 2111935SMark.Shellenbaum@Sun.COM /* 22*12493SMark.Shellenbaum@Oracle.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2311935SMark.Shellenbaum@Sun.COM */ 2411935SMark.Shellenbaum@Sun.COM 2511935SMark.Shellenbaum@Sun.COM #ifndef _SYS_SA_H 2611935SMark.Shellenbaum@Sun.COM #define _SYS_SA_H 2711935SMark.Shellenbaum@Sun.COM 2811935SMark.Shellenbaum@Sun.COM #include <sys/dmu.h> 2911935SMark.Shellenbaum@Sun.COM 3011935SMark.Shellenbaum@Sun.COM /* 3111935SMark.Shellenbaum@Sun.COM * Currently available byteswap functions. 3211935SMark.Shellenbaum@Sun.COM * If it all possible new attributes should used 3311935SMark.Shellenbaum@Sun.COM * one of the already defined byteswap functions. 3411935SMark.Shellenbaum@Sun.COM * If a new byteswap function is added then the 3511935SMark.Shellenbaum@Sun.COM * ZPL/Pool version will need to be bumped. 3611935SMark.Shellenbaum@Sun.COM */ 3711935SMark.Shellenbaum@Sun.COM 3811935SMark.Shellenbaum@Sun.COM typedef enum sa_bswap_type { 3911935SMark.Shellenbaum@Sun.COM SA_UINT64_ARRAY, 4011935SMark.Shellenbaum@Sun.COM SA_UINT32_ARRAY, 4111935SMark.Shellenbaum@Sun.COM SA_UINT16_ARRAY, 4211935SMark.Shellenbaum@Sun.COM SA_UINT8_ARRAY, 4311935SMark.Shellenbaum@Sun.COM SA_ACL, 4411935SMark.Shellenbaum@Sun.COM } sa_bswap_type_t; 4511935SMark.Shellenbaum@Sun.COM 4611935SMark.Shellenbaum@Sun.COM typedef uint16_t sa_attr_type_t; 4711935SMark.Shellenbaum@Sun.COM 4811935SMark.Shellenbaum@Sun.COM /* 4911935SMark.Shellenbaum@Sun.COM * Attribute to register support for. 5011935SMark.Shellenbaum@Sun.COM */ 5111935SMark.Shellenbaum@Sun.COM typedef struct sa_attr_reg { 5211935SMark.Shellenbaum@Sun.COM char *sa_name; /* attribute name */ 5311935SMark.Shellenbaum@Sun.COM uint16_t sa_length; 5411935SMark.Shellenbaum@Sun.COM sa_bswap_type_t sa_byteswap; /* bswap functon enum */ 5511935SMark.Shellenbaum@Sun.COM sa_attr_type_t sa_attr; /* filled in during registration */ 5611935SMark.Shellenbaum@Sun.COM } sa_attr_reg_t; 5711935SMark.Shellenbaum@Sun.COM 5811935SMark.Shellenbaum@Sun.COM 5911935SMark.Shellenbaum@Sun.COM typedef void (sa_data_locator_t)(void **, uint32_t *, uint32_t, 6011935SMark.Shellenbaum@Sun.COM boolean_t, void *userptr); 6111935SMark.Shellenbaum@Sun.COM 6211935SMark.Shellenbaum@Sun.COM /* 6311935SMark.Shellenbaum@Sun.COM * array of attributes to store. 6411935SMark.Shellenbaum@Sun.COM * 6511935SMark.Shellenbaum@Sun.COM * This array should be treated as opaque/private data. 6611935SMark.Shellenbaum@Sun.COM * The SA_BULK_ADD_ATTR() macro should be used for manipulating 6711935SMark.Shellenbaum@Sun.COM * the array. 6811935SMark.Shellenbaum@Sun.COM * 6911935SMark.Shellenbaum@Sun.COM * When sa_replace_all_by_template() is used the attributes 7011935SMark.Shellenbaum@Sun.COM * will be stored in the order defined in the array, except that 7111935SMark.Shellenbaum@Sun.COM * the attributes may be split between the bonus and the spill buffer 7211935SMark.Shellenbaum@Sun.COM * 7311935SMark.Shellenbaum@Sun.COM */ 7411935SMark.Shellenbaum@Sun.COM typedef struct sa_bulk_attr { 7511935SMark.Shellenbaum@Sun.COM void *sa_data; 7611935SMark.Shellenbaum@Sun.COM sa_data_locator_t *sa_data_func; 7711935SMark.Shellenbaum@Sun.COM uint16_t sa_length; 7811935SMark.Shellenbaum@Sun.COM sa_attr_type_t sa_attr; 7911935SMark.Shellenbaum@Sun.COM /* the following are private to the sa framework */ 8011935SMark.Shellenbaum@Sun.COM void *sa_addr; 8111935SMark.Shellenbaum@Sun.COM uint16_t sa_buftype; 8211935SMark.Shellenbaum@Sun.COM uint16_t sa_size; 8311935SMark.Shellenbaum@Sun.COM } sa_bulk_attr_t; 8411935SMark.Shellenbaum@Sun.COM 8511935SMark.Shellenbaum@Sun.COM 8611935SMark.Shellenbaum@Sun.COM /* 8711935SMark.Shellenbaum@Sun.COM * special macro for adding entries for bulk attr support 8811935SMark.Shellenbaum@Sun.COM * bulk - sa_bulk_attr_t 8911935SMark.Shellenbaum@Sun.COM * count - integer that will be incremented during each add 9011935SMark.Shellenbaum@Sun.COM * attr - attribute to manipulate 9111935SMark.Shellenbaum@Sun.COM * func - function for accessing data. 9211935SMark.Shellenbaum@Sun.COM * data - pointer to data. 9311935SMark.Shellenbaum@Sun.COM * len - length of data 9411935SMark.Shellenbaum@Sun.COM */ 9511935SMark.Shellenbaum@Sun.COM 9611935SMark.Shellenbaum@Sun.COM #define SA_ADD_BULK_ATTR(b, idx, attr, func, data, len) \ 9711935SMark.Shellenbaum@Sun.COM { \ 9811935SMark.Shellenbaum@Sun.COM b[idx].sa_attr = attr;\ 9911935SMark.Shellenbaum@Sun.COM b[idx].sa_data_func = func; \ 10011935SMark.Shellenbaum@Sun.COM b[idx].sa_data = data; \ 10111935SMark.Shellenbaum@Sun.COM b[idx++].sa_length = len; \ 10211935SMark.Shellenbaum@Sun.COM } 10311935SMark.Shellenbaum@Sun.COM 10411935SMark.Shellenbaum@Sun.COM typedef struct sa_os sa_os_t; 10511935SMark.Shellenbaum@Sun.COM 10611935SMark.Shellenbaum@Sun.COM typedef enum sa_handle_type { 10711935SMark.Shellenbaum@Sun.COM SA_HDL_SHARED, 10811935SMark.Shellenbaum@Sun.COM SA_HDL_PRIVATE 10911935SMark.Shellenbaum@Sun.COM } sa_handle_type_t; 11011935SMark.Shellenbaum@Sun.COM 11111935SMark.Shellenbaum@Sun.COM struct sa_handle; 11211935SMark.Shellenbaum@Sun.COM typedef void *sa_lookup_tab_t; 11311935SMark.Shellenbaum@Sun.COM typedef struct sa_handle sa_handle_t; 11411935SMark.Shellenbaum@Sun.COM 11511935SMark.Shellenbaum@Sun.COM typedef void (sa_update_cb_t)(sa_handle_t *, dmu_tx_t *tx); 11611935SMark.Shellenbaum@Sun.COM 11711935SMark.Shellenbaum@Sun.COM int sa_handle_get(objset_t *, uint64_t, void *userp, 11811935SMark.Shellenbaum@Sun.COM sa_handle_type_t, sa_handle_t **); 11911935SMark.Shellenbaum@Sun.COM int sa_handle_get_from_db(objset_t *, dmu_buf_t *, void *userp, 12011935SMark.Shellenbaum@Sun.COM sa_handle_type_t, sa_handle_t **); 12111935SMark.Shellenbaum@Sun.COM void sa_handle_destroy(sa_handle_t *); 12211935SMark.Shellenbaum@Sun.COM int sa_buf_hold(objset_t *, uint64_t, void *, dmu_buf_t **); 12311935SMark.Shellenbaum@Sun.COM void sa_buf_rele(dmu_buf_t *, void *); 12411935SMark.Shellenbaum@Sun.COM int sa_lookup(sa_handle_t *, sa_attr_type_t, void *buf, uint32_t buflen); 12511935SMark.Shellenbaum@Sun.COM int sa_update(sa_handle_t *, sa_attr_type_t, void *buf, 12611935SMark.Shellenbaum@Sun.COM uint32_t buflen, dmu_tx_t *); 12711935SMark.Shellenbaum@Sun.COM int sa_remove(sa_handle_t *, sa_attr_type_t, dmu_tx_t *); 12811935SMark.Shellenbaum@Sun.COM int sa_bulk_lookup(sa_handle_t *, sa_bulk_attr_t *, int count); 12911935SMark.Shellenbaum@Sun.COM int sa_bulk_lookup_locked(sa_handle_t *, sa_bulk_attr_t *, int count); 13011935SMark.Shellenbaum@Sun.COM int sa_bulk_update(sa_handle_t *, sa_bulk_attr_t *, int count, dmu_tx_t *); 13111935SMark.Shellenbaum@Sun.COM int sa_size(sa_handle_t *, sa_attr_type_t, int *); 13211935SMark.Shellenbaum@Sun.COM int sa_update_from_cb(sa_handle_t *, sa_attr_type_t, 13311935SMark.Shellenbaum@Sun.COM uint32_t buflen, sa_data_locator_t *, void *userdata, dmu_tx_t *); 13411935SMark.Shellenbaum@Sun.COM void sa_object_info(sa_handle_t *, dmu_object_info_t *); 13511935SMark.Shellenbaum@Sun.COM void sa_object_size(sa_handle_t *, uint32_t *, u_longlong_t *); 13611935SMark.Shellenbaum@Sun.COM void sa_update_user(sa_handle_t *, sa_handle_t *); 13711935SMark.Shellenbaum@Sun.COM void *sa_get_userdata(sa_handle_t *); 13811935SMark.Shellenbaum@Sun.COM void sa_set_userp(sa_handle_t *, void *); 13911935SMark.Shellenbaum@Sun.COM dmu_buf_t *sa_get_db(sa_handle_t *); 14011935SMark.Shellenbaum@Sun.COM uint64_t sa_handle_object(sa_handle_t *); 14111935SMark.Shellenbaum@Sun.COM boolean_t sa_attr_would_spill(sa_handle_t *, sa_attr_type_t, int size); 14211935SMark.Shellenbaum@Sun.COM void sa_register_update_callback(objset_t *, sa_update_cb_t *); 143*12493SMark.Shellenbaum@Oracle.COM int sa_setup(objset_t *, uint64_t, sa_attr_reg_t *, int, sa_attr_type_t **); 14411935SMark.Shellenbaum@Sun.COM void sa_tear_down(objset_t *); 14511935SMark.Shellenbaum@Sun.COM int sa_replace_all_by_template(sa_handle_t *, sa_bulk_attr_t *, 14611935SMark.Shellenbaum@Sun.COM int, dmu_tx_t *); 14711935SMark.Shellenbaum@Sun.COM int sa_replace_all_by_template_locked(sa_handle_t *, sa_bulk_attr_t *, 14811935SMark.Shellenbaum@Sun.COM int, dmu_tx_t *); 14911935SMark.Shellenbaum@Sun.COM boolean_t sa_enabled(objset_t *); 15011935SMark.Shellenbaum@Sun.COM void sa_cache_init(); 15111935SMark.Shellenbaum@Sun.COM void sa_cache_fini(); 15211935SMark.Shellenbaum@Sun.COM int sa_set_sa_object(objset_t *, uint64_t); 15311935SMark.Shellenbaum@Sun.COM int sa_hdrsize(void *); 15411935SMark.Shellenbaum@Sun.COM void sa_handle_lock(sa_handle_t *); 15511935SMark.Shellenbaum@Sun.COM void sa_handle_unlock(sa_handle_t *); 15611935SMark.Shellenbaum@Sun.COM 15711935SMark.Shellenbaum@Sun.COM #ifdef _KERNEL 15811935SMark.Shellenbaum@Sun.COM int sa_lookup_uio(sa_handle_t *, sa_attr_type_t, uio_t *); 15911935SMark.Shellenbaum@Sun.COM #endif 16011935SMark.Shellenbaum@Sun.COM 16111935SMark.Shellenbaum@Sun.COM #ifdef __cplusplus 16211935SMark.Shellenbaum@Sun.COM extern "C" { 16311935SMark.Shellenbaum@Sun.COM #endif 16411935SMark.Shellenbaum@Sun.COM 16511935SMark.Shellenbaum@Sun.COM 16611935SMark.Shellenbaum@Sun.COM #ifdef __cplusplus 16711935SMark.Shellenbaum@Sun.COM } 16811935SMark.Shellenbaum@Sun.COM #endif 16911935SMark.Shellenbaum@Sun.COM 17011935SMark.Shellenbaum@Sun.COM #endif /* _SYS_SA_H */ 171