FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 /* 00022 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 00023 */ 00024 00025 #ifndef _SYS_SA_H 00026 #define _SYS_SA_H 00027 00028 #include <sys/dmu.h> 00029 #include <sys/uio.h> 00030 00039 typedef enum sa_bswap_type { 00040 SA_UINT64_ARRAY, 00041 SA_UINT32_ARRAY, 00042 SA_UINT16_ARRAY, 00043 SA_UINT8_ARRAY, 00044 SA_ACL, 00045 } sa_bswap_type_t; 00046 00047 typedef uint16_t sa_attr_type_t; 00048 00052 typedef struct sa_attr_reg { 00053 char *sa_name; 00054 uint16_t sa_length; 00055 sa_bswap_type_t sa_byteswap; 00056 sa_attr_type_t sa_attr; 00057 } sa_attr_reg_t; 00058 00059 00060 typedef void (sa_data_locator_t)(void **, uint32_t *, uint32_t, 00061 boolean_t, void *userptr); 00062 00075 typedef struct sa_bulk_attr { 00076 void *sa_data; 00077 sa_data_locator_t *sa_data_func; 00078 uint16_t sa_length; 00079 sa_attr_type_t sa_attr; 00080 /* the following are private to the sa framework */ 00081 void *sa_addr; 00082 uint16_t sa_buftype; 00083 uint16_t sa_size; 00084 } sa_bulk_attr_t; 00085 00086 00097 #define SA_ADD_BULK_ATTR(b, idx, attr, func, data, len) \ 00098 { \ 00099 b[idx].sa_attr = attr;\ 00100 b[idx].sa_data_func = func; \ 00101 b[idx].sa_data = data; \ 00102 b[idx++].sa_length = len; \ 00103 } 00104 00105 typedef struct sa_os sa_os_t; 00106 00107 typedef enum sa_handle_type { 00108 SA_HDL_SHARED, 00109 SA_HDL_PRIVATE 00110 } sa_handle_type_t; 00111 00112 struct sa_handle; 00113 typedef void *sa_lookup_tab_t; 00114 typedef struct sa_handle sa_handle_t; 00115 00116 typedef void (sa_update_cb_t)(sa_handle_t *, dmu_tx_t *tx); 00117 00118 int sa_handle_get(objset_t *, uint64_t, void *userp, 00119 sa_handle_type_t, sa_handle_t **); 00120 int sa_handle_get_from_db(objset_t *, dmu_buf_t *, void *userp, 00121 sa_handle_type_t, sa_handle_t **); 00122 void sa_handle_destroy(sa_handle_t *); 00123 int sa_buf_hold(objset_t *, uint64_t, void *, dmu_buf_t **); 00124 void sa_buf_rele(dmu_buf_t *, void *); 00125 int sa_lookup(sa_handle_t *, sa_attr_type_t, void *buf, uint32_t buflen); 00126 int sa_update(sa_handle_t *, sa_attr_type_t, void *buf, 00127 uint32_t buflen, dmu_tx_t *); 00128 int sa_remove(sa_handle_t *, sa_attr_type_t, dmu_tx_t *); 00129 int sa_bulk_lookup(sa_handle_t *, sa_bulk_attr_t *, int count); 00130 int sa_bulk_lookup_locked(sa_handle_t *, sa_bulk_attr_t *, int count); 00131 int sa_bulk_update(sa_handle_t *, sa_bulk_attr_t *, int count, dmu_tx_t *); 00132 int sa_size(sa_handle_t *, sa_attr_type_t, int *); 00133 int sa_update_from_cb(sa_handle_t *, sa_attr_type_t, 00134 uint32_t buflen, sa_data_locator_t *, void *userdata, dmu_tx_t *); 00135 void sa_object_info(sa_handle_t *, dmu_object_info_t *); 00136 void sa_object_size(sa_handle_t *, uint32_t *, u_longlong_t *); 00137 void sa_update_user(sa_handle_t *, sa_handle_t *); 00138 void *sa_get_userdata(sa_handle_t *); 00139 void sa_set_userp(sa_handle_t *, void *); 00140 dmu_buf_t *sa_get_db(sa_handle_t *); 00141 uint64_t sa_handle_object(sa_handle_t *); 00142 boolean_t sa_attr_would_spill(sa_handle_t *, sa_attr_type_t, int size); 00143 void sa_register_update_callback(objset_t *, sa_update_cb_t *); 00144 int sa_setup(objset_t *, uint64_t, sa_attr_reg_t *, int, sa_attr_type_t **); 00145 void sa_tear_down(objset_t *); 00146 int sa_replace_all_by_template(sa_handle_t *, sa_bulk_attr_t *, 00147 int, dmu_tx_t *); 00148 int sa_replace_all_by_template_locked(sa_handle_t *, sa_bulk_attr_t *, 00149 int, dmu_tx_t *); 00150 boolean_t sa_enabled(objset_t *); 00151 void sa_cache_init(); 00152 void sa_cache_fini(); 00153 int sa_set_sa_object(objset_t *, uint64_t); 00154 int sa_hdrsize(void *); 00155 void sa_handle_lock(sa_handle_t *); 00156 void sa_handle_unlock(sa_handle_t *); 00157 00158 #ifdef _KERNEL 00159 int sa_lookup_uio(sa_handle_t *, sa_attr_type_t, uio_t *); 00160 #endif 00161 00162 #ifdef __cplusplus 00163 extern "C" { 00164 #endif 00165 00166 00167 #ifdef __cplusplus 00168 } 00169 #endif 00170 00171 #endif /* _SYS_SA_H */