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