xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zil.h (revision e09fa4dacfb671e707d50a55ae9b5cc191e1b8cb)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5436b2950Sperrin  * Common Development and Distribution License (the "License").
6436b2950Sperrin  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
223589c4f0SNeil Perrin  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23fa9e4066Sahrens  * Use is subject to license terms.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef	_SYS_ZIL_H
27fa9e4066Sahrens #define	_SYS_ZIL_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #include <sys/types.h>
30fa9e4066Sahrens #include <sys/spa.h>
31fa9e4066Sahrens #include <sys/zio.h>
32fa9e4066Sahrens #include <sys/dmu.h>
33fa9e4066Sahrens 
34fa9e4066Sahrens #ifdef	__cplusplus
35fa9e4066Sahrens extern "C" {
36fa9e4066Sahrens #endif
37fa9e4066Sahrens 
38fa9e4066Sahrens /*
39fa9e4066Sahrens  * Intent log format:
40fa9e4066Sahrens  *
41fa9e4066Sahrens  * Each objset has its own intent log.  The log header (zil_header_t)
42fa9e4066Sahrens  * for objset N's intent log is kept in the Nth object of the SPA's
43fa9e4066Sahrens  * intent_log objset.  The log header points to a chain of log blocks,
44fa9e4066Sahrens  * each of which contains log records (i.e., transactions) followed by
45fa9e4066Sahrens  * a log block trailer (zil_trailer_t).  The format of a log record
46fa9e4066Sahrens  * depends on the record (or transaction) type, but all records begin
47fa9e4066Sahrens  * with a common structure that defines the type, length, and txg.
48fa9e4066Sahrens  */
49fa9e4066Sahrens 
50fa9e4066Sahrens /*
51fa9e4066Sahrens  * Intent log header - this on disk structure holds fields to manage
52fa9e4066Sahrens  * the log.  All fields are 64 bit to easily handle cross architectures.
53fa9e4066Sahrens  */
54fa9e4066Sahrens typedef struct zil_header {
55fa9e4066Sahrens 	uint64_t zh_claim_txg;	/* txg in which log blocks were claimed */
56fa9e4066Sahrens 	uint64_t zh_replay_seq;	/* highest replayed sequence number */
57fa9e4066Sahrens 	blkptr_t zh_log;	/* log chain */
58d80c45e0Sbonwick 	uint64_t zh_claim_seq;	/* highest claimed sequence number */
593589c4f0SNeil Perrin 	uint64_t zh_flags;	/* header flags */
603589c4f0SNeil Perrin 	uint64_t zh_pad[4];
61fa9e4066Sahrens } zil_header_t;
62fa9e4066Sahrens 
633589c4f0SNeil Perrin /*
643589c4f0SNeil Perrin  * zh_flags bit settings
653589c4f0SNeil Perrin  */
663589c4f0SNeil Perrin #define	ZIL_REPLAY_NEEDED 0x1	/* replay needed - internal only */
673589c4f0SNeil Perrin 
68fa9e4066Sahrens /*
69fa9e4066Sahrens  * Log block trailer - structure at the end of the header and each log block
70fa9e4066Sahrens  *
71fa9e4066Sahrens  * The zit_bt contains a zbt_cksum which for the intent log is
72fa9e4066Sahrens  * the sequence number of this log block. A seq of 0 is invalid.
73fa9e4066Sahrens  * The zbt_cksum is checked by the SPA against the sequence
74fa9e4066Sahrens  * number passed in the blk_cksum field of the blkptr_t
75fa9e4066Sahrens  */
76fa9e4066Sahrens typedef struct zil_trailer {
77fa9e4066Sahrens 	uint64_t zit_pad;
78fa9e4066Sahrens 	blkptr_t zit_next_blk;	/* next block in chain */
79fa9e4066Sahrens 	uint64_t zit_nused;	/* bytes in log block used */
80fa9e4066Sahrens 	zio_block_tail_t zit_bt; /* block trailer */
81fa9e4066Sahrens } zil_trailer_t;
82fa9e4066Sahrens 
83b4d654b0Sperrin #define	ZIL_MIN_BLKSZ	4096ULL
84fa9e4066Sahrens #define	ZIL_MAX_BLKSZ	SPA_MAXBLOCKSIZE
85fa9e4066Sahrens #define	ZIL_BLK_DATA_SZ(lwb)	((lwb)->lwb_sz - sizeof (zil_trailer_t))
86fa9e4066Sahrens 
87d80c45e0Sbonwick /*
88d80c45e0Sbonwick  * The words of a log block checksum.
89d80c45e0Sbonwick  */
90d80c45e0Sbonwick #define	ZIL_ZC_GUID_0	0
91d80c45e0Sbonwick #define	ZIL_ZC_GUID_1	1
92d80c45e0Sbonwick #define	ZIL_ZC_OBJSET	2
93d80c45e0Sbonwick #define	ZIL_ZC_SEQ	3
94d80c45e0Sbonwick 
95da6c28aaSamw typedef enum zil_create {
96da6c28aaSamw 	Z_FILE,
97da6c28aaSamw 	Z_DIR,
98da6c28aaSamw 	Z_XATTRDIR,
99da6c28aaSamw } zil_create_t;
100da6c28aaSamw 
101da6c28aaSamw /*
102da6c28aaSamw  * size of xvattr log section.
103da6c28aaSamw  * its composed of lr_attr_t + xvattr bitmap + 2 64 bit timestamps
104da6c28aaSamw  * for create time and a single 64 bit integer for all of the attributes,
105da6c28aaSamw  * and 4 64 bit integers (32 bytes) for the scanstamp.
106da6c28aaSamw  *
107da6c28aaSamw  */
108da6c28aaSamw 
109da6c28aaSamw #define	ZIL_XVAT_SIZE(mapsize) \
110da6c28aaSamw 	sizeof (lr_attr_t) + (sizeof (uint32_t) * (mapsize - 1)) + \
111da6c28aaSamw 	(sizeof (uint64_t) * 7)
112569e6c63Smarks 
113569e6c63Smarks /*
114569e6c63Smarks  * Size of ACL in log.  The ACE data is padded out to properly align
115569e6c63Smarks  * on 8 byte boundary.
116569e6c63Smarks  */
117569e6c63Smarks 
118569e6c63Smarks #define	ZIL_ACE_LENGTH(x)	(roundup(x, sizeof (uint64_t)))
119569e6c63Smarks 
120fa9e4066Sahrens /*
121fa9e4066Sahrens  * Intent log transaction types and record structures
122fa9e4066Sahrens  */
123da6c28aaSamw #define	TX_CREATE		1	/* Create file */
124da6c28aaSamw #define	TX_MKDIR		2	/* Make directory */
125da6c28aaSamw #define	TX_MKXATTR		3	/* Make XATTR directory */
126da6c28aaSamw #define	TX_SYMLINK		4	/* Create symbolic link to a file */
127da6c28aaSamw #define	TX_REMOVE		5	/* Remove file */
128da6c28aaSamw #define	TX_RMDIR		6	/* Remove directory */
129da6c28aaSamw #define	TX_LINK			7	/* Create hard link to a file */
130da6c28aaSamw #define	TX_RENAME		8	/* Rename a file */
131da6c28aaSamw #define	TX_WRITE		9	/* File write */
132da6c28aaSamw #define	TX_TRUNCATE		10	/* Truncate a file */
133da6c28aaSamw #define	TX_SETATTR		11	/* Set file attributes */
134da6c28aaSamw #define	TX_ACL_V0		12	/* Set old formatted ACL */
135da6c28aaSamw #define	TX_ACL			13	/* Set ACL */
136da6c28aaSamw #define	TX_CREATE_ACL		14	/* create with ACL */
137da6c28aaSamw #define	TX_CREATE_ATTR		15	/* create + attrs */
138da6c28aaSamw #define	TX_CREATE_ACL_ATTR 	16	/* create with ACL + attrs */
139da6c28aaSamw #define	TX_MKDIR_ACL		17	/* mkdir with ACL */
140da6c28aaSamw #define	TX_MKDIR_ATTR		18	/* mkdir with attr */
141da6c28aaSamw #define	TX_MKDIR_ACL_ATTR	19	/* mkdir with ACL + attrs */
142da6c28aaSamw #define	TX_MAX_TYPE		20	/* Max transaction type */
143da6c28aaSamw 
144da6c28aaSamw /*
145da6c28aaSamw  * The transactions for mkdir, symlink, remove, rmdir, link, and rename
146da6c28aaSamw  * may have the following bit set, indicating the original request
147da6c28aaSamw  * specified case-insensitive handling of names.
148da6c28aaSamw  */
149da6c28aaSamw #define	TX_CI	((uint64_t)0x1 << 63) /* case-insensitive behavior requested */
150fa9e4066Sahrens 
151fa9e4066Sahrens /*
152fa9e4066Sahrens  * Format of log records.
153fa9e4066Sahrens  * The fields are carefully defined to allow them to be aligned
154fa9e4066Sahrens  * and sized the same on sparc & intel architectures.
155fa9e4066Sahrens  * Each log record has a common structure at the beginning.
156b19a79ecSperrin  *
157b19a79ecSperrin  * Note, lrc_seq holds two different sequence numbers. Whilst in memory
158b19a79ecSperrin  * it contains the transaction sequence number.  The log record on
159b19a79ecSperrin  * disk holds the sequence number of all log records which is used to
160b19a79ecSperrin  * ensure we don't replay the same record.  The two sequence numbers are
161b19a79ecSperrin  * different because the transactions can now be pushed out of order.
162fa9e4066Sahrens  */
163fa9e4066Sahrens typedef struct {			/* common log record header */
164fa9e4066Sahrens 	uint64_t	lrc_txtype;	/* intent log transaction type */
165fa9e4066Sahrens 	uint64_t	lrc_reclen;	/* transaction record length */
166fa9e4066Sahrens 	uint64_t	lrc_txg;	/* dmu transaction group number */
167b19a79ecSperrin 	uint64_t	lrc_seq;	/* see comment above */
168fa9e4066Sahrens } lr_t;
169fa9e4066Sahrens 
170da6c28aaSamw /*
171da6c28aaSamw  * Handle option extended vattr attributes.
172da6c28aaSamw  *
173da6c28aaSamw  * Whenever new attributes are added the version number
174da6c28aaSamw  * will need to be updated as will code in
175da6c28aaSamw  * zfs_log.c and zfs_replay.c
176da6c28aaSamw  */
177da6c28aaSamw typedef struct {
178da6c28aaSamw 	uint32_t	lr_attr_masksize; /* number of elements in array */
179da6c28aaSamw 	uint32_t	lr_attr_bitmap; /* First entry of array */
180da6c28aaSamw 	/* remainder of array and any additional fields */
181da6c28aaSamw } lr_attr_t;
182da6c28aaSamw 
183da6c28aaSamw /*
184da6c28aaSamw  * log record for creates without optional ACL.
185da6c28aaSamw  * This log record does support optional xvattr_t attributes.
186da6c28aaSamw  */
187fa9e4066Sahrens typedef struct {
188fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
189fa9e4066Sahrens 	uint64_t	lr_doid;	/* object id of directory */
190fa9e4066Sahrens 	uint64_t	lr_foid;	/* object id of created file object */
191fa9e4066Sahrens 	uint64_t	lr_mode;	/* mode of object */
192fa9e4066Sahrens 	uint64_t	lr_uid;		/* uid of object */
193fa9e4066Sahrens 	uint64_t	lr_gid;		/* gid of object */
194fa9e4066Sahrens 	uint64_t	lr_gen;		/* generation (txg of creation) */
195fa9e4066Sahrens 	uint64_t	lr_crtime[2];	/* creation time */
196fa9e4066Sahrens 	uint64_t	lr_rdev;	/* rdev of object to create */
197fa9e4066Sahrens 	/* name of object to create follows this */
198fa9e4066Sahrens 	/* for symlinks, link content follows name */
199da6c28aaSamw 	/* for creates with xvattr data, the name follows the xvattr info */
200fa9e4066Sahrens } lr_create_t;
201fa9e4066Sahrens 
202da6c28aaSamw /*
203da6c28aaSamw  * FUID ACL record will be an array of ACEs from the original ACL.
204da6c28aaSamw  * If this array includes ephemeral IDs, the record will also include
205da6c28aaSamw  * an array of log-specific FUIDs to replace the ephemeral IDs.
206da6c28aaSamw  * Only one copy of each unique domain will be present, so the log-specific
207da6c28aaSamw  * FUIDs will use an index into a compressed domain table.  On replay this
208da6c28aaSamw  * information will be used to construct real FUIDs (and bypass idmap,
209da6c28aaSamw  * since it may not be available).
210da6c28aaSamw  */
211da6c28aaSamw 
212da6c28aaSamw /*
213da6c28aaSamw  * Log record for creates with optional ACL
214da6c28aaSamw  * This log record is also used for recording any FUID
215da6c28aaSamw  * information needed for replaying the create.  If the
216da6c28aaSamw  * file doesn't have any actual ACEs then the lr_aclcnt
217da6c28aaSamw  * would be zero.
218da6c28aaSamw  */
219da6c28aaSamw typedef struct {
220da6c28aaSamw 	lr_create_t	lr_create;	/* common create portion */
221da6c28aaSamw 	uint64_t	lr_aclcnt;	/* number of ACEs in ACL */
222da6c28aaSamw 	uint64_t	lr_domcnt;	/* number of unique domains */
223da6c28aaSamw 	uint64_t	lr_fuidcnt;	/* number of real fuids */
224da6c28aaSamw 	uint64_t	lr_acl_bytes;	/* number of bytes in ACL */
225da6c28aaSamw 	uint64_t	lr_acl_flags;	/* ACL flags */
226da6c28aaSamw 	/* lr_acl_bytes number of variable sized ace's follows */
227da6c28aaSamw 	/* if create is also setting xvattr's, then acl data follows xvattr */
228da6c28aaSamw 	/* if ACE FUIDs are needed then they will follow the xvattr_t */
229da6c28aaSamw 	/* Following the FUIDs will be the domain table information. */
230da6c28aaSamw 	/* The FUIDs for the owner and group will be in the lr_create */
231da6c28aaSamw 	/* portion of the record. */
232da6c28aaSamw 	/* name follows ACL data */
233da6c28aaSamw } lr_acl_create_t;
234da6c28aaSamw 
235fa9e4066Sahrens typedef struct {
236fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
237fa9e4066Sahrens 	uint64_t	lr_doid;	/* obj id of directory */
238fa9e4066Sahrens 	/* name of object to remove follows this */
239fa9e4066Sahrens } lr_remove_t;
240fa9e4066Sahrens 
241fa9e4066Sahrens typedef struct {
242fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
243fa9e4066Sahrens 	uint64_t	lr_doid;	/* obj id of directory */
244fa9e4066Sahrens 	uint64_t	lr_link_obj;	/* obj id of link */
245fa9e4066Sahrens 	/* name of object to link follows this */
246fa9e4066Sahrens } lr_link_t;
247fa9e4066Sahrens 
248fa9e4066Sahrens typedef struct {
249fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
250fa9e4066Sahrens 	uint64_t	lr_sdoid;	/* obj id of source directory */
251fa9e4066Sahrens 	uint64_t	lr_tdoid;	/* obj id of target directory */
252fa9e4066Sahrens 	/* 2 strings: names of source and destination follow this */
253fa9e4066Sahrens } lr_rename_t;
254fa9e4066Sahrens 
255fa9e4066Sahrens typedef struct {
256fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
257fa9e4066Sahrens 	uint64_t	lr_foid;	/* file object to write */
258fa9e4066Sahrens 	uint64_t	lr_offset;	/* offset to write to */
259fa9e4066Sahrens 	uint64_t	lr_length;	/* user data length to write */
260fa9e4066Sahrens 	uint64_t	lr_blkoff;	/* offset represented by lr_blkptr */
261fa9e4066Sahrens 	blkptr_t	lr_blkptr;	/* spa block pointer for replay */
262fa9e4066Sahrens 	/* write data will follow for small writes */
263fa9e4066Sahrens } lr_write_t;
264fa9e4066Sahrens 
265fa9e4066Sahrens typedef struct {
266fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
267fa9e4066Sahrens 	uint64_t	lr_foid;	/* object id of file to truncate */
268fa9e4066Sahrens 	uint64_t	lr_offset;	/* offset to truncate from */
269fa9e4066Sahrens 	uint64_t	lr_length;	/* length to truncate */
270fa9e4066Sahrens } lr_truncate_t;
271fa9e4066Sahrens 
272fa9e4066Sahrens typedef struct {
273fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
274fa9e4066Sahrens 	uint64_t	lr_foid;	/* file object to change attributes */
275fa9e4066Sahrens 	uint64_t	lr_mask;	/* mask of attributes to set */
276fa9e4066Sahrens 	uint64_t	lr_mode;	/* mode to set */
277fa9e4066Sahrens 	uint64_t	lr_uid;		/* uid to set */
278fa9e4066Sahrens 	uint64_t	lr_gid;		/* gid to set */
279fa9e4066Sahrens 	uint64_t	lr_size;	/* size to set */
280fa9e4066Sahrens 	uint64_t	lr_atime[2];	/* access time */
281fa9e4066Sahrens 	uint64_t	lr_mtime[2];	/* modification time */
282da6c28aaSamw 	/* optional attribute lr_attr_t may be here */
283fa9e4066Sahrens } lr_setattr_t;
284fa9e4066Sahrens 
285fa9e4066Sahrens typedef struct {
286fa9e4066Sahrens 	lr_t		lr_common;	/* common portion of log record */
287fa9e4066Sahrens 	uint64_t	lr_foid;	/* obj id of file */
288fa9e4066Sahrens 	uint64_t	lr_aclcnt;	/* number of acl entries */
289fa9e4066Sahrens 	/* lr_aclcnt number of ace_t entries follow this */
290da6c28aaSamw } lr_acl_v0_t;
291da6c28aaSamw 
292da6c28aaSamw typedef struct {
293da6c28aaSamw 	lr_t		lr_common;	/* common portion of log record */
294da6c28aaSamw 	uint64_t	lr_foid;	/* obj id of file */
295da6c28aaSamw 	uint64_t	lr_aclcnt;	/* number of ACEs in ACL */
296da6c28aaSamw 	uint64_t	lr_domcnt;	/* number of unique domains */
297da6c28aaSamw 	uint64_t	lr_fuidcnt;	/* number of real fuids */
298da6c28aaSamw 	uint64_t	lr_acl_bytes;	/* number of bytes in ACL */
299da6c28aaSamw 	uint64_t	lr_acl_flags;	/* ACL flags */
300da6c28aaSamw 	/* lr_acl_bytes number of variable sized ace's follows */
301fa9e4066Sahrens } lr_acl_t;
302fa9e4066Sahrens 
303fa9e4066Sahrens /*
304fa9e4066Sahrens  * ZIL structure definitions, interface function prototype and globals.
305fa9e4066Sahrens  */
306fa9e4066Sahrens 
307fa9e4066Sahrens /*
308510b6c0eSNeil Perrin  * Writes are handled in three different ways:
309510b6c0eSNeil Perrin  *
310510b6c0eSNeil Perrin  * WR_INDIRECT:
311510b6c0eSNeil Perrin  *    In this mode, if we need to commit the write later, then the block
312510b6c0eSNeil Perrin  *    is immediately written into the file system (using dmu_sync),
313510b6c0eSNeil Perrin  *    and a pointer to the block is put into the log record.
314510b6c0eSNeil Perrin  *    When the txg commits the block is linked in.
315510b6c0eSNeil Perrin  *    This saves additionally writing the data into the log record.
316510b6c0eSNeil Perrin  *    There are a few requirements for this to occur:
317510b6c0eSNeil Perrin  *	- write is greater than zfs/zvol_immediate_write_sz
318510b6c0eSNeil Perrin  *	- not using slogs (as slogs are assumed to always be faster
319510b6c0eSNeil Perrin  *	  than writing into the main pool)
320510b6c0eSNeil Perrin  *	- the write occupies only one block
321510b6c0eSNeil Perrin  * WR_COPIED:
322510b6c0eSNeil Perrin  *    If we know we'll immediately be committing the
323510b6c0eSNeil Perrin  *    transaction (FSYNC or FDSYNC), the we allocate a larger
324510b6c0eSNeil Perrin  *    log record here for the data and copy the data in.
325510b6c0eSNeil Perrin  * WR_NEED_COPY:
326510b6c0eSNeil Perrin  *    Otherwise we don't allocate a buffer, and *if* we need to
327510b6c0eSNeil Perrin  *    flush the write later then a buffer is allocated and
328510b6c0eSNeil Perrin  *    we retrieve the data using the dmu.
329fa9e4066Sahrens  */
330104e2ed7Sperrin typedef enum {
331104e2ed7Sperrin 	WR_INDIRECT,	/* indirect - a large write (dmu_sync() data */
332104e2ed7Sperrin 			/* and put blkptr in log, rather than actual data) */
333104e2ed7Sperrin 	WR_COPIED,	/* immediate - data is copied into lr_write_t */
334104e2ed7Sperrin 	WR_NEED_COPY,	/* immediate - data needs to be copied if pushed */
335104e2ed7Sperrin } itx_wr_state_t;
336104e2ed7Sperrin 
337fa9e4066Sahrens typedef struct itx {
338fa9e4066Sahrens 	list_node_t	itx_node;	/* linkage on zl_itx_list */
339fa9e4066Sahrens 	void		*itx_private;	/* type-specific opaque data */
340104e2ed7Sperrin 	itx_wr_state_t	itx_wr_state;	/* write state */
34167bd71c6Sperrin 	uint8_t		itx_sync;	/* synchronous transaction */
342abf76b6eSperrin 	uint64_t	itx_sod;	/* record size on disk */
343fa9e4066Sahrens 	lr_t		itx_lr;		/* common part of log record */
344fa9e4066Sahrens 	/* followed by type-specific part of lr_xx_t and its immediate data */
345fa9e4066Sahrens } itx_t;
346fa9e4066Sahrens 
34767bd71c6Sperrin 
34867bd71c6Sperrin /*
34967bd71c6Sperrin  * zgd_t is passed through dmu_sync() to the callback routine zfs_get_done()
35067bd71c6Sperrin  * to handle the cleanup of the dmu_sync() buffer write
35167bd71c6Sperrin  */
35267bd71c6Sperrin typedef struct {
35367bd71c6Sperrin 	zilog_t		*zgd_zilog;	/* zilog */
35467bd71c6Sperrin 	blkptr_t	*zgd_bp;	/* block pointer */
35567bd71c6Sperrin 	struct rl	*zgd_rl;	/* range lock */
35667bd71c6Sperrin } zgd_t;
35767bd71c6Sperrin 
35867bd71c6Sperrin 
359fa9e4066Sahrens typedef void zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg,
360fa9e4066Sahrens     uint64_t txg);
361fa9e4066Sahrens typedef void zil_parse_lr_func_t(zilog_t *zilog, lr_t *lr, void *arg,
362fa9e4066Sahrens     uint64_t txg);
363fa9e4066Sahrens typedef int zil_replay_func_t();
364c5c6ffa0Smaybee typedef int zil_get_data_t(void *arg, lr_write_t *lr, char *dbuf, zio_t *zio);
365fa9e4066Sahrens 
366d80c45e0Sbonwick extern uint64_t	zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
367fa9e4066Sahrens     zil_parse_lr_func_t *parse_lr_func, void *arg, uint64_t txg);
368fa9e4066Sahrens 
369fa9e4066Sahrens extern void	zil_init(void);
370fa9e4066Sahrens extern void	zil_fini(void);
371fa9e4066Sahrens 
372fa9e4066Sahrens extern zilog_t	*zil_alloc(objset_t *os, zil_header_t *zh_phys);
373fa9e4066Sahrens extern void	zil_free(zilog_t *zilog);
374fa9e4066Sahrens 
375fa9e4066Sahrens extern zilog_t	*zil_open(objset_t *os, zil_get_data_t *get_data);
376fa9e4066Sahrens extern void	zil_close(zilog_t *zilog);
377fa9e4066Sahrens 
3781209a471SNeil Perrin extern void	zil_replay(objset_t *os, void *arg,
3791209a471SNeil Perrin     zil_replay_func_t *replay_func[TX_MAX_TYPE]);
380d80c45e0Sbonwick extern void	zil_destroy(zilog_t *zilog, boolean_t keep_first);
3813a8a1de4Sperrin extern void	zil_rollback_destroy(zilog_t *zilog, dmu_tx_t *tx);
382fa9e4066Sahrens 
383da6c28aaSamw extern itx_t	*zil_itx_create(uint64_t txtype, size_t lrsize);
384fa9e4066Sahrens extern uint64_t zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx);
385fa9e4066Sahrens 
386b19a79ecSperrin extern void	zil_commit(zilog_t *zilog, uint64_t seq, uint64_t oid);
387fa9e4066Sahrens 
388e6ca193dSGeorge Wilson extern int	zil_vdev_offline(char *osname, void *txarg);
3891d452cf5Sahrens extern int	zil_claim(char *osname, void *txarg);
390b87f3af3Sperrin extern int	zil_check_log_chain(char *osname, void *txarg);
391fa9e4066Sahrens extern void	zil_sync(zilog_t *zilog, dmu_tx_t *tx);
392fa9e4066Sahrens extern void	zil_clean(zilog_t *zilog);
393436b2950Sperrin extern int	zil_is_committed(zilog_t *zilog);
394fa9e4066Sahrens 
395fa9e4066Sahrens extern int	zil_suspend(zilog_t *zilog);
396fa9e4066Sahrens extern void	zil_resume(zilog_t *zilog);
397fa9e4066Sahrens 
39817f17c2dSbonwick extern void	zil_add_block(zilog_t *zilog, blkptr_t *bp);
39967bd71c6Sperrin 
400*e09fa4daSNeil Perrin extern void	zil_set_logbias(zilog_t *zilog, uint64_t slogval);
401*e09fa4daSNeil Perrin 
402fa9e4066Sahrens extern int zil_disable;
403fa9e4066Sahrens 
404fa9e4066Sahrens #ifdef	__cplusplus
405fa9e4066Sahrens }
406fa9e4066Sahrens #endif
407fa9e4066Sahrens 
408fa9e4066Sahrens #endif	/* _SYS_ZIL_H */
409