xref: /titanic_44/usr/src/uts/common/sys/fs/ufs_log.h (revision 1cb6af97c6f66f456d4f726ef056e1ebc0f73305)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_FS_UFS_LOG_H
28 #define	_SYS_FS_UFS_LOG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/buf.h>
33 #include <sys/fs/ufs_trans.h>
34 #include <sys/fs/ufs_filio.h>
35 #include <sys/fs/ufs_inode.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 typedef struct lufs_save {
42 	buf_t		*sv_bp;
43 	size_t		sv_nb_left;
44 	int		sv_error;
45 } lufs_save_t;
46 
47 typedef struct lufs_buf {
48 	buf_t		lb_buf;
49 	void		*lb_ptr;
50 } lufs_buf_t;
51 
52 /*
53  * Log space is stored as extents
54  */
55 #define	LUFS_EXTENTS	(UINT32_C(0))
56 #define	LS_SECTORS	2
57 
58 typedef struct extent {
59 	uint32_t	lbno;	/* Logical block # within the space */
60 	uint32_t	pbno;	/* Physical block number of extent. */
61 				/* in disk blocks for non-MTB ufs */
62 				/* in frags for MTB ufs */
63 	uint32_t	nbno;	/* # blocks in this extent */
64 } extent_t;
65 
66 typedef struct ic_extent {
67 	uint32_t	ic_lbno;	/* Logical block # within the space */
68 	uint32_t	ic_nbno;	/* # blocks in this extent */
69 	daddr_t		ic_pbno;	/* Physical block number of extent. */
70 					/* (always in disk blocks) 	*/
71 } ic_extent_t;
72 
73 typedef struct extent_block {
74 	uint32_t	type;		/* Set to LUFS_EXTENTS to identify */
75 					/*   structure on disk. */
76 	int32_t		chksum;		/* Checksum over entire block. */
77 	uint32_t	nextents;	/* Size of extents array. */
78 	uint32_t	nbytes;		/* # bytes mapped by extent_block. */
79 	uint32_t	nextbno;	/* blkno of next extent_block. */
80 	extent_t	extents[1];
81 } extent_block_t;
82 
83 typedef struct ic_extent_block {
84 	uint32_t	ic_nextents;	/* Size of extents array. */
85 	uint32_t	ic_nbytes;	/* # bytes mapped by extent_block. */
86 	uint32_t	ic_nextbno;	/* blkno of next extent_block. */
87 	ic_extent_t	ic_extents[1];
88 } ic_extent_block_t;
89 
90 /*
91  * Don't size the incore buffers too small or too large
92  */
93 #define	LDL_MINTRANSFER		(UINT32_C(32768))	/* 32 k */
94 #define	LDL_MAXTRANSFER		(UINT32_C(1048576))	/* 1 M */
95 
96 /*
97  * LDL_DIVISOR (ldl_divisor) is the number to calculate the log size
98  * from the file system size according to the calculation in lufs_enable()
99  */
100 #define	LDL_DIVISOR		1024 /* 1024 gives 1MB per 1GB */
101 
102 /*
103  * But set reasonable min/max units
104  *   BUT never set LDL_MAXLOGSIZE to greater than LDL_REALMAXLOGSIZE.  The
105  *   scan code will break (See sect_trailer).
106  */
107 #define	LDL_MINLOGSIZE		(1024 * 1024)
108 #define	LDL_MAXLOGSIZE		(64 * 1024 * 1024)
109 
110 #define	LDL_MINBUFSIZE		(32 * 1024)
111 #define	LDL_USABLE_BSIZE	(DEV_BSIZE - sizeof (sect_trailer_t))
112 #define	NB_LEFT_IN_SECTOR(off) 	(LDL_USABLE_BSIZE - ((off) - dbtob(btodb(off))))
113 
114 typedef struct cirbuf {
115 	buf_t		*cb_bp;		/* buf's with space in circular buf */
116 	buf_t		*cb_dirty;	/* filling this buffer for log write */
117 	buf_t		*cb_free;	/* free bufs list */
118 	caddr_t		cb_va;		/* address of circular buffer */
119 	size_t		cb_nb;		/* size of circular buffer */
120 	krwlock_t	cb_rwlock;	/* r/w lock to protect list mgmt. */
121 } cirbuf_t;
122 
123 #define	LUFS_VERSION		(UINT32_C(1))	/* Version 1 */
124 #define	LUFS_VERSION_LATEST	LUFS_VERSION
125 
126 /*
127  * The old Disksuite unit structure has been split into two parts -- the
128  * incore part which is created at run time and the ondisk structure.  To
129  * minimize code changes, the incore structure retains the old name,
130  * ml_unit_t and the ondisk structure is called ml_odunit_t.  The ondisk
131  * structure is stored at the beginning of the log.
132  *
133  * This structure must fit into a sector (512b)
134  *
135  */
136 typedef struct ml_odunit {
137 	uint32_t	od_version;	/* version number */
138 	uint32_t	od_badlog;	/* is the log okay? */
139 	uint32_t	od_unused1;
140 
141 	/*
142 	 * Important constants
143 	 */
144 	uint32_t	od_maxtransfer;	/* max transfer in bytes */
145 	uint32_t	od_devbsize;	/* device bsize */
146 	int32_t		od_bol_lof;	/* byte offset to begin of log */
147 	int32_t		od_eol_lof;	/* byte offset to end of log */
148 
149 	/*
150 	 * The disk space is split into state and circular log
151 	 */
152 	uint32_t	od_requestsize;	/* size requested by user */
153 	uint32_t	od_statesize;	/* size of state area in bytes */
154 	uint32_t	od_logsize;	/* size of log area in bytes */
155 	int32_t		od_statebno;	/* first block of state area */
156 	int32_t		od_unused2;
157 
158 	/*
159 	 * Head and tail of log
160 	 */
161 	int32_t		od_head_lof;	/* byte offset of head */
162 	uint32_t	od_head_ident;	/* head sector id # */
163 	int32_t		od_tail_lof;	/* byte offset of tail */
164 	uint32_t	od_tail_ident;	/* tail sector id # */
165 	uint32_t	od_chksum;	/* checksum to verify ondisk contents */
166 
167 	/*
168 	 * Used for error recovery
169 	 */
170 	uint32_t	od_head_tid;	/* used for logscan; set at sethead */
171 
172 	/*
173 	 * Debug bits
174 	 */
175 	int32_t		od_debug;
176 
177 	/*
178 	 * Misc
179 	 */
180 	struct timeval	od_timestamp;	/* time of last state change */
181 } ml_odunit_t;
182 
183 typedef struct ml_unit {
184 	struct ml_unit	*un_next;	/* next incore log */
185 	int		un_flags;	/* Incore state */
186 	buf_t		*un_bp;		/* contains memory for un_ondisk */
187 	struct ufsvfs	*un_ufsvfs;	/* backpointer to ufsvfs */
188 	dev_t		un_dev;		/* for convenience */
189 	ic_extent_block_t *un_ebp;	/* block of extents */
190 	size_t		un_nbeb;	/* # bytes used by *un_ebp */
191 	struct mt_map	*un_deltamap;	/* deltamap */
192 	struct mt_map	*un_logmap;	/* logmap includes moby trans stuff */
193 	struct mt_map	*un_matamap;	/* optional - matamap */
194 
195 	/*
196 	 * Used for managing transactions
197 	 */
198 	uint32_t	un_maxresv;	/* maximum reservable space */
199 	uint32_t	un_resv;	/* reserved byte count for this trans */
200 	uint32_t	un_resv_wantin;	/* reserved byte count for next trans */
201 
202 	/*
203 	 * Used during logscan
204 	 */
205 	uint32_t	un_tid;
206 
207 	/*
208 	 * Read/Write Buffers
209 	 */
210 	cirbuf_t	un_rdbuf;	/* read buffer space */
211 	cirbuf_t	un_wrbuf;	/* write buffer space */
212 
213 	/*
214 	 * Ondisk state
215 	 */
216 	ml_odunit_t	un_ondisk;	/* ondisk log information */
217 
218 	/*
219 	 * locks
220 	 */
221 	kmutex_t	un_log_mutex;	/* allows one log write at a time */
222 	kmutex_t	un_state_mutex;	/* only 1 state update at a time */
223 } ml_unit_t;
224 
225 /*
226  * Macros to allow access to the ondisk elements via the ml_unit_t incore
227  * structure.
228  */
229 
230 #define	un_version	un_ondisk.od_version
231 #define	un_badlog	un_ondisk.od_badlog
232 #define	un_maxtransfer	un_ondisk.od_maxtransfer
233 #define	un_devbsize	un_ondisk.od_devbsize
234 #define	un_bol_lof	un_ondisk.od_bol_lof
235 #define	un_eol_lof	un_ondisk.od_eol_lof
236 #define	un_statesize	un_ondisk.od_statesize
237 #define	un_logsize	un_ondisk.od_logsize
238 #define	un_statebno	un_ondisk.od_statebno
239 #define	un_requestsize	un_ondisk.od_requestsize
240 #define	un_head_lof	un_ondisk.od_head_lof
241 #define	un_head_ident	un_ondisk.od_head_ident
242 #define	un_tail_lof	un_ondisk.od_tail_lof
243 #define	un_tail_ident	un_ondisk.od_tail_ident
244 #define	un_chksum	un_ondisk.od_chksum
245 #define	un_head_tid	un_ondisk.od_head_tid
246 #define	un_debug	un_ondisk.od_debug
247 #define	un_timestamp	un_ondisk.od_timestamp
248 
249 /*
250  *	un_flags
251  */
252 #define	LDL_SCAN	0x0001	/* log scan in progress */
253 #define	LDL_ERROR	0x0002	/* in error state */
254 #define	LDL_NOROLL	0x0004  /* Log Not Yet Rollable */
255 
256 typedef struct sect_trailer {
257 	uint32_t	st_tid;		/* transaction id */
258 	uint32_t	st_ident;	/* unique sector id */
259 } sect_trailer_t;
260 
261 /*
262  * map block
263  */
264 #define	MAPBLOCKSIZE	(8192)
265 #define	MAPBLOCKSHIFT	(13)
266 #define	MAPBLOCKOFF	(MAPBLOCKSIZE-1)
267 #define	MAPBLOCKMASK	(~MAPBLOCKOFF)
268 #define	DEV_BMASK	(DEV_BSIZE - 1)
269 
270 /*
271  * cached roll buffer
272  */
273 typedef struct crb {
274 	int64_t		c_mof;		/* master file offset of buffer */
275 	caddr_t		c_buf;		/* pointer to cached roll buffer */
276 	uint32_t	c_nb;		/* size of buffer */
277 	ushort_t	c_refcnt;	/* reference count on crb */
278 	uchar_t		c_invalid;	/* crb should not be used */
279 } crb_t;
280 
281 #define	CRB_END ((crb_t *)1) /* must be non zero */
282 
283 /*
284  * delta header
285  */
286 struct delta {
287 	int64_t		d_mof;	/* byte offset on device to start writing */
288 				/*   delta */
289 	int32_t		d_nb;	/* # bytes in the delta */
290 	delta_t 	d_typ;	/* Type of delta.  Defined in ufs_trans.h */
291 };
292 /*
293  * common map entry
294  */
295 typedef struct mapentry	mapentry_t;
296 struct mapentry {
297 	/*
298 	 * doubly linked list of all mapentries in map -- MUST BE FIRST
299 	 */
300 	mapentry_t	*me_next;
301 	mapentry_t	*me_prev;
302 
303 	mapentry_t	*me_hash;
304 	mapentry_t	*me_agenext;
305 	mapentry_t	*me_cancel;
306 	crb_t		*me_crb;
307 	int		(*me_func)();
308 	ulong_t		me_arg;
309 	ulong_t		me_age;
310 	struct delta	me_delta;
311 	uint32_t	me_tid;
312 	off_t		me_lof;
313 	ushort_t	me_flags;
314 };
315 
316 #define	me_mof	me_delta.d_mof
317 #define	me_nb	me_delta.d_nb
318 #define	me_dt	me_delta.d_typ
319 
320 /*
321  * me_flags
322  */
323 #define	ME_SCAN		(0x0001)	/* entry from log scan */
324 #define	ME_HASH		(0x0002)	/* on hash   list */
325 #define	ME_CANCEL	(0x0004)	/* on cancel list */
326 #define	ME_AGE		(0x0008)	/* on age    list */
327 #define	ME_LIST		(0x0010)	/* on list   list */
328 #define	ME_ROLL		(0x0020)	/* on pseudo-roll list */
329 #define	ME_USER		(0x0040)	/* User Block DT_CANCEL entry */
330 
331 /*
332  * MAP TYPES
333  */
334 enum maptypes	{
335 	deltamaptype, logmaptype, matamaptype
336 };
337 
338 /*
339  * MAP
340  */
341 #define	DELTAMAP_NHASH	(512)
342 #define	LOGMAP_NHASH	(2048)
343 #define	MAP_INDEX(mof, mtm) \
344 	(((mof) >> MAPBLOCKSHIFT) & (mtm->mtm_nhash-1))
345 #define	MAP_HASH(mof, mtm) \
346 	((mtm)->mtm_hash + MAP_INDEX((mof), (mtm)))
347 
348 typedef struct mt_map {
349 	/*
350 	 * anchor doubly linked list this map's entries -- MUST BE FIRST
351 	 */
352 	mapentry_t	*mtm_next;
353 	mapentry_t	*mtm_prev;
354 
355 	enum maptypes	mtm_type;	/* map type */
356 	int		mtm_flags;	/* generic flags */
357 	int		mtm_ref;	/* PTE like ref bit */
358 	ulong_t		mtm_debug;	/* set at create time */
359 	ulong_t		mtm_age;	/* mono-inc; tags mapentries */
360 	mapentry_t	*mtm_cancel;	/* to be canceled at commit */
361 	ulong_t		mtm_nhash;	/* # of hash anchors */
362 	mapentry_t	**mtm_hash;	/* array of singly linked lists */
363 	struct topstats	*mtm_tops;	/* trans ops - enabled by an ioctl */
364 	long		mtm_nme;	/* # of mapentries */
365 	long		mtm_nmet;	/* # of mapentries this transaction */
366 	long		mtm_cfrags;	/* Canceled frags */
367 	long		mtm_cfragmax;	/* Maximum canceled frags */
368 	/*
369 	 * used after logscan to set the log's tail
370 	 */
371 	off_t		mtm_tail_lof;
372 	size_t		mtm_tail_nb;
373 
374 	/*
375 	 * debug field for Scan test
376 	 */
377 	off_t		mtm_trimlof;	/* log was trimmed to this lof */
378 	off_t		mtm_trimtail;	/* tail lof before trimming */
379 	off_t		mtm_trimalof;	/* lof of last allocation delta */
380 	off_t		mtm_trimclof;	/* lof of last commit delta */
381 	off_t		mtm_trimrlof;	/* lof of last rolled delta */
382 	ml_unit_t	*mtm_ul;	/* log unit for this map */
383 
384 	/*
385 	 * moby trans stuff
386 	 */
387 	uint32_t		mtm_tid;
388 	uint32_t		mtm_committid;
389 	ushort_t		mtm_closed;
390 	ushort_t		mtm_seq;
391 	long			mtm_wantin;
392 	long			mtm_active;
393 	long			mtm_activesync;
394 	ulong_t			mtm_dirty;
395 	kmutex_t		mtm_lock;
396 	kcondvar_t		mtm_cv_commit;
397 	kcondvar_t		mtm_cv_next;
398 	kcondvar_t		mtm_cv_eot;
399 
400 	/*
401 	 * mutex that protects all the fields in mt_map except
402 	 * mtm_mapnext and mtm_refcnt
403 	 */
404 	kmutex_t	mtm_mutex;
405 
406 	/*
407 	 * logmap only condition variables
408 	 */
409 	kcondvar_t	mtm_to_roll_cv; /* roll log or kill roll thread */
410 	kcondvar_t	mtm_from_roll_cv; /* log rolled or thread exiting */
411 
412 	/*
413 	 * rw lock for the agenext mapentry field
414 	 */
415 	krwlock_t	mtm_rwlock;
416 	/*
417 	 * DEBUG: runtestscan
418 	 */
419 	kmutex_t	mtm_scan_mutex;
420 
421 	/*
422 	 * logmap only taskq sync count variable, protected by mtm_lock.
423 	 * keeps track of the number of pending top_issue_sync
424 	 * dispatches.
425 	 */
426 	int		mtm_taskq_sync_count;
427 
428 	/*
429 	 * logmap only condition variable, to synchronize with lufs_unsnarf.
430 	 */
431 	kcondvar_t	mtm_cv;
432 } mt_map_t;
433 
434 /*
435  * mtm_flags
436  */
437 #define	MTM_ROLL_EXIT		0x00000001 /* force roll thread to exit */
438 #define	MTM_ROLL_RUNNING	0x00000002 /* roll thread is running */
439 #define	MTM_FORCE_ROLL		0x00000004 /* force at least one roll cycle */
440 #define	MTM_ROLLING		0x00000008 /* currently rolling the log */
441 #define	MTM_CANCELED		0x00000010 /* cancel entries were removed */
442 
443 /*
444  * Generic range checking macros
445  */
446 #define	OVERLAP(sof, snb, dof, dnb) \
447 	(((sof) >= (dof) && (sof) < ((dof) + (dnb))) || \
448 	((dof) >= (sof) && (dof) < ((sof) + (snb))))
449 #define	WITHIN(sof, snb, dof, dnb) \
450 	(((sof) >= (dof)) && (((sof) + (snb)) <= ((dof) + (dnb))))
451 #define	DATAoverlapME(mof, hnb, me) \
452 	(OVERLAP((mof), (hnb), (me)->me_mof, (me)->me_nb))
453 #define	MEwithinDATA(me, mof, hnb) \
454 	(WITHIN((me)->me_mof, (me)->me_nb, (mof), (hnb)))
455 #define	DATAwithinME(mof, hnb, me) \
456 	(WITHIN((mof), (hnb), (me)->me_mof, (me)->me_nb))
457 #define	DATAwithinCRB(mof, nb, crb) \
458 	(WITHIN((mof), (nb), (crb)->c_mof, (crb)->c_nb))
459 
460 /*
461  * TRANSACTION OPS STATS
462  */
463 typedef struct topstats {
464 	uint64_t	mtm_top_num[TOP_MAX];
465 	uint64_t	mtm_top_size_etot[TOP_MAX];
466 	uint64_t	mtm_top_size_rtot[TOP_MAX];
467 	uint64_t	mtm_top_size_max[TOP_MAX];
468 	uint64_t	mtm_top_size_min[TOP_MAX];
469 	uint64_t	mtm_delta_num[DT_MAX];
470 } topstats_t;
471 
472 /*
473  * fio_lufs_stats_t is used by _FIO_GET_TOP_STATS ioctl for getting topstats
474  */
475 typedef struct fio_lufs_stats {
476 	uint32_t	ls_debug;	/* out: un_debug value */
477 	uint32_t	_ls_pad;	/* make size 64-bit aligned on x86 */
478 	topstats_t	ls_topstats;	/* out: transaction stats */
479 } fio_lufs_stats_t;
480 
481 /*
482  * roll buf structure; one per roll buffer
483  */
484 typedef uint16_t rbsecmap_t;
485 typedef struct rollbuf {
486 	buf_t rb_bh;		/* roll buffer header */
487 	struct rollbuf *rb_next; /* link for mof ordered roll bufs */
488 	crb_t *rb_crb;		/* cached roll buffer to roll */
489 	mapentry_t *rb_age;	/* age list */
490 	rbsecmap_t rb_secmap;	/* sector map */
491 } rollbuf_t;
492 
493 /*
494  * un_debug
495  *	MT_TRANSACT		- keep per thread accounting of tranactions
496  *	MT_MATAMAP		- double check deltas and ops against matamap
497  *	MT_WRITE_CHECK		- check master+deltas against metadata write
498  *	MT_LOG_WRITE_CHECK	- read after write for log writes
499  *	MT_CHECK_MAP		- check map after every insert/delete
500  *	MT_TRACE		- trace transactions (used with MT_TRANSACT)
501  *	MT_SIZE			- fail on size errors (used with MT_TRANSACT)
502  *	MT_NOASYNC		- force every op to be sync
503  *	MT_FORCEROLL		- forcibly roll the log after every commit
504  *	MT_SCAN			- running runtestscan; special case as needed
505  */
506 #define	MT_NONE			(0x00000000)
507 #define	MT_TRANSACT		(0x00000001)
508 #define	MT_MATAMAP		(0x00000002)
509 #define	MT_WRITE_CHECK		(0x00000004)
510 #define	MT_LOG_WRITE_CHECK	(0x00000008)
511 #define	MT_CHECK_MAP		(0x00000010)
512 #define	MT_TRACE		(0x00000020)
513 #define	MT_SIZE			(0x00000040)
514 #define	MT_NOASYNC		(0x00000080)
515 #define	MT_FORCEROLL		(0x00000100)
516 #define	MT_SCAN			(0x00000200)
517 
518 struct logstats {
519 	kstat_named_t ls_lreads;	/* master reads */
520 	kstat_named_t ls_lwrites;	/* master writes */
521 	kstat_named_t ls_lreadsinmem;	/* log reads in memory */
522 	kstat_named_t ls_ldlreads;	/* log reads */
523 	kstat_named_t ls_ldlwrites;	/* log writes */
524 	kstat_named_t ls_mreads;	/* log master reads */
525 	kstat_named_t ls_rreads;	/* log roll reads */
526 	kstat_named_t ls_rwrites;	/* log roll writes */
527 };
528 
529 #ifdef _KERNEL
530 
531 typedef struct threadtrans {
532 	ulong_t		deltas_size;	/* size of deltas this transaction */
533 	uint32_t	last_async_tid;	/* last async transaction id */
534 	uchar_t		any_deltas;	/* any deltas done this transaction */
535 #ifdef DEBUG
536 	uint_t		topid;		/* transaction type */
537 	ulong_t		esize;		/* estimated trans size */
538 	ulong_t		rsize;		/* real trans size */
539 	dev_t		dev;		/* device */
540 #endif /* DEBUG */
541 } threadtrans_t;
542 
543 /*
544  * Log layer protos -- lufs_log.c
545  */
546 extern void		ldl_strategy(ml_unit_t *, buf_t *);
547 extern void		ldl_round_commit(ml_unit_t *);
548 extern void		ldl_push_commit(ml_unit_t *);
549 extern int		ldl_need_commit(ml_unit_t *);
550 extern int		ldl_has_space(ml_unit_t *, mapentry_t *);
551 extern void		ldl_write(ml_unit_t *, caddr_t, offset_t, mapentry_t *);
552 extern void		ldl_waito(ml_unit_t *);
553 extern int		ldl_read(ml_unit_t *, caddr_t, offset_t, off_t,
554 					mapentry_t *);
555 extern void		ldl_sethead(ml_unit_t *, off_t, uint32_t);
556 extern void		ldl_settail(ml_unit_t *, off_t, size_t);
557 extern ulong_t		ldl_logscan_nbcommit(off_t);
558 extern int		ldl_logscan_read(ml_unit_t *, off_t *, size_t, caddr_t);
559 extern void		ldl_logscan_begin(ml_unit_t *);
560 extern void		ldl_logscan_end(ml_unit_t *);
561 extern int		ldl_need_roll(ml_unit_t *);
562 extern void		ldl_seterror(ml_unit_t *, char *);
563 extern size_t		ldl_bufsize(ml_unit_t *);
564 extern void		ldl_savestate(ml_unit_t *);
565 extern void		free_cirbuf(cirbuf_t *);
566 extern void		alloc_rdbuf(cirbuf_t *, size_t, size_t);
567 extern void		alloc_wrbuf(cirbuf_t *, size_t);
568 
569 /*
570  * trans driver layer -- lufs.c
571  */
572 extern int		trans_not_wait(struct buf *cb);
573 extern int		trans_not_done(struct buf *cb);
574 extern int		trans_wait(struct buf *cb);
575 extern int		trans_done(struct buf *cb);
576 extern void		lufs_strategy(ml_unit_t *, buf_t *);
577 extern void		lufs_read_strategy(ml_unit_t *, buf_t *);
578 extern void		lufs_write_strategy(ml_unit_t *, buf_t *);
579 extern void		lufs_init(void);
580 extern int		lufs_enable(struct vnode *, struct fiolog *, cred_t *);
581 extern int		lufs_disable(vnode_t *, struct fiolog *);
582 
583 /*
584  * transaction op layer -- lufs_top.c
585  */
586 extern void	_init_top(void);
587 extern int	top_read_roll(rollbuf_t *, ml_unit_t *);
588 
589 
590 /*
591  * map layer -- lufs_map.c
592  */
593 extern void		map_free_entries(mt_map_t *);
594 extern int		matamap_overlap(mt_map_t *, offset_t, off_t);
595 extern int		matamap_within(mt_map_t *, offset_t, off_t);
596 extern int		deltamap_need_commit(mt_map_t *);
597 extern void		deltamap_add(mt_map_t *, offset_t, off_t, delta_t,
598 				int (*)(), ulong_t, threadtrans_t *tp);
599 extern mapentry_t	*deltamap_remove(mt_map_t *, offset_t, off_t);
600 extern void		deltamap_del(mt_map_t *, offset_t, off_t);
601 extern void		deltamap_push(ml_unit_t *);
602 extern void		logmap_cancel_remove(mt_map_t *);
603 extern int		logmap_need_commit(mt_map_t *);
604 extern int		logmap_need_roll_async(mt_map_t *);
605 extern int		logmap_need_roll_sync(mt_map_t *);
606 extern void		logmap_start_roll(ml_unit_t *);
607 extern void		logmap_kill_roll(ml_unit_t *);
608 extern void		logmap_forceroll(mt_map_t *);
609 extern void		logmap_forceroll_nowait(mt_map_t *);
610 extern int		logmap_overlap(mt_map_t *, offset_t, off_t);
611 extern void		logmap_remove_roll(mt_map_t *, offset_t, off_t);
612 extern int		logmap_next_roll(mt_map_t *, offset_t *);
613 extern int		logmap_list_get(mt_map_t *, offset_t, off_t,
614 				mapentry_t **);
615 extern int		logmap_list_get_roll(mt_map_t *, offset_t, rollbuf_t *);
616 extern void		logmap_list_put(mt_map_t *, mapentry_t *);
617 extern void		logmap_list_put_roll(mt_map_t *, mapentry_t *);
618 extern int		logmap_setup_read(mapentry_t *, rollbuf_t *);
619 extern void		logmap_make_space(struct mt_map *, ml_unit_t *,
620 				mapentry_t *);
621 extern void		logmap_add(ml_unit_t *, char *, offset_t, mapentry_t *);
622 extern void		logmap_add_buf(ml_unit_t *, char *, offset_t,
623 				mapentry_t *, caddr_t, uint32_t);
624 extern void		logmap_commit(ml_unit_t *, uint32_t);
625 extern void		logmap_sethead(mt_map_t *, ml_unit_t *);
626 extern void		logmap_settail(mt_map_t *, ml_unit_t *);
627 extern void		logmap_roll_dev(ml_unit_t *ul);
628 extern void		logmap_cancel(ml_unit_t *, offset_t, off_t, int);
629 extern void		logmap_free_cancel(mt_map_t *, mapentry_t **);
630 extern int		logmap_iscancel(mt_map_t *, offset_t, off_t);
631 extern void		logmap_logscan(ml_unit_t *);
632 extern mt_map_t		*map_put(mt_map_t *);
633 extern mt_map_t		*map_get(ml_unit_t *, enum maptypes, int);
634 extern void		_init_map(void);
635 
636 /*
637  * scan and roll threads -- lufs_thread.c
638  */
639 extern void	trans_roll(ml_unit_t *);
640 
641 /*
642  * DEBUG
643  */
644 #ifdef	DEBUG
645 extern int	map_put_debug(mt_map_t *);
646 extern int	map_get_debug(ml_unit_t *, mt_map_t *);
647 extern int	top_write_debug(ml_unit_t *, mapentry_t *, offset_t, off_t);
648 extern int	matamap_overlap(mt_map_t *, offset_t, off_t);
649 extern int	ldl_sethead_debug(ml_unit_t *);
650 extern int	map_check_linkage(mt_map_t *);
651 extern int	logmap_logscan_debug(mt_map_t *, mapentry_t *);
652 extern int	map_check_ldl_write(ml_unit_t *, caddr_t, offset_t,
653 								mapentry_t *);
654 extern int	logmap_logscan_commit_debug(off_t, mt_map_t *);
655 extern int	logmap_logscan_add_debug(struct delta *, mt_map_t *);
656 extern int	top_delta_debug(ml_unit_t *, offset_t, off_t, delta_t);
657 extern int	top_begin_debug(ml_unit_t *, top_t, ulong_t);
658 extern int	top_end_debug(ml_unit_t *, mt_map_t *, top_t, ulong_t);
659 extern int	top_roll_debug(ml_unit_t *);
660 extern int	top_init_debug(void);
661 extern int	lufs_initialize_debug(ml_odunit_t *);
662 #endif	/* DEBUG */
663 
664 extern uint64_t delta_stats[DT_MAX];
665 extern uint64_t roll_stats[DT_MAX];
666 extern struct logstats logstats;
667 extern int ufs_crb_enable;
668 
669 extern uint_t topkey;
670 extern uint32_t ufs_ncg_log;
671 
672 extern uint_t lufs_debug;
673 extern uint32_t	last_loghead_ident;
674 
675 #endif	/* _KERNEL */
676 
677 #ifdef	__cplusplus
678 }
679 #endif
680 
681 #endif	/* _SYS_FS_UFS_LOG_H */
682