2fa9e406ahrens * CDDL HEADER START
3fa9e406ahrens *
4fa9e406ahrens * The contents of this file are subject to the terms of the
5436b295perrin * Common Development and Distribution License (the "License").
6436b295perrin * You may not use this file except in compliance with the License.
7fa9e406ahrens *
8fa9e406ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e406ahrens * or http://www.opensolaris.org/os/licensing.
10fa9e406ahrens * See the License for the specific language governing permissions
11fa9e406ahrens * and limitations under the License.
12fa9e406ahrens *
13fa9e406ahrens * When distributing Covered Code, include this CDDL HEADER in each
14fa9e406ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e406ahrens * If applicable, add the following below this CDDL HEADER, with the
16fa9e406ahrens * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e406ahrens * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e406ahrens *
19fa9e406ahrens * CDDL HEADER END
20fa9e406ahrens */
2255da60bMark J Musante * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23b7b2590Matthew Ahrens * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
24c3d26abMatthew Ahrens * Copyright (c) 2014 Integros [integros.com]
25fa9e406ahrens */
2755da60bMark J Musante/* Portions Copyright 2010 Robert Milkowski */
2855da60bMark J Musante
29fa9e406ahrens#ifndef	_SYS_ZIL_H
30fa9e406ahrens#define	_SYS_ZIL_H
32fa9e406ahrens#include <sys/types.h>
33fa9e406ahrens#include <sys/spa.h>
34fa9e406ahrens#include <sys/zio.h>
35fa9e406ahrens#include <sys/dmu.h>
36eb63303Tom Caputi#include <sys/zio_crypt.h>
38fa9e406ahrens#ifdef	__cplusplus
39fa9e406ahrensextern "C" {
4212380e1Arne Jansenstruct dsl_pool;
4312380e1Arne Jansenstruct dsl_dataset;
441271e4bPrakash Suryastruct lwb;
4512380e1Arne Jansen
47fa9e406ahrens * Intent log format:
48fa9e406ahrens *
49fa9e406ahrens * Each objset has its own intent log.  The log header (zil_header_t)
50fa9e406ahrens * for objset N's intent log is kept in the Nth object of the SPA's
51fa9e406ahrens * intent_log objset.  The log header points to a chain of log blocks,
52fa9e406ahrens * each of which contains log records (i.e., transactions) followed by
53fa9e406ahrens * a log block trailer (zil_trailer_t).  The format of a log record
54fa9e406ahrens * depends on the record (or transaction) type, but all records begin
55fa9e406ahrens * with a common structure that defines the type, length, and txg.
56fa9e406ahrens */
59fa9e406ahrens * Intent log header - this on disk structure holds fields to manage
60fa9e406ahrens * the log.  All fields are 64 bit to easily handle cross architectures.
61fa9e406ahrens */
62fa9e406ahrenstypedef struct zil_header {
63fa9e406ahrens	uint64_t zh_claim_txg;	/* txg in which log blocks were claimed */
64fa9e406ahrens	uint64_t zh_replay_seq;	/* highest replayed sequence number */
65fa9e406ahrens	blkptr_t zh_log;	/* log chain */
66b24ab67Jeff Bonwick	uint64_t zh_claim_blk_seq; /* highest claimed block sequence number */
673589c4fNeil Perrin	uint64_t zh_flags;	/* header flags */
68b24ab67Jeff Bonwick	uint64_t zh_claim_lr_seq; /* highest claimed lr sequence number */
69b24ab67Jeff Bonwick	uint64_t zh_pad[3];
70fa9e406ahrens} zil_header_t;
733589c4fNeil Perrin * zh_flags bit settings
743589c4fNeil Perrin */
75b24ab67Jeff Bonwick#define	ZIL_REPLAY_NEEDED	0x1	/* replay needed - internal only */
76b24ab67Jeff Bonwick#define	ZIL_CLAIM_LR_SEQ_VALID	0x2	/* zh_claim_lr_seq field is valid */
773589c4fNeil Perrin
783589c4fNeil Perrin/*
796e1f5caNeil Perrin * Log block chaining.
80fa9e406ahrens *
816e1f5caNeil Perrin * Log blocks are chained together. Originally they were chained at the
826e1f5caNeil Perrin * end of the block. For performance reasons the chain was moved to the
836e1f5caNeil Perrin * beginning of the block which allows writes for only the data being used.
846e1f5caNeil Perrin * The older position is supported for backwards compatability.
856e1f5caNeil Perrin *
866e1f5caNeil Perrin * The zio_eck_t contains a zec_cksum which for the intent log is
87fa9e406ahrens * the sequence number of this log block. A seq of 0 is invalid.
886e1f5caNeil Perrin * The zec_cksum is checked by the SPA against the sequence
89fa9e406ahrens * number passed in the blk_cksum field of the blkptr_t
90fa9e406ahrens */
916e1f5caNeil Perrintypedef struct zil_chain {
926e1f5caNeil Perrin	uint64_t zc_pad;
936e1f5caNeil Perrin	blkptr_t zc_next_blk;	/* next block in chain */
946e1f5caNeil Perrin	uint64_t zc_nused;	/* bytes in log block used */
956e1f5caNeil Perrin	zio_eck_t zc_eck;	/* block trailer */
966e1f5caNeil Perrin} zil_chain_t;
98b4d654bperrin#define	ZIL_MIN_BLKSZ	4096ULL
101b7b2590Matthew Ahrens * ziltest is by and large an ugly hack, but very useful in
102b7b2590Matthew Ahrens * checking replay without tedious work.
103b7b2590Matthew Ahrens * When running ziltest we want to keep all itx's and so maintain
104b7b2590Matthew Ahrens * a single list in the zl_itxg[] that uses a high txg: ZILTEST_TXG
105b7b2590Matthew Ahrens * We subtract TXG_CONCURRENT_STATES to allow for common code.
106b7b2590Matthew Ahrens */
107b7b2590Matthew Ahrens#define	ZILTEST_TXG (UINT64_MAX - TXG_CONCURRENT_STATES)
108b7b2590Matthew Ahrens
109b7b2590Matthew Ahrens/*
110d80c45ebonwick * The words of a log block checksum.
111d80c45ebonwick */
112d80c45ebonwick#define	ZIL_ZC_GUID_0	0
113d80c45ebonwick#define	ZIL_ZC_GUID_1	1
114d80c45ebonwick#define	ZIL_ZC_OBJSET	2
115d80c45ebonwick#define	ZIL_ZC_SEQ	3
117da6c28aamwtypedef enum zil_create {
118da6c28aamw	Z_FILE,
119da6c28aamw	Z_DIR,
120da6c28aamw	Z_XATTRDIR,
121da6c28aamw} zil_create_t;
124da6c28aamw * size of xvattr log section.
125da6c28aamw * its composed of lr_attr_t + xvattr bitmap + 2 64 bit timestamps
126da6c28aamw * for create time and a single 64 bit integer for all of the attributes,
127da6c28aamw * and 4 64 bit integers (32 bytes) for the scanstamp.
128da6c28aamw *
129da6c28aamw */
131da6c28aamw#define	ZIL_XVAT_SIZE(mapsize) \
132da6c28aamw	sizeof (lr_attr_t) + (sizeof (uint32_t) * (mapsize - 1)) + \
133da6c28aamw	(sizeof (uint64_t) * 7)
136569e6c6marks * Size of ACL in log.  The ACE data is padded out to properly align
137569e6c6marks * on 8 byte boundary.
138569e6c6marks */
140569e6c6marks#define	ZIL_ACE_LENGTH(x)	(roundup(x, sizeof (uint64_t)))
143fa9e406ahrens * Intent log transaction types and record structures
144fa9e406ahrens */
1451271e4bPrakash Surya#define	TX_COMMIT		0	/* Commit marker (no on-disk state) */
146da6c28aamw#define	TX_CREATE		1	/* Create file */
147da6c28aamw#define	TX_MKDIR		2	/* Make directory */
148da6c28aamw#define	TX_MKXATTR		3	/* Make XATTR directory */
149da6c28aamw#define	TX_SYMLINK		4	/* Create symbolic link to a file */
150da6c28aamw#define	TX_REMOVE		5	/* Remove file */
151da6c28aamw#define	TX_RMDIR		6	/* Remove directory */
152da6c28aamw#define	TX_LINK			7	/* Create hard link to a file */
153da6c28aamw#define	TX_RENAME		8	/* Rename a file */
154da6c28aamw#define	TX_WRITE		9	/* File write */
155da6c28aamw#define	TX_TRUNCATE		10	/* Truncate a file */
156da6c28aamw#define	TX_SETATTR		11	/* Set file attributes */
157da6c28aamw#define	TX_ACL_V0		12	/* Set old formatted ACL */
158da6c28aamw#define	TX_ACL			13	/* Set ACL */
159da6c28aamw#define	TX_CREATE_ACL		14	/* create with ACL */
160da6c28aamw#define	TX_CREATE_ATTR		15	/* create + attrs */
16154811daToomas Soome#define	TX_CREATE_ACL_ATTR	16	/* create with ACL + attrs */
162da6c28aamw#define	TX_MKDIR_ACL		17	/* mkdir with ACL */
163da6c28aamw#define	TX_MKDIR_ATTR		18	/* mkdir with attr */
164da6c28aamw#define	TX_MKDIR_ACL_ATTR	19	/* mkdir with ACL + attrs */
165975c32aNeil Perrin#define	TX_WRITE2		20	/* dmu_sync EALREADY write */
166975c32aNeil Perrin#define	TX_MAX_TYPE		21	/* Max transaction type */
169da6c28aamw * The transactions for mkdir, symlink, remove, rmdir, link, and rename
170da6c28aamw * may have the following bit set, indicating the original request
171da6c28aamw * specified case-insensitive handling of names.
172da6c28aamw */
173da6c28aamw#define	TX_CI	((uint64_t)0x1 << 63) /* case-insensitive behavior requested */
176b24ab67Jeff Bonwick * Transactions for write, truncate, setattr, acl_v0, and acl can be logged
177b24ab67Jeff Bonwick * out of order.  For convenience in the code, all such records must have
178b24ab67Jeff Bonwick * lr_foid at the same offset.
179b24ab67Jeff Bonwick */
180b24ab67Jeff Bonwick#define	TX_OOO(txtype)			\
181b24ab67Jeff Bonwick	((txtype) == TX_WRITE ||	\
182b24ab67Jeff Bonwick	(txtype) == TX_TRUNCATE ||	\
183b24ab67Jeff Bonwick	(txtype) == TX_SETATTR ||	\
184b24ab67Jeff Bonwick	(txtype) == TX_ACL_V0 ||	\
185b24ab67Jeff Bonwick	(txtype) == TX_ACL ||		\
186b24ab67Jeff Bonwick	(txtype) == TX_WRITE2)
187b24ab67Jeff Bonwick
188b24ab67Jeff Bonwick/*
18954811daToomas Soome * The number of dnode slots consumed by the object is stored in the 8
19054811daToomas Soome * unused upper bits of the object ID. We subtract 1 from the value
19154811daToomas Soome * stored on disk for compatibility with implementations that don't
19254811daToomas Soome * support large dnodes. The slot count for a single-slot dnode will
19354811daToomas Soome * contain 0 for those bits to preserve the log record format for
19454811daToomas Soome * "small" dnodes.
19554811daToomas Soome */
19654811daToomas Soome#define	LR_FOID_GET_SLOTS(oid) (BF64_GET((oid), 56, 8) + 1)
19754811daToomas Soome#define	LR_FOID_SET_SLOTS(oid, x) BF64_SET((oid), 56, 8, (x) - 1)
19854811daToomas Soome#define	LR_FOID_GET_OBJ(oid) BF64_GET((oid), 0, DN_MAX_OBJECT_SHIFT)
19954811daToomas Soome#define	LR_FOID_SET_OBJ(oid, x) BF64_SET((oid), 0, DN_MAX_OBJECT_SHIFT, (x))
20054811daToomas Soome
20154811daToomas Soome/*
202fa9e406ahrens * Format of log records.
203fa9e406ahrens * The fields are carefully defined to allow them to be aligned
204fa9e406ahrens * and sized the same on sparc & intel architectures.
205fa9e406ahrens * Each log record has a common structure at the beginning.
206b19a79eperrin *
2075002558Neil Perrin * The log record on disk (lrc_seq) holds the sequence number of all log
2085002558Neil Perrin * records which is used to ensure we don't replay the same record.
209fa9e406ahrens */
210fa9e406ahrenstypedef struct {			/* common log record header */
211fa9e406ahrens	uint64_t	lrc_txtype;	/* intent log transaction type */
212fa9e406ahrens	uint64_t	lrc_reclen;	/* transaction record length */
213fa9e406ahrens	uint64_t	lrc_txg;	/* dmu transaction group number */
214b19a79eperrin	uint64_t	lrc_seq;	/* see comment above */
215fa9e406ahrens} lr_t;
218b24ab67Jeff Bonwick * Common start of all out-of-order record types (TX_OOO() above).
219b24ab67Jeff Bonwick */
220b24ab67Jeff Bonwicktypedef struct {
221b24ab67Jeff Bonwick	lr_t		lr_common;	/* common portion of log record */
222b24ab67Jeff Bonwick	uint64_t	lr_foid;	/* object id */
223b24ab67Jeff Bonwick} lr_ooo_t;
224b24ab67Jeff Bonwick
225b24ab67Jeff Bonwick/*
226da6c28aamw * Handle option extended vattr attributes.
227da6c28aamw *
228da6c28aamw * Whenever new attributes are added the version number
229da6c28aamw * will need to be updated as will code in
230da6c28aamw * zfs_log.c and zfs_replay.c
231da6c28aamw */
232da6c28aamwtypedef struct {
233da6c28aamw	uint32_t	lr_attr_masksize; /* number of elements in array */
234da6c28aamw	uint32_t	lr_attr_bitmap; /* First entry of array */
235da6c28aamw	/* remainder of array and any additional fields */
236da6c28aamw} lr_attr_t;
239da6c28aamw * log record for creates without optional ACL.
240da6c28aamw * This log record does support optional xvattr_t attributes.
241da6c28aamw */
242fa9e406ahrenstypedef struct {
243fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
244fa9e406ahrens	uint64_t	lr_doid;	/* object id of directory */
245fa9e406ahrens	uint64_t	lr_foid;	/* object id of created file object */
246fa9e406ahrens	uint64_t	lr_mode;	/* mode of object */
247fa9e406ahrens	uint64_t	lr_uid;		/* uid of object */
248fa9e406ahrens	uint64_t	lr_gid;		/* gid of object */
249fa9e406ahrens	uint64_t	lr_gen;		/* generation (txg of creation) */
250fa9e406ahrens	uint64_t	lr_crtime[2];	/* creation time */
251fa9e406ahrens	uint64_t	lr_rdev;	/* rdev of object to create */
252fa9e406ahrens	/* name of object to create follows this */
253fa9e406ahrens	/* for symlinks, link content follows name */
254da6c28aamw	/* for creates with xvattr data, the name follows the xvattr info */
255fa9e406ahrens} lr_create_t;
258da6c28aamw * FUID ACL record will be an array of ACEs from the original ACL.
259da6c28aamw * If this array includes ephemeral IDs, the record will also include
260da6c28aamw * an array of log-specific FUIDs to replace the ephemeral IDs.
261da6c28aamw * Only one copy of each unique domain will be present, so the log-specific
262da6c28aamw * FUIDs will use an index into a compressed domain table.  On replay this
263da6c28aamw * information will be used to construct real FUIDs (and bypass idmap,
264da6c28aamw * since it may not be available).
265da6c28aamw */
268da6c28aamw * Log record for creates with optional ACL
269da6c28aamw * This log record is also used for recording any FUID
270da6c28aamw * information needed for replaying the create.  If the
271da6c28aamw * file doesn't have any actual ACEs then the lr_aclcnt
272da6c28aamw * would be zero.
273f717074Will Andrews *
274f717074Will Andrews * After lr_acl_flags, there are a lr_acl_bytes number of variable sized ace's.
275f717074Will Andrews * If create is also setting xvattr's, then acl data follows xvattr.
276f717074Will Andrews * If ACE FUIDs are needed then they will follow the xvattr_t.  Following
277f717074Will Andrews * the FUIDs will be the domain table information.  The FUIDs for the owner
278f717074Will Andrews * and group will be in lr_create.  Name follows ACL data.
279da6c28aamw */
280da6c28aamwtypedef struct {
281da6c28aamw	lr_create_t	lr_create;	/* common create portion */
282da6c28aamw	uint64_t	lr_aclcnt;	/* number of ACEs in ACL */
283da6c28aamw	uint64_t	lr_domcnt;	/* number of unique domains */
284da6c28aamw	uint64_t	lr_fuidcnt;	/* number of real fuids */
285da6c28aamw	uint64_t	lr_acl_bytes;	/* number of bytes in ACL */
286da6c28aamw	uint64_t	lr_acl_flags;	/* ACL flags */
287da6c28aamw} lr_acl_create_t;
289fa9e406ahrenstypedef struct {
290fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
291fa9e406ahrens	uint64_t	lr_doid;	/* obj id of directory */
292fa9e406ahrens	/* name of object to remove follows this */
293fa9e406ahrens} lr_remove_t;
295fa9e406ahrenstypedef struct {
296fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
297fa9e406ahrens	uint64_t	lr_doid;	/* obj id of directory */
298fa9e406ahrens	uint64_t	lr_link_obj;	/* obj id of link */
299fa9e406ahrens	/* name of object to link follows this */
300fa9e406ahrens} lr_link_t;
302fa9e406ahrenstypedef struct {
303fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
304fa9e406ahrens	uint64_t	lr_sdoid;	/* obj id of source directory */
305fa9e406ahrens	uint64_t	lr_tdoid;	/* obj id of target directory */
306fa9e406ahrens	/* 2 strings: names of source and destination follow this */
307fa9e406ahrens} lr_rename_t;
309fa9e406ahrenstypedef struct {
310fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
311fa9e406ahrens	uint64_t	lr_foid;	/* file object to write */
312fa9e406ahrens	uint64_t	lr_offset;	/* offset to write to */
313fa9e406ahrens	uint64_t	lr_length;	/* user data length to write */
314b24ab67Jeff Bonwick	uint64_t	lr_blkoff;	/* no longer used */
315fa9e406ahrens	blkptr_t	lr_blkptr;	/* spa block pointer for replay */
316fa9e406ahrens	/* write data will follow for small writes */
317fa9e406ahrens} lr_write_t;
319fa9e406ahrenstypedef struct {
320fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
321fa9e406ahrens	uint64_t	lr_foid;	/* object id of file to truncate */
322fa9e406ahrens	uint64_t	lr_offset;	/* offset to truncate from */
323fa9e406ahrens	uint64_t	lr_length;	/* length to truncate */
324fa9e406ahrens} lr_truncate_t;
326fa9e406ahrenstypedef struct {
327fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
328fa9e406ahrens	uint64_t	lr_foid;	/* file object to change attributes */
329fa9e406ahrens	uint64_t	lr_mask;	/* mask of attributes to set */
330fa9e406ahrens	uint64_t	lr_mode;	/* mode to set */
331fa9e406ahrens	uint64_t	lr_uid;		/* uid to set */
332fa9e406ahrens	uint64_t	lr_gid;		/* gid to set */
333fa9e406ahrens	uint64_t	lr_size;	/* size to set */
334fa9e406ahrens	uint64_t	lr_atime[2];	/* access time */
335fa9e406ahrens	uint64_t	lr_mtime[2];	/* modification time */
336da6c28aamw	/* optional attribute lr_attr_t may be here */
337fa9e406ahrens} lr_setattr_t;
339fa9e406ahrenstypedef struct {
340fa9e406ahrens	lr_t		lr_common;	/* common portion of log record */
341fa9e406ahrens	uint64_t	lr_foid;	/* obj id of file */
342fa9e406ahrens	uint64_t	lr_aclcnt;	/* number of acl entries */
343fa9e406ahrens	/* lr_aclcnt number of ace_t entries follow this */
344da6c28aamw} lr_acl_v0_t;
346da6c28aamwtypedef struct {
347da6c28aamw	lr_t		lr_common;	/* common portion of log record */
348da6c28aamw	uint64_t	lr_foid;	/* obj id of file */
349da6c28aamw	uint64_t	lr_aclcnt;	/* number of ACEs in ACL */
350da6c28aamw	uint64_t	lr_domcnt;	/* number of unique domains */
351da6c28aamw	uint64_t	lr_fuidcnt;	/* number of real fuids */
352da6c28aamw	uint64_t	lr_acl_bytes;	/* number of bytes in ACL */
353da6c28aamw	uint64_t	lr_acl_flags;	/* ACL flags */
354da6c28aamw	/* lr_acl_bytes number of variable sized ace's follows */
355fa9e406ahrens} lr_acl_t;
358fa9e406ahrens * ZIL structure definitions, interface function prototype and globals.
359fa9e406ahrens */
362510b6c0Neil Perrin * Writes are handled in three different ways:
363510b6c0Neil Perrin *
364510b6c0Neil Perrin * WR_INDIRECT:
365510b6c0Neil Perrin *    In this mode, if we need to commit the write later, then the block
366510b6c0Neil Perrin *    is immediately written into the file system (using dmu_sync),
367510b6c0Neil Perrin *    and a pointer to the block is put into the log record.
368510b6c0Neil Perrin *    When the txg commits the block is linked in.
369510b6c0Neil Perrin *    This saves additionally writing the data into the log record.
370510b6c0Neil Perrin *    There are a few requirements for this to occur:
371510b6c0Neil Perrin *	- write is greater than zfs/zvol_immediate_write_sz
372510b6c0Neil Perrin *	- not using slogs (as slogs are assumed to always be faster
373510b6c0Neil Perrin *	  than writing into the main pool)
374510b6c0Neil Perrin *	- the write occupies only one block
375510b6c0Neil Perrin * WR_COPIED:
376510b6c0Neil Perrin *    If we know we'll immediately be committing the
377510b6c0Neil Perrin *    transaction (FSYNC or FDSYNC), the we allocate a larger
378510b6c0Neil Perrin *    log record here for the data and copy the data in.
379510b6c0Neil Perrin * WR_NEED_COPY:
380510b6c0Neil Perrin *    Otherwise we don't allocate a buffer, and *if* we need to
381510b6c0Neil Perrin *    flush the write later then a buffer is allocated and
382510b6c0Neil Perrin *    we retrieve the data using the dmu.
383fa9e406ahrens */
384104e2edperrintypedef enum {
385104e2edperrin	WR_INDIRECT,	/* indirect - a large write (dmu_sync() data */
386104e2edperrin			/* and put blkptr in log, rather than actual data) */
387104e2edperrin	WR_COPIED,	/* immediate - data is copied into lr_write_t */
388104e2edperrin	WR_NEED_COPY,	/* immediate - data needs to be copied if pushed */
389b24ab67Jeff Bonwick	WR_NUM_STATES	/* number of states */
390104e2edperrin} itx_wr_state_t;
392fa9e406ahrenstypedef struct itx {
393fa9e406ahrens	list_node_t	itx_node;	/* linkage on zl_itx_list */
394fa9e406ahrens	void		*itx_private;	/* type-specific opaque data */
395104e2edperrin	itx_wr_state_t	itx_wr_state;	/* write state */
39667bd71cperrin	uint8_t		itx_sync;	/* synchronous transaction */
39751bd2f9Neil Perrin	uint64_t	itx_oid;	/* object id */
398fa9e406ahrens	lr_t		itx_lr;		/* common part of log record */
399fa9e406ahrens	/* followed by type-specific part of lr_xx_t and its immediate data */
400fa9e406ahrens} itx_t;
402b24ab67Jeff Bonwicktypedef int zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg,
403fa9e406ahrens    uint64_t txg);
404b24ab67Jeff Bonwicktypedef int zil_parse_lr_func_t(zilog_t *zilog, lr_t *lr, void *arg,
405fa9e406ahrens    uint64_t txg);
4063f7978dAlan Somerstypedef int zil_replay_func_t(void *arg1, void *arg2, boolean_t byteswap);
4071271e4bPrakash Suryatypedef int zil_get_data_t(void *arg, lr_write_t *lr, char *dbuf,
4081271e4bPrakash Surya    struct lwb *lwb, zio_t *zio);
410b24ab67Jeff Bonwickextern int zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
411eb63303Tom Caputi    zil_parse_lr_func_t *parse_lr_func, void *arg, uint64_t txg,
412eb63303Tom Caputi    boolean_t decrypt);
414fa9e406ahrensextern void	zil_init(void);
415fa9e406ahrensextern void	zil_fini(void);
417fa9e406ahrensextern zilog_t	*zil_alloc(objset_t *os, zil_header_t *zh_phys);
418fa9e406ahrensextern void	zil_free(zilog_t *zilog);
420fa9e406ahrensextern zilog_t	*zil_open(objset_t *os, zil_get_data_t *get_data);
421fa9e406ahrensextern void	zil_close(zilog_t *zilog);
4231209a47Neil Perrinextern void	zil_replay(objset_t *os, void *arg,
4241209a47Neil Perrin    zil_replay_func_t *replay_func[TX_MAX_TYPE]);
425b24ab67Jeff Bonwickextern boolean_t zil_replaying(zilog_t *zilog, dmu_tx_t *tx);
426d80c45ebonwickextern void	zil_destroy(zilog_t *zilog, boolean_t keep_first);
427ce636f8Matthew Ahrensextern void	zil_destroy_sync(zilog_t *zilog, dmu_tx_t *tx);
4283a8a1deperrinextern void	zil_rollback_destroy(zilog_t *zilog, dmu_tx_t *tx);
430da6c28aamwextern itx_t	*zil_itx_create(uint64_t txtype, size_t lrsize);
431b24ab67Jeff Bonwickextern void	zil_itx_destroy(itx_t *itx);
4325002558Neil Perrinextern void	zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx);
4345002558Neil Perrinextern void	zil_commit(zilog_t *zilog, uint64_t oid);
43594ddd09Prakash Suryaextern void	zil_commit_impl(zilog_t *zilog, uint64_t oid);
4375cabbc6Prashanth Sreenivasaextern int	zil_reset(const char *osname, void *txarg);
43812380e1Arne Jansenextern int	zil_claim(struct dsl_pool *dp,
43912380e1Arne Jansen    struct dsl_dataset *ds, void *txarg);
44054811daToomas Soomeextern int	zil_check_log_chain(struct dsl_pool *dp,
44112380e1Arne Jansen    struct dsl_dataset *ds, void *tx);
442fa9e406ahrensextern void	zil_sync(zilog_t *zilog, dmu_tx_t *tx);
4435002558Neil Perrinextern void	zil_clean(zilog_t *zilog, uint64_t synced_txg);
4453b2aab1Matthew Ahrensextern int	zil_suspend(const char *osname, void **cookiep);
4463b2aab1Matthew Ahrensextern void	zil_resume(void *cookie);
4481271e4bPrakash Suryaextern void	zil_lwb_add_block(struct lwb *lwb, const blkptr_t *bp);
4491271e4bPrakash Suryaextern void	zil_lwb_add_txg(struct lwb *lwb, uint64_t txg);
450b24ab67Jeff Bonwickextern int	zil_bp_tree_add(zilog_t *zilog, const blkptr_t *bp);
451b24ab67Jeff Bonwick
45255da60bMark J Musanteextern void	zil_set_sync(zilog_t *zilog, uint64_t syncval);
45355da60bMark J Musante
454e09fa4dNeil Perrinextern void	zil_set_logbias(zilog_t *zilog, uint64_t slogval);
455e09fa4dNeil Perrin
45655da60bMark J Musanteextern int zil_replay_disable;
458fa9e406ahrens#ifdef	__cplusplus
462fa9e406ahrens#endif	/* _SYS_ZIL_H */