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.
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.
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]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2015, 2018 by Delphix. All rights reserved.
27 #include <sys/types.h>
28 #include <sys/param.h>
29 #include <sys/sysmacros.h>
30 #include <sys/cmn_err.h>
32 #include <sys/thread.h>
35 #include <sys/zfs_znode.h>
36 #include <sys/zfs_dir.h>
38 #include <sys/zil_impl.h>
39 #include <sys/byteorder.h>
40 #include <sys/policy.h>
46 #include <sys/zfs_fuid.h>
47 #include <sys/dsl_dataset.h>
50 * These zfs_log_* functions must be called within a dmu tx, in one
51 * of 2 contexts depending on zilog->z_replay:
55 * We need to record the transaction so that if it is committed to
56 * the Intent Log then it can be replayed. An intent log transaction
57 * structure (itx_t) is allocated and all the information necessary to
58 * possibly replay the transaction is saved in it. The itx is then assigned
59 * a sequence number and inserted in the in-memory list anchored in the zilog.
63 * We need to mark the intent log record as replayed in the log header.
64 * This is done in the same transaction as the replay so that they
69 zfs_log_create_txtype(zil_create_t type
, vsecattr_t
*vsecp
, vattr_t
*vap
)
71 int isxvattr
= (vap
->va_mask
& ATTR_XVATTR
);
74 if (vsecp
== NULL
&& !isxvattr
)
76 if (vsecp
&& isxvattr
)
77 return (TX_CREATE_ACL_ATTR
);
79 return (TX_CREATE_ACL
);
81 return (TX_CREATE_ATTR
);
84 if (vsecp
== NULL
&& !isxvattr
)
86 if (vsecp
&& isxvattr
)
87 return (TX_MKDIR_ACL_ATTR
);
89 return (TX_MKDIR_ACL
);
91 return (TX_MKDIR_ATTR
);
100 * build up the log data necessary for logging xvattr_t
101 * First lr_attr_t is initialized. following the lr_attr_t
102 * is the mapsize and attribute bitmap copied from the xvattr_t.
103 * Following the bitmap and bitmapsize two 64 bit words are reserved
104 * for the create time which may be set. Following the create time
105 * records a single 64 bit integer which has the bits to set on
106 * replay for the xvattr.
109 zfs_log_xvattr(lr_attr_t
*lrattr
, xvattr_t
*xvap
)
118 xoap
= xva_getxoptattr(xvap
);
121 lrattr
->lr_attr_masksize
= xvap
->xva_mapsize
;
122 bitmap
= &lrattr
->lr_attr_bitmap
;
123 for (i
= 0; i
!= xvap
->xva_mapsize
; i
++, bitmap
++) {
124 *bitmap
= xvap
->xva_reqattrmap
[i
];
127 /* Now pack the attributes up in a single uint64_t */
128 attrs
= (uint64_t *)bitmap
;
130 scanstamp
= (caddr_t
)(crtime
+ 2);
132 if (XVA_ISSET_REQ(xvap
, XAT_READONLY
))
133 *attrs
|= (xoap
->xoa_readonly
== 0) ? 0 :
135 if (XVA_ISSET_REQ(xvap
, XAT_HIDDEN
))
136 *attrs
|= (xoap
->xoa_hidden
== 0) ? 0 :
138 if (XVA_ISSET_REQ(xvap
, XAT_SYSTEM
))
139 *attrs
|= (xoap
->xoa_system
== 0) ? 0 :
141 if (XVA_ISSET_REQ(xvap
, XAT_ARCHIVE
))
142 *attrs
|= (xoap
->xoa_archive
== 0) ? 0 :
144 if (XVA_ISSET_REQ(xvap
, XAT_IMMUTABLE
))
145 *attrs
|= (xoap
->xoa_immutable
== 0) ? 0 :
147 if (XVA_ISSET_REQ(xvap
, XAT_NOUNLINK
))
148 *attrs
|= (xoap
->xoa_nounlink
== 0) ? 0 :
150 if (XVA_ISSET_REQ(xvap
, XAT_APPENDONLY
))
151 *attrs
|= (xoap
->xoa_appendonly
== 0) ? 0 :
153 if (XVA_ISSET_REQ(xvap
, XAT_OPAQUE
))
154 *attrs
|= (xoap
->xoa_opaque
== 0) ? 0 :
156 if (XVA_ISSET_REQ(xvap
, XAT_NODUMP
))
157 *attrs
|= (xoap
->xoa_nodump
== 0) ? 0 :
159 if (XVA_ISSET_REQ(xvap
, XAT_AV_QUARANTINED
))
160 *attrs
|= (xoap
->xoa_av_quarantined
== 0) ? 0 :
162 if (XVA_ISSET_REQ(xvap
, XAT_AV_MODIFIED
))
163 *attrs
|= (xoap
->xoa_av_modified
== 0) ? 0 :
165 if (XVA_ISSET_REQ(xvap
, XAT_CREATETIME
))
166 ZFS_TIME_ENCODE(&xoap
->xoa_createtime
, crtime
);
167 if (XVA_ISSET_REQ(xvap
, XAT_AV_SCANSTAMP
)) {
168 ASSERT(!XVA_ISSET_REQ(xvap
, XAT_PROJID
));
170 bcopy(xoap
->xoa_av_scanstamp
, scanstamp
, AV_SCANSTAMP_SZ
);
171 } else if (XVA_ISSET_REQ(xvap
, XAT_PROJID
)) {
173 * XAT_PROJID and XAT_AV_SCANSTAMP will never be valid
174 * at the same time, so we can share the same space.
176 bcopy(&xoap
->xoa_projid
, scanstamp
, sizeof (uint64_t));
178 if (XVA_ISSET_REQ(xvap
, XAT_REPARSE
))
179 *attrs
|= (xoap
->xoa_reparse
== 0) ? 0 :
181 if (XVA_ISSET_REQ(xvap
, XAT_OFFLINE
))
182 *attrs
|= (xoap
->xoa_offline
== 0) ? 0 :
184 if (XVA_ISSET_REQ(xvap
, XAT_SPARSE
))
185 *attrs
|= (xoap
->xoa_sparse
== 0) ? 0 :
187 if (XVA_ISSET_REQ(xvap
, XAT_PROJINHERIT
))
188 *attrs
|= (xoap
->xoa_projinherit
== 0) ? 0 :
193 zfs_log_fuid_ids(zfs_fuid_info_t
*fuidp
, void *start
)
196 uint64_t *fuidloc
= start
;
198 /* First copy in the ACE FUIDs */
199 for (zfuid
= list_head(&fuidp
->z_fuids
); zfuid
;
200 zfuid
= list_next(&fuidp
->z_fuids
, zfuid
)) {
201 *fuidloc
++ = zfuid
->z_logfuid
;
208 zfs_log_fuid_domains(zfs_fuid_info_t
*fuidp
, void *start
)
210 zfs_fuid_domain_t
*zdomain
;
212 /* now copy in the domain info, if any */
213 if (fuidp
->z_domain_str_sz
!= 0) {
214 for (zdomain
= list_head(&fuidp
->z_domains
); zdomain
;
215 zdomain
= list_next(&fuidp
->z_domains
, zdomain
)) {
216 bcopy((void *)zdomain
->z_domain
, start
,
217 strlen(zdomain
->z_domain
) + 1);
218 start
= (caddr_t
)start
+
219 strlen(zdomain
->z_domain
) + 1;
226 * If zp is an xattr node, check whether the xattr owner is unlinked.
227 * We don't want to log anything if the owner is unlinked.
230 zfs_xattr_owner_unlinked(znode_t
*zp
)
238 * zrele drops the vnode lock which violates the VOP locking contract
239 * on FreeBSD. See comment at the top of zfs_replay.c for more detail.
242 * if zp is XATTR node, keep walking up via z_xattr_parent until we
245 while (tzp
->z_pflags
& ZFS_XATTR
) {
246 ASSERT3U(zp
->z_xattr_parent
, !=, 0);
247 if (zfs_zget(ZTOZSB(tzp
), tzp
->z_xattr_parent
, &dzp
) != 0) {
255 unlinked
= tzp
->z_unlinked
;
262 * if zp is XATTR node, keep walking up via z_xattr_parent until we
265 while (zp
->z_pflags
& ZFS_XATTR
) {
266 ASSERT3U(zp
->z_xattr_parent
, !=, 0);
267 if (zfs_zget(ZTOZSB(zp
), zp
->z_xattr_parent
, &dzp
) != 0) {
274 unlinked
= zp
->z_unlinked
;
282 * Handles TX_CREATE, TX_CREATE_ATTR, TX_MKDIR, TX_MKDIR_ATTR and
283 * TK_MKXATTR transactions.
285 * TX_CREATE and TX_MKDIR are standard creates, but they may have FUID
286 * domain information appended prior to the name. In this case the
287 * uid/gid in the log record will be a log centric FUID.
289 * TX_CREATE_ACL_ATTR and TX_MKDIR_ACL_ATTR handle special creates that
290 * may contain attributes, ACL and optional fuid information.
292 * TX_CREATE_ACL and TX_MKDIR_ACL handle special creates that specify
293 * and ACL and normal users/groups in the ACEs.
295 * There may be an optional xvattr attribute information similar
296 * to zfs_log_setattr.
298 * Also, after the file name "domain" strings may be appended.
301 zfs_log_create(zilog_t
*zilog
, dmu_tx_t
*tx
, uint64_t txtype
,
302 znode_t
*dzp
, znode_t
*zp
, const char *name
, vsecattr_t
*vsecp
,
303 zfs_fuid_info_t
*fuidp
, vattr_t
*vap
)
307 lr_acl_create_t
*lracl
;
311 xvattr_t
*xvap
= (xvattr_t
*)vap
;
314 size_t namesize
= strlen(name
) + 1;
317 if (zil_replaying(zilog
, tx
) || zfs_xattr_owner_unlinked(dzp
))
321 * If we have FUIDs present then add in space for
322 * domains and ACE fuid's if any.
325 fuidsz
+= fuidp
->z_domain_str_sz
;
326 fuidsz
+= fuidp
->z_fuid_cnt
* sizeof (uint64_t);
329 if (vap
->va_mask
& ATTR_XVATTR
)
330 xvatsize
= ZIL_XVAT_SIZE(xvap
->xva_mapsize
);
332 if ((int)txtype
== TX_CREATE_ATTR
|| (int)txtype
== TX_MKDIR_ATTR
||
333 (int)txtype
== TX_CREATE
|| (int)txtype
== TX_MKDIR
||
334 (int)txtype
== TX_MKXATTR
) {
335 txsize
= sizeof (*lr
) + namesize
+ fuidsz
+ xvatsize
;
336 lrsize
= sizeof (*lr
);
339 sizeof (lr_acl_create_t
) + namesize
+ fuidsz
+
340 ZIL_ACE_LENGTH(aclsize
) + xvatsize
;
341 lrsize
= sizeof (lr_acl_create_t
);
344 itx
= zil_itx_create(txtype
, txsize
);
346 lr
= (lr_create_t
*)&itx
->itx_lr
;
347 lr
->lr_doid
= dzp
->z_id
;
348 lr
->lr_foid
= zp
->z_id
;
349 /* Store dnode slot count in 8 bits above object id. */
350 LR_FOID_SET_SLOTS(lr
->lr_foid
, zp
->z_dnodesize
>> DNODE_SHIFT
);
351 lr
->lr_mode
= zp
->z_mode
;
352 if (!IS_EPHEMERAL(KUID_TO_SUID(ZTOUID(zp
)))) {
353 lr
->lr_uid
= (uint64_t)KUID_TO_SUID(ZTOUID(zp
));
355 lr
->lr_uid
= fuidp
->z_fuid_owner
;
357 if (!IS_EPHEMERAL(KGID_TO_SGID(ZTOGID(zp
)))) {
358 lr
->lr_gid
= (uint64_t)KGID_TO_SGID(ZTOGID(zp
));
360 lr
->lr_gid
= fuidp
->z_fuid_group
;
362 (void) sa_lookup(zp
->z_sa_hdl
, SA_ZPL_GEN(ZTOZSB(zp
)), &lr
->lr_gen
,
364 (void) sa_lookup(zp
->z_sa_hdl
, SA_ZPL_CRTIME(ZTOZSB(zp
)),
365 lr
->lr_crtime
, sizeof (uint64_t) * 2);
367 if (sa_lookup(zp
->z_sa_hdl
, SA_ZPL_RDEV(ZTOZSB(zp
)), &lr
->lr_rdev
,
368 sizeof (lr
->lr_rdev
)) != 0)
372 * Fill in xvattr info if any
374 if (vap
->va_mask
& ATTR_XVATTR
) {
375 zfs_log_xvattr((lr_attr_t
*)((caddr_t
)lr
+ lrsize
), xvap
);
376 end
= (caddr_t
)lr
+ lrsize
+ xvatsize
;
378 end
= (caddr_t
)lr
+ lrsize
;
381 /* Now fill in any ACL info */
384 lracl
= (lr_acl_create_t
*)&itx
->itx_lr
;
385 lracl
->lr_aclcnt
= vsecp
->vsa_aclcnt
;
386 lracl
->lr_acl_bytes
= aclsize
;
387 lracl
->lr_domcnt
= fuidp
? fuidp
->z_domain_cnt
: 0;
388 lracl
->lr_fuidcnt
= fuidp
? fuidp
->z_fuid_cnt
: 0;
389 if (vsecp
->vsa_aclflags
& VSA_ACE_ACLFLAGS
)
390 lracl
->lr_acl_flags
= (uint64_t)vsecp
->vsa_aclflags
;
392 lracl
->lr_acl_flags
= 0;
394 bcopy(vsecp
->vsa_aclentp
, end
, aclsize
);
395 end
= (caddr_t
)end
+ ZIL_ACE_LENGTH(aclsize
);
398 /* drop in FUID info */
400 end
= zfs_log_fuid_ids(fuidp
, end
);
401 end
= zfs_log_fuid_domains(fuidp
, end
);
404 * Now place file name in log record
406 bcopy(name
, end
, namesize
);
408 zil_itx_assign(zilog
, itx
, tx
);
412 * Handles both TX_REMOVE and TX_RMDIR transactions.
415 zfs_log_remove(zilog_t
*zilog
, dmu_tx_t
*tx
, uint64_t txtype
,
416 znode_t
*dzp
, const char *name
, uint64_t foid
, boolean_t unlinked
)
420 size_t namesize
= strlen(name
) + 1;
422 if (zil_replaying(zilog
, tx
) || zfs_xattr_owner_unlinked(dzp
))
425 itx
= zil_itx_create(txtype
, sizeof (*lr
) + namesize
);
426 lr
= (lr_remove_t
*)&itx
->itx_lr
;
427 lr
->lr_doid
= dzp
->z_id
;
428 bcopy(name
, (char *)(lr
+ 1), namesize
);
433 * Object ids can be re-instantiated in the next txg so
434 * remove any async transactions to avoid future leaks.
435 * This can happen if a fsync occurs on the re-instantiated
436 * object for a WR_INDIRECT or WR_NEED_COPY write, which gets
437 * the new file data and flushes a write record for the old object.
440 ASSERT((txtype
& ~TX_CI
) == TX_REMOVE
);
441 zil_remove_async(zilog
, foid
);
443 zil_itx_assign(zilog
, itx
, tx
);
447 * Handles TX_LINK transactions.
450 zfs_log_link(zilog_t
*zilog
, dmu_tx_t
*tx
, uint64_t txtype
,
451 znode_t
*dzp
, znode_t
*zp
, const char *name
)
455 size_t namesize
= strlen(name
) + 1;
457 if (zil_replaying(zilog
, tx
))
460 itx
= zil_itx_create(txtype
, sizeof (*lr
) + namesize
);
461 lr
= (lr_link_t
*)&itx
->itx_lr
;
462 lr
->lr_doid
= dzp
->z_id
;
463 lr
->lr_link_obj
= zp
->z_id
;
464 bcopy(name
, (char *)(lr
+ 1), namesize
);
466 zil_itx_assign(zilog
, itx
, tx
);
470 * Handles TX_SYMLINK transactions.
473 zfs_log_symlink(zilog_t
*zilog
, dmu_tx_t
*tx
, uint64_t txtype
,
474 znode_t
*dzp
, znode_t
*zp
, const char *name
, const char *link
)
478 size_t namesize
= strlen(name
) + 1;
479 size_t linksize
= strlen(link
) + 1;
481 if (zil_replaying(zilog
, tx
))
484 itx
= zil_itx_create(txtype
, sizeof (*lr
) + namesize
+ linksize
);
485 lr
= (lr_create_t
*)&itx
->itx_lr
;
486 lr
->lr_doid
= dzp
->z_id
;
487 lr
->lr_foid
= zp
->z_id
;
488 lr
->lr_uid
= KUID_TO_SUID(ZTOUID(zp
));
489 lr
->lr_gid
= KGID_TO_SGID(ZTOGID(zp
));
490 lr
->lr_mode
= zp
->z_mode
;
491 (void) sa_lookup(zp
->z_sa_hdl
, SA_ZPL_GEN(ZTOZSB(zp
)), &lr
->lr_gen
,
493 (void) sa_lookup(zp
->z_sa_hdl
, SA_ZPL_CRTIME(ZTOZSB(zp
)),
494 lr
->lr_crtime
, sizeof (uint64_t) * 2);
495 bcopy(name
, (char *)(lr
+ 1), namesize
);
496 bcopy(link
, (char *)(lr
+ 1) + namesize
, linksize
);
498 zil_itx_assign(zilog
, itx
, tx
);
502 * Handles TX_RENAME transactions.
505 zfs_log_rename(zilog_t
*zilog
, dmu_tx_t
*tx
, uint64_t txtype
, znode_t
*sdzp
,
506 const char *sname
, znode_t
*tdzp
, const char *dname
, znode_t
*szp
)
510 size_t snamesize
= strlen(sname
) + 1;
511 size_t dnamesize
= strlen(dname
) + 1;
513 if (zil_replaying(zilog
, tx
))
516 itx
= zil_itx_create(txtype
, sizeof (*lr
) + snamesize
+ dnamesize
);
517 lr
= (lr_rename_t
*)&itx
->itx_lr
;
518 lr
->lr_sdoid
= sdzp
->z_id
;
519 lr
->lr_tdoid
= tdzp
->z_id
;
520 bcopy(sname
, (char *)(lr
+ 1), snamesize
);
521 bcopy(dname
, (char *)(lr
+ 1) + snamesize
, dnamesize
);
522 itx
->itx_oid
= szp
->z_id
;
524 zil_itx_assign(zilog
, itx
, tx
);
528 * zfs_log_write() handles TX_WRITE transactions. The specified callback is
529 * called as soon as the write is on stable storage (be it via a DMU sync or a
532 long zfs_immediate_write_sz
= 32768;
535 zfs_log_write(zilog_t
*zilog
, dmu_tx_t
*tx
, int txtype
,
536 znode_t
*zp
, offset_t off
, ssize_t resid
, int ioflag
,
537 zil_callback_t callback
, void *callback_data
)
539 dmu_buf_impl_t
*db
= (dmu_buf_impl_t
*)sa_get_db(zp
->z_sa_hdl
);
540 uint32_t blocksize
= zp
->z_blksz
;
541 itx_wr_state_t write_state
;
544 ssize_t size
= resid
;
546 if (zil_replaying(zilog
, tx
) || zp
->z_unlinked
||
547 zfs_xattr_owner_unlinked(zp
)) {
548 if (callback
!= NULL
)
549 callback(callback_data
);
553 if (zilog
->zl_logbias
== ZFS_LOGBIAS_THROUGHPUT
)
554 write_state
= WR_INDIRECT
;
555 else if (!spa_has_slogs(zilog
->zl_spa
) &&
556 resid
>= zfs_immediate_write_sz
)
557 write_state
= WR_INDIRECT
;
558 else if (ioflag
& (O_SYNC
| O_DSYNC
))
559 write_state
= WR_COPIED
;
561 write_state
= WR_NEED_COPY
;
563 if ((fsync_cnt
= (uintptr_t)tsd_get(zfs_fsyncer_key
)) != 0) {
564 (void) tsd_set(zfs_fsyncer_key
, (void *)(fsync_cnt
- 1));
567 (void) sa_lookup(zp
->z_sa_hdl
, SA_ZPL_GEN(ZTOZSB(zp
)), &gen
,
573 itx_wr_state_t wr_state
= write_state
;
577 * A WR_COPIED record must fit entirely in one log block.
578 * Large writes can use WR_NEED_COPY, which the ZIL will
579 * split into multiple records across several log blocks
582 if (wr_state
== WR_COPIED
&&
583 resid
> zil_max_copied_data(zilog
))
584 wr_state
= WR_NEED_COPY
;
585 else if (wr_state
== WR_INDIRECT
)
586 len
= MIN(blocksize
- P2PHASE(off
, blocksize
), resid
);
588 itx
= zil_itx_create(txtype
, sizeof (*lr
) +
589 (wr_state
== WR_COPIED
? len
: 0));
590 lr
= (lr_write_t
*)&itx
->itx_lr
;
593 * For WR_COPIED records, copy the data into the lr_write_t.
595 if (wr_state
== WR_COPIED
) {
598 err
= dmu_read_by_dnode(DB_DNODE(db
), off
, len
, lr
+ 1,
599 DMU_READ_NO_PREFETCH
);
601 zil_itx_destroy(itx
);
602 itx
= zil_itx_create(txtype
, sizeof (*lr
));
603 lr
= (lr_write_t
*)&itx
->itx_lr
;
604 wr_state
= WR_NEED_COPY
;
609 itx
->itx_wr_state
= wr_state
;
610 lr
->lr_foid
= zp
->z_id
;
614 BP_ZERO(&lr
->lr_blkptr
);
616 itx
->itx_private
= ZTOZSB(zp
);
619 if (!(ioflag
& (O_SYNC
| O_DSYNC
)) && (zp
->z_sync_cnt
== 0) &&
621 itx
->itx_sync
= B_FALSE
;
623 itx
->itx_callback
= callback
;
624 itx
->itx_callback_data
= callback_data
;
625 zil_itx_assign(zilog
, itx
, tx
);
631 if (write_state
== WR_COPIED
|| write_state
== WR_NEED_COPY
) {
632 dsl_pool_wrlog_count(zilog
->zl_dmu_pool
, size
, tx
->tx_txg
);
637 * Handles TX_TRUNCATE transactions.
640 zfs_log_truncate(zilog_t
*zilog
, dmu_tx_t
*tx
, int txtype
,
641 znode_t
*zp
, uint64_t off
, uint64_t len
)
646 if (zil_replaying(zilog
, tx
) || zp
->z_unlinked
||
647 zfs_xattr_owner_unlinked(zp
))
650 itx
= zil_itx_create(txtype
, sizeof (*lr
));
651 lr
= (lr_truncate_t
*)&itx
->itx_lr
;
652 lr
->lr_foid
= zp
->z_id
;
656 itx
->itx_sync
= (zp
->z_sync_cnt
!= 0);
657 zil_itx_assign(zilog
, itx
, tx
);
661 * Handles TX_SETATTR transactions.
664 zfs_log_setattr(zilog_t
*zilog
, dmu_tx_t
*tx
, int txtype
,
665 znode_t
*zp
, vattr_t
*vap
, uint_t mask_applied
, zfs_fuid_info_t
*fuidp
)
669 xvattr_t
*xvap
= (xvattr_t
*)vap
;
670 size_t recsize
= sizeof (lr_setattr_t
);
673 if (zil_replaying(zilog
, tx
) || zp
->z_unlinked
)
677 * If XVATTR set, then log record size needs to allow
678 * for lr_attr_t + xvattr mask, mapsize and create time
679 * plus actual attribute values
681 if (vap
->va_mask
& ATTR_XVATTR
)
682 recsize
= sizeof (*lr
) + ZIL_XVAT_SIZE(xvap
->xva_mapsize
);
685 recsize
+= fuidp
->z_domain_str_sz
;
687 itx
= zil_itx_create(txtype
, recsize
);
688 lr
= (lr_setattr_t
*)&itx
->itx_lr
;
689 lr
->lr_foid
= zp
->z_id
;
690 lr
->lr_mask
= (uint64_t)mask_applied
;
691 lr
->lr_mode
= (uint64_t)vap
->va_mode
;
692 if ((mask_applied
& ATTR_UID
) && IS_EPHEMERAL(vap
->va_uid
))
693 lr
->lr_uid
= fuidp
->z_fuid_owner
;
695 lr
->lr_uid
= (uint64_t)vap
->va_uid
;
697 if ((mask_applied
& ATTR_GID
) && IS_EPHEMERAL(vap
->va_gid
))
698 lr
->lr_gid
= fuidp
->z_fuid_group
;
700 lr
->lr_gid
= (uint64_t)vap
->va_gid
;
702 lr
->lr_size
= (uint64_t)vap
->va_size
;
703 ZFS_TIME_ENCODE(&vap
->va_atime
, lr
->lr_atime
);
704 ZFS_TIME_ENCODE(&vap
->va_mtime
, lr
->lr_mtime
);
705 start
= (lr_setattr_t
*)(lr
+ 1);
706 if (vap
->va_mask
& ATTR_XVATTR
) {
707 zfs_log_xvattr((lr_attr_t
*)start
, xvap
);
708 start
= (caddr_t
)start
+ ZIL_XVAT_SIZE(xvap
->xva_mapsize
);
712 * Now stick on domain information if any on end
716 (void) zfs_log_fuid_domains(fuidp
, start
);
718 itx
->itx_sync
= (zp
->z_sync_cnt
!= 0);
719 zil_itx_assign(zilog
, itx
, tx
);
723 * Handles TX_ACL transactions.
726 zfs_log_acl(zilog_t
*zilog
, dmu_tx_t
*tx
, znode_t
*zp
,
727 vsecattr_t
*vsecp
, zfs_fuid_info_t
*fuidp
)
735 size_t aclbytes
= vsecp
->vsa_aclentsz
;
737 if (zil_replaying(zilog
, tx
) || zp
->z_unlinked
)
740 txtype
= (ZTOZSB(zp
)->z_version
< ZPL_VERSION_FUID
) ?
743 if (txtype
== TX_ACL
)
744 lrsize
= sizeof (*lr
);
746 lrsize
= sizeof (*lrv0
);
749 ((txtype
== TX_ACL
) ? ZIL_ACE_LENGTH(aclbytes
) : aclbytes
) +
750 (fuidp
? fuidp
->z_domain_str_sz
: 0) +
751 sizeof (uint64_t) * (fuidp
? fuidp
->z_fuid_cnt
: 0);
753 itx
= zil_itx_create(txtype
, txsize
);
755 lr
= (lr_acl_t
*)&itx
->itx_lr
;
756 lr
->lr_foid
= zp
->z_id
;
757 if (txtype
== TX_ACL
) {
758 lr
->lr_acl_bytes
= aclbytes
;
759 lr
->lr_domcnt
= fuidp
? fuidp
->z_domain_cnt
: 0;
760 lr
->lr_fuidcnt
= fuidp
? fuidp
->z_fuid_cnt
: 0;
761 if (vsecp
->vsa_mask
& VSA_ACE_ACLFLAGS
)
762 lr
->lr_acl_flags
= (uint64_t)vsecp
->vsa_aclflags
;
764 lr
->lr_acl_flags
= 0;
766 lr
->lr_aclcnt
= (uint64_t)vsecp
->vsa_aclcnt
;
768 if (txtype
== TX_ACL_V0
) {
769 lrv0
= (lr_acl_v0_t
*)lr
;
770 bcopy(vsecp
->vsa_aclentp
, (ace_t
*)(lrv0
+ 1), aclbytes
);
772 void *start
= (ace_t
*)(lr
+ 1);
774 bcopy(vsecp
->vsa_aclentp
, start
, aclbytes
);
776 start
= (caddr_t
)start
+ ZIL_ACE_LENGTH(aclbytes
);
779 start
= zfs_log_fuid_ids(fuidp
, start
);
780 (void) zfs_log_fuid_domains(fuidp
, start
);
784 itx
->itx_sync
= (zp
->z_sync_cnt
!= 0);
785 zil_itx_assign(zilog
, itx
, tx
);
789 ZFS_MODULE_PARAM(zfs
, zfs_
, immediate_write_sz
, LONG
, ZMOD_RW
,
790 "Largest data block to write to zil");