94 * attribues. The new attribute will be appended to the end of the already
95 * existing attributes.
96 *
97 * Both the attribute registration and attribute layout information are
98 * stored in normal ZAP attributes. Their should be a small number of
99 * known layouts and the set of attributes is assumed to typically be quite
100 * small.
101 *
102 * The registered attributes and layout "table" information is maintained
103 * in core and a special "sa_os_t" is attached to the objset_t.
104 *
105 * A special interface is provided to allow for quickly applying
106 * a large set of attributes at once. sa_replace_all_by_template() is
107 * used to set an array of attributes. This is used by the ZPL when
108 * creating a brand new file. The template that is passed into the function
109 * specifies the attribute, size for variable length attributes, location of
110 * data and special "data locator" function if the data isn't in a contiguous
111 * location.
112 *
113 * Byteswap implications:
114 * Since the SA attributes are not entirely self describing we can't do
115 * the normal byteswap processing. The special ZAP layout attribute and
116 * attribute registration attributes define the byteswap function and the
117 * size of the attributes, unless it is variable sized.
118 * The normal ZFS byteswapping infrastructure assumes you don't need
119 * to read any objects in order to do the necessary byteswapping. Whereas
120 * SA attributes can only be properly byteswapped if the dataset is opened
121 * and the layout/attribute ZAP attributes are available. Because of this
122 * the SA attributes will be byteswapped when they are first accessed by
123 * the SA code that will read the SA data.
124 */
125
126 typedef void (sa_iterfunc_t)(void *hdr, void *addr, sa_attr_type_t,
127 uint16_t length, int length_idx, boolean_t, void *userp);
128
129 static int sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype);
130 static void sa_idx_tab_hold(objset_t *os, sa_idx_tab_t *idx_tab);
131 static void *sa_find_idx_tab(objset_t *os, dmu_object_type_t bonustype,
132 void *data);
133 static void sa_idx_tab_rele(objset_t *os, void *arg);
172 sa_attr_reg_t sa_legacy_attrs[] = {
173 {"ZPL_ATIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 0},
174 {"ZPL_MTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 1},
175 {"ZPL_CTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 2},
176 {"ZPL_CRTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 3},
177 {"ZPL_GEN", sizeof (uint64_t), SA_UINT64_ARRAY, 4},
178 {"ZPL_MODE", sizeof (uint64_t), SA_UINT64_ARRAY, 5},
179 {"ZPL_SIZE", sizeof (uint64_t), SA_UINT64_ARRAY, 6},
180 {"ZPL_PARENT", sizeof (uint64_t), SA_UINT64_ARRAY, 7},
181 {"ZPL_LINKS", sizeof (uint64_t), SA_UINT64_ARRAY, 8},
182 {"ZPL_XATTR", sizeof (uint64_t), SA_UINT64_ARRAY, 9},
183 {"ZPL_RDEV", sizeof (uint64_t), SA_UINT64_ARRAY, 10},
184 {"ZPL_FLAGS", sizeof (uint64_t), SA_UINT64_ARRAY, 11},
185 {"ZPL_UID", sizeof (uint64_t), SA_UINT64_ARRAY, 12},
186 {"ZPL_GID", sizeof (uint64_t), SA_UINT64_ARRAY, 13},
187 {"ZPL_PAD", sizeof (uint64_t) * 4, SA_UINT64_ARRAY, 14},
188 {"ZPL_ZNODE_ACL", 88, SA_UINT8_ARRAY, 15},
189 };
190
191 /*
192 * ZPL legacy layout
193 * This is only used for objects of type DMU_OT_ZNODE
194 */
195 sa_attr_type_t sa_legacy_zpl_layout[] = {
196 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
197 };
198
199 /*
200 * Special dummy layout used for buffers with no attributes.
201 */
202
203 sa_attr_type_t sa_dummy_zpl_layout[] = { 0 };
204
205 static int sa_legacy_attr_count = 16;
206 static kmem_cache_t *sa_cache = NULL;
207
208 /*ARGSUSED*/
209 static int
210 sa_cache_constructor(void *buf, void *unused, int kmflag)
211 {
212 sa_handle_t *hdl = buf;
213
214 hdl->sa_bonus_tab = NULL;
215 hdl->sa_spill_tab = NULL;
216 hdl->sa_os = NULL;
217 hdl->sa_userp = NULL;
218 hdl->sa_bonus = NULL;
219 hdl->sa_spill = NULL;
220 mutex_init(&hdl->sa_lock, NULL, MUTEX_DEFAULT, NULL);
221 return (0);
222 }
|
94 * attribues. The new attribute will be appended to the end of the already
95 * existing attributes.
96 *
97 * Both the attribute registration and attribute layout information are
98 * stored in normal ZAP attributes. Their should be a small number of
99 * known layouts and the set of attributes is assumed to typically be quite
100 * small.
101 *
102 * The registered attributes and layout "table" information is maintained
103 * in core and a special "sa_os_t" is attached to the objset_t.
104 *
105 * A special interface is provided to allow for quickly applying
106 * a large set of attributes at once. sa_replace_all_by_template() is
107 * used to set an array of attributes. This is used by the ZPL when
108 * creating a brand new file. The template that is passed into the function
109 * specifies the attribute, size for variable length attributes, location of
110 * data and special "data locator" function if the data isn't in a contiguous
111 * location.
112 *
113 * Byteswap implications:
114 *
115 * Since the SA attributes are not entirely self describing we can't do
116 * the normal byteswap processing. The special ZAP layout attribute and
117 * attribute registration attributes define the byteswap function and the
118 * size of the attributes, unless it is variable sized.
119 * The normal ZFS byteswapping infrastructure assumes you don't need
120 * to read any objects in order to do the necessary byteswapping. Whereas
121 * SA attributes can only be properly byteswapped if the dataset is opened
122 * and the layout/attribute ZAP attributes are available. Because of this
123 * the SA attributes will be byteswapped when they are first accessed by
124 * the SA code that will read the SA data.
125 */
126
127 typedef void (sa_iterfunc_t)(void *hdr, void *addr, sa_attr_type_t,
128 uint16_t length, int length_idx, boolean_t, void *userp);
129
130 static int sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype);
131 static void sa_idx_tab_hold(objset_t *os, sa_idx_tab_t *idx_tab);
132 static void *sa_find_idx_tab(objset_t *os, dmu_object_type_t bonustype,
133 void *data);
134 static void sa_idx_tab_rele(objset_t *os, void *arg);
173 sa_attr_reg_t sa_legacy_attrs[] = {
174 {"ZPL_ATIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 0},
175 {"ZPL_MTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 1},
176 {"ZPL_CTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 2},
177 {"ZPL_CRTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 3},
178 {"ZPL_GEN", sizeof (uint64_t), SA_UINT64_ARRAY, 4},
179 {"ZPL_MODE", sizeof (uint64_t), SA_UINT64_ARRAY, 5},
180 {"ZPL_SIZE", sizeof (uint64_t), SA_UINT64_ARRAY, 6},
181 {"ZPL_PARENT", sizeof (uint64_t), SA_UINT64_ARRAY, 7},
182 {"ZPL_LINKS", sizeof (uint64_t), SA_UINT64_ARRAY, 8},
183 {"ZPL_XATTR", sizeof (uint64_t), SA_UINT64_ARRAY, 9},
184 {"ZPL_RDEV", sizeof (uint64_t), SA_UINT64_ARRAY, 10},
185 {"ZPL_FLAGS", sizeof (uint64_t), SA_UINT64_ARRAY, 11},
186 {"ZPL_UID", sizeof (uint64_t), SA_UINT64_ARRAY, 12},
187 {"ZPL_GID", sizeof (uint64_t), SA_UINT64_ARRAY, 13},
188 {"ZPL_PAD", sizeof (uint64_t) * 4, SA_UINT64_ARRAY, 14},
189 {"ZPL_ZNODE_ACL", 88, SA_UINT8_ARRAY, 15},
190 };
191
192 /*
193 * This is only used for objects of type DMU_OT_ZNODE
194 */
195 sa_attr_type_t sa_legacy_zpl_layout[] = {
196 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
197 };
198
199 /*
200 * Special dummy layout used for buffers with no attributes.
201 */
202 sa_attr_type_t sa_dummy_zpl_layout[] = { 0 };
203
204 static int sa_legacy_attr_count = 16;
205 static kmem_cache_t *sa_cache = NULL;
206
207 /*ARGSUSED*/
208 static int
209 sa_cache_constructor(void *buf, void *unused, int kmflag)
210 {
211 sa_handle_t *hdl = buf;
212
213 hdl->sa_bonus_tab = NULL;
214 hdl->sa_spill_tab = NULL;
215 hdl->sa_os = NULL;
216 hdl->sa_userp = NULL;
217 hdl->sa_bonus = NULL;
218 hdl->sa_spill = NULL;
219 mutex_init(&hdl->sa_lock, NULL, MUTEX_DEFAULT, NULL);
220 return (0);
221 }
|