]>
Commit | Line | Data |
---|---|---|
428870ff BB |
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 (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 | */ | |
24 | ||
0c66c32d | 25 | #include <sys/zfs_context.h> |
428870ff BB |
26 | #include <sys/vnode.h> |
27 | #include <sys/sa.h> | |
28 | #include <sys/zfs_acl.h> | |
29 | #include <sys/zfs_sa.h> | |
30 | ||
31 | /* | |
32 | * ZPL attribute registration table. | |
33 | * Order of attributes doesn't matter | |
34 | * a unique value will be assigned for each | |
35 | * attribute that is file system specific | |
36 | * | |
37 | * This is just the set of ZPL attributes that this | |
38 | * version of ZFS deals with natively. The file system | |
39 | * could have other attributes stored in files, but they will be | |
40 | * ignored. The SA framework will preserve them, just that | |
41 | * this version of ZFS won't change or delete them. | |
42 | */ | |
43 | ||
44 | sa_attr_reg_t zfs_attr_table[ZPL_END+1] = { | |
45 | {"ZPL_ATIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 0}, | |
46 | {"ZPL_MTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 1}, | |
47 | {"ZPL_CTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 2}, | |
48 | {"ZPL_CRTIME", sizeof (uint64_t) * 2, SA_UINT64_ARRAY, 3}, | |
49 | {"ZPL_GEN", sizeof (uint64_t), SA_UINT64_ARRAY, 4}, | |
50 | {"ZPL_MODE", sizeof (uint64_t), SA_UINT64_ARRAY, 5}, | |
51 | {"ZPL_SIZE", sizeof (uint64_t), SA_UINT64_ARRAY, 6}, | |
52 | {"ZPL_PARENT", sizeof (uint64_t), SA_UINT64_ARRAY, 7}, | |
53 | {"ZPL_LINKS", sizeof (uint64_t), SA_UINT64_ARRAY, 8}, | |
54 | {"ZPL_XATTR", sizeof (uint64_t), SA_UINT64_ARRAY, 9}, | |
55 | {"ZPL_RDEV", sizeof (uint64_t), SA_UINT64_ARRAY, 10}, | |
56 | {"ZPL_FLAGS", sizeof (uint64_t), SA_UINT64_ARRAY, 11}, | |
57 | {"ZPL_UID", sizeof (uint64_t), SA_UINT64_ARRAY, 12}, | |
58 | {"ZPL_GID", sizeof (uint64_t), SA_UINT64_ARRAY, 13}, | |
59 | {"ZPL_PAD", sizeof (uint64_t) * 4, SA_UINT64_ARRAY, 14}, | |
60 | {"ZPL_ZNODE_ACL", 88, SA_UINT8_ARRAY, 15}, | |
61 | {"ZPL_DACL_COUNT", sizeof (uint64_t), SA_UINT64_ARRAY, 0}, | |
62 | {"ZPL_SYMLINK", 0, SA_UINT8_ARRAY, 0}, | |
63 | {"ZPL_SCANSTAMP", 32, SA_UINT8_ARRAY, 0}, | |
64 | {"ZPL_DACL_ACES", 0, SA_ACL, 0}, | |
82a37189 | 65 | {"ZPL_DXATTR", 0, SA_UINT8_ARRAY, 0}, |
428870ff BB |
66 | {NULL, 0, 0, 0} |
67 | }; | |
68 | ||
69 | #ifdef _KERNEL | |
428870ff BB |
70 | int |
71 | zfs_sa_readlink(znode_t *zp, uio_t *uio) | |
72 | { | |
73 | dmu_buf_t *db = sa_get_db(zp->z_sa_hdl); | |
74 | size_t bufsz; | |
75 | int error; | |
76 | ||
77 | bufsz = zp->z_size; | |
78 | if (bufsz + ZFS_OLD_ZNODE_PHYS_SIZE <= db->db_size) { | |
79 | error = uiomove((caddr_t)db->db_data + | |
80 | ZFS_OLD_ZNODE_PHYS_SIZE, | |
81 | MIN((size_t)bufsz, uio->uio_resid), UIO_READ, uio); | |
82 | } else { | |
83 | dmu_buf_t *dbp; | |
3558fd73 | 84 | if ((error = dmu_buf_hold(ZTOZSB(zp)->z_os, zp->z_id, |
428870ff BB |
85 | 0, FTAG, &dbp, DMU_READ_NO_PREFETCH)) == 0) { |
86 | error = uiomove(dbp->db_data, | |
87 | MIN((size_t)bufsz, uio->uio_resid), UIO_READ, uio); | |
88 | dmu_buf_rele(dbp, FTAG); | |
89 | } | |
90 | } | |
91 | return (error); | |
92 | } | |
93 | ||
94 | void | |
95 | zfs_sa_symlink(znode_t *zp, char *link, int len, dmu_tx_t *tx) | |
96 | { | |
97 | dmu_buf_t *db = sa_get_db(zp->z_sa_hdl); | |
98 | ||
99 | if (ZFS_OLD_ZNODE_PHYS_SIZE + len <= dmu_bonus_max()) { | |
50c957f7 | 100 | VERIFY0(dmu_set_bonus(db, len + ZFS_OLD_ZNODE_PHYS_SIZE, tx)); |
428870ff BB |
101 | if (len) { |
102 | bcopy(link, (caddr_t)db->db_data + | |
103 | ZFS_OLD_ZNODE_PHYS_SIZE, len); | |
104 | } | |
105 | } else { | |
106 | dmu_buf_t *dbp; | |
107 | ||
108 | zfs_grow_blocksize(zp, len, tx); | |
50c957f7 NB |
109 | VERIFY0(dmu_buf_hold(ZTOZSB(zp)->z_os, zp->z_id, 0, FTAG, &dbp, |
110 | DMU_READ_NO_PREFETCH)); | |
428870ff BB |
111 | |
112 | dmu_buf_will_dirty(dbp, tx); | |
113 | ||
114 | ASSERT3U(len, <=, dbp->db_size); | |
115 | bcopy(link, dbp->db_data, len); | |
116 | dmu_buf_rele(dbp, FTAG); | |
117 | } | |
118 | } | |
119 | ||
120 | void | |
121 | zfs_sa_get_scanstamp(znode_t *zp, xvattr_t *xvap) | |
122 | { | |
0037b49e | 123 | zfsvfs_t *zfsvfs = ZTOZSB(zp); |
428870ff BB |
124 | xoptattr_t *xoap; |
125 | ||
572e2857 | 126 | ASSERT(MUTEX_HELD(&zp->z_lock)); |
428870ff BB |
127 | VERIFY((xoap = xva_getxoptattr(xvap)) != NULL); |
128 | if (zp->z_is_sa) { | |
0037b49e | 129 | if (sa_lookup(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs), |
428870ff BB |
130 | &xoap->xoa_av_scanstamp, |
131 | sizeof (xoap->xoa_av_scanstamp)) != 0) | |
132 | return; | |
133 | } else { | |
134 | dmu_object_info_t doi; | |
135 | dmu_buf_t *db = sa_get_db(zp->z_sa_hdl); | |
136 | int len; | |
137 | ||
138 | if (!(zp->z_pflags & ZFS_BONUS_SCANSTAMP)) | |
139 | return; | |
140 | ||
141 | sa_object_info(zp->z_sa_hdl, &doi); | |
142 | len = sizeof (xoap->xoa_av_scanstamp) + | |
143 | ZFS_OLD_ZNODE_PHYS_SIZE; | |
144 | ||
145 | if (len <= doi.doi_bonus_size) { | |
146 | (void) memcpy(xoap->xoa_av_scanstamp, | |
147 | (caddr_t)db->db_data + ZFS_OLD_ZNODE_PHYS_SIZE, | |
148 | sizeof (xoap->xoa_av_scanstamp)); | |
149 | } | |
150 | } | |
151 | XVA_SET_RTN(xvap, XAT_AV_SCANSTAMP); | |
152 | } | |
153 | ||
154 | void | |
155 | zfs_sa_set_scanstamp(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx) | |
156 | { | |
0037b49e | 157 | zfsvfs_t *zfsvfs = ZTOZSB(zp); |
428870ff BB |
158 | xoptattr_t *xoap; |
159 | ||
572e2857 | 160 | ASSERT(MUTEX_HELD(&zp->z_lock)); |
428870ff BB |
161 | VERIFY((xoap = xva_getxoptattr(xvap)) != NULL); |
162 | if (zp->z_is_sa) | |
0037b49e | 163 | VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs), |
428870ff BB |
164 | &xoap->xoa_av_scanstamp, |
165 | sizeof (xoap->xoa_av_scanstamp), tx)); | |
166 | else { | |
167 | dmu_object_info_t doi; | |
168 | dmu_buf_t *db = sa_get_db(zp->z_sa_hdl); | |
169 | int len; | |
170 | ||
171 | sa_object_info(zp->z_sa_hdl, &doi); | |
172 | len = sizeof (xoap->xoa_av_scanstamp) + | |
173 | ZFS_OLD_ZNODE_PHYS_SIZE; | |
174 | if (len > doi.doi_bonus_size) | |
175 | VERIFY(dmu_set_bonus(db, len, tx) == 0); | |
176 | (void) memcpy((caddr_t)db->db_data + ZFS_OLD_ZNODE_PHYS_SIZE, | |
177 | xoap->xoa_av_scanstamp, sizeof (xoap->xoa_av_scanstamp)); | |
178 | ||
179 | zp->z_pflags |= ZFS_BONUS_SCANSTAMP; | |
0037b49e | 180 | VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_FLAGS(zfsvfs), |
428870ff BB |
181 | &zp->z_pflags, sizeof (uint64_t), tx)); |
182 | } | |
183 | } | |
184 | ||
82a37189 BB |
185 | int |
186 | zfs_sa_get_xattr(znode_t *zp) | |
187 | { | |
0037b49e | 188 | zfsvfs_t *zfsvfs = ZTOZSB(zp); |
82a37189 BB |
189 | char *obj; |
190 | int size; | |
191 | int error; | |
192 | ||
193 | ASSERT(RW_LOCK_HELD(&zp->z_xattr_lock)); | |
194 | ASSERT(!zp->z_xattr_cached); | |
195 | ASSERT(zp->z_is_sa); | |
196 | ||
0037b49e | 197 | error = sa_size(zp->z_sa_hdl, SA_ZPL_DXATTR(zfsvfs), &size); |
82a37189 BB |
198 | if (error) { |
199 | if (error == ENOENT) | |
200 | return nvlist_alloc(&zp->z_xattr_cached, | |
201 | NV_UNIQUE_NAME, KM_SLEEP); | |
202 | else | |
203 | return (error); | |
204 | } | |
205 | ||
a3fd9d9e | 206 | obj = vmem_alloc(size, KM_SLEEP); |
82a37189 | 207 | |
0037b49e | 208 | error = sa_lookup(zp->z_sa_hdl, SA_ZPL_DXATTR(zfsvfs), obj, size); |
82a37189 BB |
209 | if (error == 0) |
210 | error = nvlist_unpack(obj, size, &zp->z_xattr_cached, KM_SLEEP); | |
211 | ||
a3fd9d9e | 212 | vmem_free(obj, size); |
82a37189 BB |
213 | |
214 | return (error); | |
215 | } | |
216 | ||
217 | int | |
218 | zfs_sa_set_xattr(znode_t *zp) | |
219 | { | |
0037b49e | 220 | zfsvfs_t *zfsvfs = ZTOZSB(zp); |
82a37189 BB |
221 | dmu_tx_t *tx; |
222 | char *obj; | |
223 | size_t size; | |
224 | int error; | |
225 | ||
226 | ASSERT(RW_WRITE_HELD(&zp->z_xattr_lock)); | |
227 | ASSERT(zp->z_xattr_cached); | |
228 | ASSERT(zp->z_is_sa); | |
229 | ||
230 | error = nvlist_size(zp->z_xattr_cached, &size, NV_ENCODE_XDR); | |
43b4935e | 231 | if ((error == 0) && (size > SA_ATTR_MAX_LEN)) |
ecb2b7dc | 232 | error = SET_ERROR(EFBIG); |
82a37189 BB |
233 | if (error) |
234 | goto out; | |
235 | ||
a3fd9d9e | 236 | obj = vmem_alloc(size, KM_SLEEP); |
82a37189 BB |
237 | |
238 | error = nvlist_pack(zp->z_xattr_cached, &obj, &size, | |
239 | NV_ENCODE_XDR, KM_SLEEP); | |
240 | if (error) | |
241 | goto out_free; | |
242 | ||
0037b49e | 243 | tx = dmu_tx_create(zfsvfs->z_os); |
82a37189 | 244 | dmu_tx_hold_sa_create(tx, size); |
f828e63a | 245 | dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_TRUE); |
82a37189 BB |
246 | |
247 | error = dmu_tx_assign(tx, TXG_WAIT); | |
248 | if (error) { | |
249 | dmu_tx_abort(tx); | |
250 | } else { | |
0037b49e | 251 | VERIFY0(sa_update(zp->z_sa_hdl, SA_ZPL_DXATTR(zfsvfs), |
43b4935e NB |
252 | obj, size, tx)); |
253 | dmu_tx_commit(tx); | |
82a37189 BB |
254 | } |
255 | out_free: | |
a3fd9d9e | 256 | vmem_free(obj, size); |
82a37189 BB |
257 | out: |
258 | return (error); | |
259 | } | |
260 | ||
428870ff BB |
261 | /* |
262 | * I'm not convinced we should do any of this upgrade. | |
263 | * since the SA code can read both old/new znode formats | |
d3cc8b15 | 264 | * with probably little to no performance difference. |
428870ff BB |
265 | * |
266 | * All new files will be created with the new format. | |
267 | */ | |
268 | ||
269 | void | |
270 | zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) | |
271 | { | |
272 | dmu_buf_t *db = sa_get_db(hdl); | |
273 | znode_t *zp = sa_get_userdata(hdl); | |
0037b49e | 274 | zfsvfs_t *zfsvfs = ZTOZSB(zp); |
428870ff | 275 | int count = 0; |
1ee1b767 | 276 | sa_bulk_attr_t *bulk, *sa_attrs; |
428870ff | 277 | zfs_acl_locator_cb_t locate = { 0 }; |
278f2236 | 278 | uint64_t uid, gid, mode, rdev, xattr, parent, tmp_gen; |
0df9673f | 279 | uint64_t crtime[2], mtime[2], ctime[2], atime[2]; |
dfbc8630 | 280 | uint64_t links; |
428870ff BB |
281 | zfs_acl_phys_t znode_acl; |
282 | char scanstamp[AV_SCANSTAMP_SZ]; | |
572e2857 | 283 | boolean_t drop_lock = B_FALSE; |
428870ff BB |
284 | |
285 | /* | |
286 | * No upgrade if ACL isn't cached | |
287 | * since we won't know which locks are held | |
288 | * and ready the ACL would require special "locked" | |
289 | * interfaces that would be messy | |
290 | */ | |
3558fd73 | 291 | if (zp->z_acl_cached == NULL || S_ISLNK(ZTOI(zp)->i_mode)) |
428870ff BB |
292 | return; |
293 | ||
572e2857 BB |
294 | /* |
295 | * If the z_lock is held and we aren't the owner | |
296 | * the just return since we don't want to deadlock | |
297 | * trying to update the status of z_is_sa. This | |
298 | * file can then be upgraded at a later time. | |
299 | * | |
300 | * Otherwise, we know we are doing the | |
301 | * sa_update() that caused us to enter this function. | |
302 | */ | |
c25b8f99 | 303 | if (MUTEX_NOT_HELD(&zp->z_lock)) { |
572e2857 BB |
304 | if (mutex_tryenter(&zp->z_lock) == 0) |
305 | return; | |
306 | else | |
307 | drop_lock = B_TRUE; | |
308 | } | |
309 | ||
428870ff | 310 | /* First do a bulk query of the attributes that aren't cached */ |
d1d7e268 | 311 | bulk = kmem_alloc(sizeof (sa_bulk_attr_t) * 20, KM_SLEEP); |
0037b49e BB |
312 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL, &atime, 16); |
313 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16); | |
314 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16); | |
315 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL, &crtime, 16); | |
316 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8); | |
317 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_PARENT(zfsvfs), NULL, &parent, 8); | |
318 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_XATTR(zfsvfs), NULL, &xattr, 8); | |
319 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_RDEV(zfsvfs), NULL, &rdev, 8); | |
320 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zfsvfs), NULL, &uid, 8); | |
321 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zfsvfs), NULL, &gid, 8); | |
322 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GEN(zfsvfs), NULL, &tmp_gen, 8); | |
323 | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ZNODE_ACL(zfsvfs), NULL, | |
428870ff BB |
324 | &znode_acl, 88); |
325 | ||
1ee1b767 | 326 | if (sa_bulk_lookup_locked(hdl, bulk, count) != 0) { |
d1d7e268 | 327 | kmem_free(bulk, sizeof (sa_bulk_attr_t) * 20); |
572e2857 | 328 | goto done; |
1ee1b767 | 329 | } |
428870ff BB |
330 | |
331 | /* | |
332 | * While the order here doesn't matter its best to try and organize | |
333 | * it is such a way to pick up an already existing layout number | |
334 | */ | |
335 | count = 0; | |
d1d7e268 | 336 | sa_attrs = kmem_zalloc(sizeof (sa_bulk_attr_t) * 20, KM_SLEEP); |
0037b49e BB |
337 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8); |
338 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_SIZE(zfsvfs), NULL, | |
428870ff | 339 | &zp->z_size, 8); |
0037b49e BB |
340 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_GEN(zfsvfs), |
341 | NULL, &tmp_gen, 8); | |
342 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_UID(zfsvfs), NULL, &uid, 8); | |
343 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_GID(zfsvfs), NULL, &gid, 8); | |
344 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_PARENT(zfsvfs), | |
428870ff | 345 | NULL, &parent, 8); |
0037b49e | 346 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_FLAGS(zfsvfs), NULL, |
428870ff | 347 | &zp->z_pflags, 8); |
0037b49e | 348 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_ATIME(zfsvfs), NULL, |
0df9673f | 349 | &atime, 16); |
0037b49e | 350 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_MTIME(zfsvfs), NULL, |
428870ff | 351 | &mtime, 16); |
0037b49e | 352 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_CTIME(zfsvfs), NULL, |
428870ff | 353 | &ctime, 16); |
0037b49e | 354 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_CRTIME(zfsvfs), NULL, |
428870ff | 355 | &crtime, 16); |
dfbc8630 | 356 | links = ZTOI(zp)->i_nlink; |
0037b49e | 357 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_LINKS(zfsvfs), NULL, |
dfbc8630 | 358 | &links, 8); |
3558fd73 | 359 | if (S_ISBLK(ZTOI(zp)->i_mode) || S_ISCHR(ZTOI(zp)->i_mode)) |
0037b49e | 360 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_RDEV(zfsvfs), NULL, |
428870ff | 361 | &rdev, 8); |
0037b49e | 362 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_DACL_COUNT(zfsvfs), NULL, |
428870ff BB |
363 | &zp->z_acl_cached->z_acl_count, 8); |
364 | ||
365 | if (zp->z_acl_cached->z_version < ZFS_ACL_VERSION_FUID) | |
366 | zfs_acl_xform(zp, zp->z_acl_cached, CRED()); | |
367 | ||
368 | locate.cb_aclp = zp->z_acl_cached; | |
0037b49e | 369 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_DACL_ACES(zfsvfs), |
428870ff | 370 | zfs_acl_data_locator, &locate, zp->z_acl_cached->z_acl_bytes); |
572e2857 | 371 | |
428870ff | 372 | if (xattr) |
0037b49e | 373 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_XATTR(zfsvfs), |
572e2857 | 374 | NULL, &xattr, 8); |
428870ff BB |
375 | |
376 | /* if scanstamp then add scanstamp */ | |
377 | ||
378 | if (zp->z_pflags & ZFS_BONUS_SCANSTAMP) { | |
379 | bcopy((caddr_t)db->db_data + ZFS_OLD_ZNODE_PHYS_SIZE, | |
380 | scanstamp, AV_SCANSTAMP_SZ); | |
0037b49e | 381 | SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_SCANSTAMP(zfsvfs), |
428870ff BB |
382 | NULL, scanstamp, AV_SCANSTAMP_SZ); |
383 | zp->z_pflags &= ~ZFS_BONUS_SCANSTAMP; | |
384 | } | |
385 | ||
386 | VERIFY(dmu_set_bonustype(db, DMU_OT_SA, tx) == 0); | |
387 | VERIFY(sa_replace_all_by_template_locked(hdl, sa_attrs, | |
388 | count, tx) == 0); | |
389 | if (znode_acl.z_acl_extern_obj) | |
0037b49e | 390 | VERIFY(0 == dmu_object_free(zfsvfs->z_os, |
428870ff BB |
391 | znode_acl.z_acl_extern_obj, tx)); |
392 | ||
393 | zp->z_is_sa = B_TRUE; | |
d1d7e268 MK |
394 | kmem_free(sa_attrs, sizeof (sa_bulk_attr_t) * 20); |
395 | kmem_free(bulk, sizeof (sa_bulk_attr_t) * 20); | |
572e2857 BB |
396 | done: |
397 | if (drop_lock) | |
398 | mutex_exit(&zp->z_lock); | |
428870ff BB |
399 | } |
400 | ||
401 | void | |
402 | zfs_sa_upgrade_txholds(dmu_tx_t *tx, znode_t *zp) | |
403 | { | |
3558fd73 | 404 | if (!ZTOZSB(zp)->z_use_sa || zp->z_is_sa) |
428870ff BB |
405 | return; |
406 | ||
428870ff BB |
407 | |
408 | dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_TRUE); | |
409 | ||
572e2857 BB |
410 | if (zfs_external_acl(zp)) { |
411 | dmu_tx_hold_free(tx, zfs_external_acl(zp), 0, | |
428870ff BB |
412 | DMU_OBJECT_END); |
413 | } | |
414 | } | |
415 | ||
e29be02e | 416 | EXPORT_SYMBOL(zfs_attr_table); |
e45aa452 BB |
417 | EXPORT_SYMBOL(zfs_sa_readlink); |
418 | EXPORT_SYMBOL(zfs_sa_symlink); | |
419 | EXPORT_SYMBOL(zfs_sa_get_scanstamp); | |
420 | EXPORT_SYMBOL(zfs_sa_set_scanstamp); | |
82a37189 BB |
421 | EXPORT_SYMBOL(zfs_sa_get_xattr); |
422 | EXPORT_SYMBOL(zfs_sa_set_xattr); | |
e45aa452 BB |
423 | EXPORT_SYMBOL(zfs_sa_upgrade); |
424 | EXPORT_SYMBOL(zfs_sa_upgrade_txholds); | |
425 | ||
428870ff | 426 | #endif |