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