xref: /onnv-gate/usr/src/uts/common/sys/lvm/md_trans.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SYS_MD_TRANS_H
28*0Sstevel@tonic-gate #define	_SYS_MD_TRANS_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/lvm/mdvar.h>
33*0Sstevel@tonic-gate #include <sys/buf.h>
34*0Sstevel@tonic-gate #include <sys/fs/ufs_trans.h>
35*0Sstevel@tonic-gate #include <sys/lvm/md_rename.h>
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #ifdef	__cplusplus
38*0Sstevel@tonic-gate extern "C" {
39*0Sstevel@tonic-gate #endif
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #define	LDL_META_SBLK		(16)
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #define	LDL_MINLOGSIZE		(1024*1024)
44*0Sstevel@tonic-gate #define	LDL_MAXLOGSIZE		(1024*1024*1024)
45*0Sstevel@tonic-gate #define	LDL_MINBUFSIZE		(32*1024)
46*0Sstevel@tonic-gate #define	LDL_USABLE_BSIZE	(DEV_BSIZE - sizeof (sect_trailer_t))
47*0Sstevel@tonic-gate #define	NB_LEFT_IN_SECTOR(off) 	(LDL_USABLE_BSIZE - ((off) - dbtob(btodb(off))))
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate typedef struct cirbuf32 {
50*0Sstevel@tonic-gate 	caddr32_t	xx_cb_bp;	/* buf's with space in circular buf */
51*0Sstevel@tonic-gate 	caddr32_t	xx_cb_dirty;	/* filling this buffer for log write */
52*0Sstevel@tonic-gate 	caddr32_t	xx_cb_free;	/* free bufs list */
53*0Sstevel@tonic-gate 	caddr32_t	xx_cb_va;	/* address of circular buffer */
54*0Sstevel@tonic-gate 	uint_t		xx_cb_nb;	/* size of circular buffer */
55*0Sstevel@tonic-gate 	uint_t		xx_cb_rwlock[3]; /* r/w lock to protect list mgmt. */
56*0Sstevel@tonic-gate } cirbuf32_t;
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate typedef struct cirbuf_ic {
59*0Sstevel@tonic-gate 	buf_t		*cb_bp;		/* buf's with space in circular buf */
60*0Sstevel@tonic-gate 	buf_t		*cb_dirty;	/* filling this buffer for log write */
61*0Sstevel@tonic-gate 	buf_t		*cb_free;	/* free bufs list */
62*0Sstevel@tonic-gate 	caddr_t		cb_va;		/* address of circular buffer */
63*0Sstevel@tonic-gate 	size_t		cb_nb;		/* size of circular buffer */
64*0Sstevel@tonic-gate 	md_krwlock_t	cb_rwlock;	/* r/w lock to protect list mgmt. */
65*0Sstevel@tonic-gate } cirbuf_ic_t;
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate typedef struct ml_unit {
69*0Sstevel@tonic-gate 	uint_t		un_revision;	/* revision number */
70*0Sstevel@tonic-gate 	/*
71*0Sstevel@tonic-gate 	 * mdd infrastructure stuff
72*0Sstevel@tonic-gate 	 */
73*0Sstevel@tonic-gate 	mddb_recid_t	un_recid;	/* db record id */
74*0Sstevel@tonic-gate 	mdkey_t		un_key;		/* namespace key */
75*0Sstevel@tonic-gate 	md_dev64_t	un_dev;		/* device number */
76*0Sstevel@tonic-gate 	uint_t		un_opencnt;	/* open count */
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate 	/*
79*0Sstevel@tonic-gate 	 * metatrans infrastructure stuff
80*0Sstevel@tonic-gate 	 */
81*0Sstevel@tonic-gate 	uint_t		un_transcnt;	/* #open metatrans devices */
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate 	/*
84*0Sstevel@tonic-gate 	 * log specific stuff
85*0Sstevel@tonic-gate 	 */
86*0Sstevel@tonic-gate 	off32_t		un_head_lof;	/* byte offset of head */
87*0Sstevel@tonic-gate 	uint_t		un_head_ident;	/* head sector id # */
88*0Sstevel@tonic-gate 	off32_t		un_tail_lof;	/* byte offset of tail */
89*0Sstevel@tonic-gate 	uint_t		un_tail_ident;	/* tail sector id # */
90*0Sstevel@tonic-gate 	off32_t		un_bol_lof;	/* byte offset of begin of log */
91*0Sstevel@tonic-gate 	off32_t		un_eol_lof;	/* byte offset of end of log */
92*0Sstevel@tonic-gate 	daddr32_t	un_nblks;	/* total blocks of log space */
93*0Sstevel@tonic-gate 	daddr32_t	un_tblks;	/* total blocks in log device */
94*0Sstevel@tonic-gate 	uint_t		un_maxtransfer;	/* max transfer in bytes */
95*0Sstevel@tonic-gate 	uint_t		un_status;	/* status bits */
96*0Sstevel@tonic-gate 	uint_t		un_maxresv;	/* maximum reservable space */
97*0Sstevel@tonic-gate 	daddr32_t	un_pwsblk;	/* block number of prewrite area */
98*0Sstevel@tonic-gate 	ulong_t		un_devbsize;	/* device bsize */
99*0Sstevel@tonic-gate 	uint_t		un_resv;	/* reserved byte count for this trans */
100*0Sstevel@tonic-gate 	uint_t		un_resv_wantin;	/* reserved byte count for next trans */
101*0Sstevel@tonic-gate 	mt_l_error_t	un_error;	/* error state */
102*0Sstevel@tonic-gate 	uint_t		un_tid;		/* used during logscan */
103*0Sstevel@tonic-gate 	uint_t		un_head_tid;	/* used for logscan; set at sethead */
104*0Sstevel@tonic-gate 	struct timeval32 un_timestamp;	/* time of last state change */
105*0Sstevel@tonic-gate 	/*
106*0Sstevel@tonic-gate 	 * spares
107*0Sstevel@tonic-gate 	 */
108*0Sstevel@tonic-gate 	uint_t		un_spare[16];
109*0Sstevel@tonic-gate 	/*
110*0Sstevel@tonic-gate 	 * following are incore only elements.
111*0Sstevel@tonic-gate 	 * Incore elements must always be at the end
112*0Sstevel@tonic-gate 	 * of this data struture.
113*0Sstevel@tonic-gate 	 */
114*0Sstevel@tonic-gate 	struct ml_unit	*un_next;
115*0Sstevel@tonic-gate 	struct mt_unit	*un_utlist;
116*0Sstevel@tonic-gate 	struct mt_map	*un_logmap;
117*0Sstevel@tonic-gate 	cirbuf_ic_t	un_rdbuf;
118*0Sstevel@tonic-gate 	cirbuf_ic_t	un_wrbuf;
119*0Sstevel@tonic-gate 	kmutex_t	un_log_mutex;
120*0Sstevel@tonic-gate } ml_unit_t;
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
124*0Sstevel@tonic-gate #pragma pack(4)
125*0Sstevel@tonic-gate #endif
126*0Sstevel@tonic-gate typedef struct ml_unit32_od {
127*0Sstevel@tonic-gate 	uint_t		un_revision;	/* revision number */
128*0Sstevel@tonic-gate 	/*
129*0Sstevel@tonic-gate 	 * mdd infrastructure stuff
130*0Sstevel@tonic-gate 	 */
131*0Sstevel@tonic-gate 	caddr32_t	xx_un_next;	/* next log unit struct */
132*0Sstevel@tonic-gate 	mddb_recid_t	un_recid;	/* db record id */
133*0Sstevel@tonic-gate 	mdkey_t		un_key;		/* namespace key */
134*0Sstevel@tonic-gate 	dev32_t		un_dev;		/* device number */
135*0Sstevel@tonic-gate 	uint_t		un_opencnt;	/* open count */
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate 	/*
138*0Sstevel@tonic-gate 	 * metatrans infrastructure stuff
139*0Sstevel@tonic-gate 	 */
140*0Sstevel@tonic-gate 	uint_t		un_transcnt;	/* #open metatrans devices */
141*0Sstevel@tonic-gate 	caddr32_t	xx_un_utlist;	/* list of metatrans devices */
142*0Sstevel@tonic-gate 	caddr32_t	xx_un_logmap;	/* address of logmap */
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate 	/*
145*0Sstevel@tonic-gate 	 * log specific stuff
146*0Sstevel@tonic-gate 	 */
147*0Sstevel@tonic-gate 	off32_t		un_head_lof;	/* byte offset of head */
148*0Sstevel@tonic-gate 	uint_t		un_head_ident;	/* head sector id # */
149*0Sstevel@tonic-gate 	off32_t		un_tail_lof;	/* byte offset of tail */
150*0Sstevel@tonic-gate 	uint_t		un_tail_ident;	/* tail sector id # */
151*0Sstevel@tonic-gate 	off32_t		un_bol_lof;	/* byte offset of begin of log */
152*0Sstevel@tonic-gate 	off32_t		un_eol_lof;	/* byte offset of end of log */
153*0Sstevel@tonic-gate 	daddr32_t	un_nblks;	/* total blocks of log space */
154*0Sstevel@tonic-gate 	daddr32_t	un_tblks;	/* total blocks in log device */
155*0Sstevel@tonic-gate 	uint_t		un_maxtransfer;	/* max transfer in bytes */
156*0Sstevel@tonic-gate 	uint_t		un_status;	/* status bits */
157*0Sstevel@tonic-gate 	uint_t		un_maxresv;	/* maximum reservable space */
158*0Sstevel@tonic-gate 	daddr32_t	un_pwsblk;	/* block number of prewrite area */
159*0Sstevel@tonic-gate 	uint_t		un_devbsize;	/* device bsize */
160*0Sstevel@tonic-gate 	uint_t		un_resv;	/* reserved byte count for this trans */
161*0Sstevel@tonic-gate 	uint_t		un_resv_wantin;	/* reserved byte count for next trans */
162*0Sstevel@tonic-gate 	mt_l_error_t	un_error;	/* error state */
163*0Sstevel@tonic-gate 	uint_t		un_tid;		/* used during logscan */
164*0Sstevel@tonic-gate 	uint_t		un_head_tid;	/* used for logscan; set at sethead */
165*0Sstevel@tonic-gate 	cirbuf32_t	xx_un_rdbuf;	/* read buffer space */
166*0Sstevel@tonic-gate 	cirbuf32_t	xx_un_wrbuf;	/* write buffer space */
167*0Sstevel@tonic-gate 	int		xx_un_log_mutex[2]; /* allows one log write at a time */
168*0Sstevel@tonic-gate 	struct timeval32 un_timestamp;	/* time of last state change */
169*0Sstevel@tonic-gate 	/*
170*0Sstevel@tonic-gate 	 * spares
171*0Sstevel@tonic-gate 	 */
172*0Sstevel@tonic-gate 	uint_t		un_spare[16];
173*0Sstevel@tonic-gate } ml_unit32_od_t;
174*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
175*0Sstevel@tonic-gate #pragma pack()
176*0Sstevel@tonic-gate #endif
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate 
180*0Sstevel@tonic-gate #define	ML_UNIT_ONDSZ	((size_t)((caddr_t)&((ml_unit_t *)0)->un_spare[15] +\
181*0Sstevel@tonic-gate 				sizeof (uint_t)))
182*0Sstevel@tonic-gate 
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate /*
185*0Sstevel@tonic-gate  *	un_status
186*0Sstevel@tonic-gate  */
187*0Sstevel@tonic-gate #define	LDL_BEING_RESET	0x0001	/* delete the log record at snarf */
188*0Sstevel@tonic-gate #define	LDL_FIND_TAIL	0x0002	/* find tail of the log */
189*0Sstevel@tonic-gate #define	LDL_SCAN_ACTIVE	0x0004	/* log scan in progress */
190*0Sstevel@tonic-gate #define	LDL_METADEVICE	0x0008	/* underlying device is metadevice */
191*0Sstevel@tonic-gate #define	LDL_PWVALID	0x0010	/* prewrite area is valid */
192*0Sstevel@tonic-gate #define	LDL_INFO	0x0020	/* prewrite state is valid */
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate typedef struct sect_trailer {
195*0Sstevel@tonic-gate 	uint_t		st_tid;		/* transaction id */
196*0Sstevel@tonic-gate 	uint_t		st_ident;	/* unique sector id */
197*0Sstevel@tonic-gate } sect_trailer_t;
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate 
200*0Sstevel@tonic-gate /*
201*0Sstevel@tonic-gate  * ioctls
202*0Sstevel@tonic-gate  */
203*0Sstevel@tonic-gate #define	MD_IOCGET_LOG		(MDIOC_MISC|0)
204*0Sstevel@tonic-gate #define	MD_IOC_DEBUG		(MDIOC_MISC|4)
205*0Sstevel@tonic-gate #define	MD_IOCGET_TRANSSTATS	(MDIOC_MISC|5)
206*0Sstevel@tonic-gate #define	MD_IOC_TSD		(MDIOC_MISC|6)
207*0Sstevel@tonic-gate #define	MD_IOC_TRYGETBLK	(MDIOC_MISC|7)
208*0Sstevel@tonic-gate #define	MD_IOC_TRYPAGE		(MDIOC_MISC|8)
209*0Sstevel@tonic-gate #define	MD_IOC_SETSHADOW	(MDIOC_MISC|11)
210*0Sstevel@tonic-gate #define	MD_IOC_INJECTERRORS	(MDIOC_MISC|13)
211*0Sstevel@tonic-gate #define	MD_IOC_STOPERRORS	(MDIOC_MISC|14)
212*0Sstevel@tonic-gate #define	MD_IOC_UFSERROR		(MDIOC_MISC|15)
213*0Sstevel@tonic-gate #define	MD_IOC_ISDEBUG		(MDIOC_MISC|17)
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate #define	MD_IOC_TRANS_DETACH	(MDIOC_MISC|32)
216*0Sstevel@tonic-gate 
217*0Sstevel@tonic-gate /*
218*0Sstevel@tonic-gate  * following bits are used in status word in the common section
219*0Sstevel@tonic-gate  * of unit structure
220*0Sstevel@tonic-gate  */
221*0Sstevel@tonic-gate #define	MD_UN_LOG_DELETED	(0x00010000)	/* don't need to del @snarf */
222*0Sstevel@tonic-gate 
223*0Sstevel@tonic-gate /*
224*0Sstevel@tonic-gate  * map block
225*0Sstevel@tonic-gate  */
226*0Sstevel@tonic-gate #define	MAPBLOCKSIZE	(8192)
227*0Sstevel@tonic-gate #define	MAPBLOCKSHIFT	(13)
228*0Sstevel@tonic-gate #define	MAPBLOCKOFF	(MAPBLOCKSIZE-1)
229*0Sstevel@tonic-gate #define	MAPBLOCKMASK	(~MAPBLOCKOFF)
230*0Sstevel@tonic-gate 
231*0Sstevel@tonic-gate /*
232*0Sstevel@tonic-gate  * delta header
233*0Sstevel@tonic-gate  */
234*0Sstevel@tonic-gate struct delta {
235*0Sstevel@tonic-gate 	offset_t	d_mof;
236*0Sstevel@tonic-gate 	off32_t		d_nb;
237*0Sstevel@tonic-gate 	dev32_t		d_dev;
238*0Sstevel@tonic-gate 	delta_t 	d_typ;
239*0Sstevel@tonic-gate };
240*0Sstevel@tonic-gate 
241*0Sstevel@tonic-gate /*
242*0Sstevel@tonic-gate  * common map entry
243*0Sstevel@tonic-gate  */
244*0Sstevel@tonic-gate typedef struct mapentry	mapentry_t;
245*0Sstevel@tonic-gate struct mapentry {
246*0Sstevel@tonic-gate 	/*
247*0Sstevel@tonic-gate 	 * doubly linked list of all mapentries in map -- MUST BE FIRST
248*0Sstevel@tonic-gate 	 */
249*0Sstevel@tonic-gate 	mapentry_t	*me_next;
250*0Sstevel@tonic-gate 	mapentry_t	*me_prev;
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate 	mapentry_t	*me_hash;
253*0Sstevel@tonic-gate 	mapentry_t	*me_agenext;
254*0Sstevel@tonic-gate 	mapentry_t	*me_cancel;
255*0Sstevel@tonic-gate 	int		(*me_func)();
256*0Sstevel@tonic-gate 	uintptr_t	me_arg;
257*0Sstevel@tonic-gate 	off_t		me_lof;
258*0Sstevel@tonic-gate 	uint_t		me_flags;
259*0Sstevel@tonic-gate 	uint_t		me_tid;
260*0Sstevel@tonic-gate 	uint_t		me_age;
261*0Sstevel@tonic-gate 	struct delta	me_delta;
262*0Sstevel@tonic-gate };
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate #define	me_mof	me_delta.d_mof
265*0Sstevel@tonic-gate #define	me_nb	me_delta.d_nb
266*0Sstevel@tonic-gate #define	me_dt	me_delta.d_typ
267*0Sstevel@tonic-gate #define	me_dev	me_delta.d_dev
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate /*
270*0Sstevel@tonic-gate  * me_flags
271*0Sstevel@tonic-gate  */
272*0Sstevel@tonic-gate #define	ME_FREE		(0x0001)	/* on free   list */
273*0Sstevel@tonic-gate #define	ME_HASH		(0x0002)	/* on hash   list */
274*0Sstevel@tonic-gate #define	ME_CANCEL	(0x0004)	/* on cancel list */
275*0Sstevel@tonic-gate #define	ME_AGE		(0x0008)	/* on age    list */
276*0Sstevel@tonic-gate #define	ME_LIST		(0x0010)	/* on list   list */
277*0Sstevel@tonic-gate #define	ME_ROLL		(0x0020)	/* on pseudo-roll list */
278*0Sstevel@tonic-gate 
279*0Sstevel@tonic-gate /*
280*0Sstevel@tonic-gate  * TRANSACTION OPS STATS
281*0Sstevel@tonic-gate  * mt_top_size_* should be 64bit but that would
282*0Sstevel@tonic-gate  * require test recompilations. It does not hurt the kernel
283*0Sstevel@tonic-gate  * so leave as 32 bit for now.
284*0Sstevel@tonic-gate  */
285*0Sstevel@tonic-gate struct topstats {
286*0Sstevel@tonic-gate 	uint_t		mtm_top_num[TOP_MAX];
287*0Sstevel@tonic-gate 	uint_t		mtm_top_size_etot[TOP_MAX];
288*0Sstevel@tonic-gate 	uint_t		mtm_top_size_rtot[TOP_MAX];
289*0Sstevel@tonic-gate 	uint_t		mtm_top_size_max[TOP_MAX];
290*0Sstevel@tonic-gate 	uint_t		mtm_top_size_min[TOP_MAX];
291*0Sstevel@tonic-gate 	uint_t		mtm_delta_num[DT_MAX];
292*0Sstevel@tonic-gate };
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate /*
295*0Sstevel@tonic-gate  * MAP STATS (global struct that is not updated if compiled w/o ASSERTs)
296*0Sstevel@tonic-gate  * some members of transstats need to be 64bit. See the comment above.
297*0Sstevel@tonic-gate  */
298*0Sstevel@tonic-gate struct transstats {
299*0Sstevel@tonic-gate 	/* trans.c */
300*0Sstevel@tonic-gate 	uint_t		ts_trans_zalloc;
301*0Sstevel@tonic-gate 	uint_t		ts_trans_zalloc_nosleep;
302*0Sstevel@tonic-gate 	uint_t		ts_trans_alloc;
303*0Sstevel@tonic-gate 	uint_t		ts_trans_alloc_nosleep;
304*0Sstevel@tonic-gate 	uint_t		ts_trans_free;
305*0Sstevel@tonic-gate 	uint_t		ts_trans_alloced;
306*0Sstevel@tonic-gate 	uint_t		ts_trans_freed;
307*0Sstevel@tonic-gate 	uint_t		ts_trans_write;
308*0Sstevel@tonic-gate 	uint_t		ts_trans_write_roll;
309*0Sstevel@tonic-gate 
310*0Sstevel@tonic-gate 	/* trans_delta.c */
311*0Sstevel@tonic-gate 	uint_t		ts_mapentry_alloc;
312*0Sstevel@tonic-gate 	uint_t		ts_mapentry_alloc_list;
313*0Sstevel@tonic-gate 	uint_t		ts_mapentry_free;
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate 	uint_t		ts_delta_add;
316*0Sstevel@tonic-gate 	uint_t		ts_delta_add_scan;
317*0Sstevel@tonic-gate 	uint_t		ts_delta_add_hit;
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate 	uint_t		ts_delta_remove;
320*0Sstevel@tonic-gate 	uint_t		ts_delta_remove_scan;
321*0Sstevel@tonic-gate 	uint_t		ts_delta_remove_hit;
322*0Sstevel@tonic-gate 
323*0Sstevel@tonic-gate 	uint_t		ts_delta_del;
324*0Sstevel@tonic-gate 	uint_t		ts_delta_del_scan;
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate 	uint_t		ts_delta_push;
327*0Sstevel@tonic-gate 
328*0Sstevel@tonic-gate 	uint_t		ts_overlap;
329*0Sstevel@tonic-gate 	uint_t		ts_overlap_scan;
330*0Sstevel@tonic-gate 	uint_t		ts_overlap_hit;
331*0Sstevel@tonic-gate 
332*0Sstevel@tonic-gate 	uint_t		ts_remove_roll;
333*0Sstevel@tonic-gate 	uint_t		ts_remove_roll_scan;
334*0Sstevel@tonic-gate 	uint_t		ts_remove_roll_hit;
335*0Sstevel@tonic-gate 	uint_t		ts_remove_roll_dolock;
336*0Sstevel@tonic-gate 	uint_t		ts_remove_roll_sud;
337*0Sstevel@tonic-gate 
338*0Sstevel@tonic-gate 	uint_t		ts_next_roll;
339*0Sstevel@tonic-gate 	uint_t		ts_next_roll_scan;
340*0Sstevel@tonic-gate 	uint_t		ts_next_roll_hit;
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate 	uint_t		ts_list_age;
343*0Sstevel@tonic-gate 	uint_t		ts_list_age_scan;
344*0Sstevel@tonic-gate 
345*0Sstevel@tonic-gate 	uint_t		ts_list_get;
346*0Sstevel@tonic-gate 	uint_t		ts_list_get_scan;
347*0Sstevel@tonic-gate 	uint_t		ts_list_get_hit;
348*0Sstevel@tonic-gate 	uint_t		ts_list_get_again;
349*0Sstevel@tonic-gate 
350*0Sstevel@tonic-gate 	uint_t		ts_list_put;
351*0Sstevel@tonic-gate 	uint_t		ts_list_put_scan;
352*0Sstevel@tonic-gate 
353*0Sstevel@tonic-gate 	uint_t		ts_read_mstr;
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate 	uint_t		ts_logmap_secmap_roll;
356*0Sstevel@tonic-gate 
357*0Sstevel@tonic-gate 	uint_t		ts_read_log;
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate 	uint_t		ts_logmap_abort;
360*0Sstevel@tonic-gate 	uint_t		ts_logmap_abort_hit;
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate 	uint_t		ts_list_add;
363*0Sstevel@tonic-gate 	uint_t		ts_list_add_scan;
364*0Sstevel@tonic-gate 	uint_t		ts_list_add_cancel;
365*0Sstevel@tonic-gate 	uint_t		ts_list_add_unhash;
366*0Sstevel@tonic-gate 
367*0Sstevel@tonic-gate 	uint_t		ts_free_cancel;
368*0Sstevel@tonic-gate 	uint_t		ts_free_cancel_again;
369*0Sstevel@tonic-gate 	uint_t		ts_free_cancel_scan;
370*0Sstevel@tonic-gate 	uint_t		ts_free_cancel_hit;
371*0Sstevel@tonic-gate 
372*0Sstevel@tonic-gate 	uint_t		ts_commit;
373*0Sstevel@tonic-gate 	uint_t		ts_commit_hit;
374*0Sstevel@tonic-gate 
375*0Sstevel@tonic-gate 	uint_t		ts_logmap_roll_dev;
376*0Sstevel@tonic-gate 	uint_t		ts_logmap_roll_dev_scan;
377*0Sstevel@tonic-gate 	uint_t		ts_logmap_roll_dev_hit;
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate 	uint_t		ts_logmap_roll_sud;
380*0Sstevel@tonic-gate 	uint_t		ts_logmap_roll_sud_hit;
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate 	uint_t		ts_logmap_ud_done;
383*0Sstevel@tonic-gate 	uint_t		ts_logmap_ud_done_scan;
384*0Sstevel@tonic-gate 
385*0Sstevel@tonic-gate 	uint_t		ts_logmap_ud_wait;
386*0Sstevel@tonic-gate 	uint_t		ts_logmap_ud_wait_hit;
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate 	uint_t		ts_logmap_ud_commit;
389*0Sstevel@tonic-gate 	uint_t		ts_logmap_ud_commit_scan;
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate 	uint_t		ts_logmap_cancel;
392*0Sstevel@tonic-gate 	uint_t		ts_logmap_cancel_scan;
393*0Sstevel@tonic-gate 	uint_t		ts_logmap_cancel_hit;
394*0Sstevel@tonic-gate 
395*0Sstevel@tonic-gate 	uint_t		ts_logmap_iscancel;
396*0Sstevel@tonic-gate 	uint_t		ts_logmap_iscancel_scan;
397*0Sstevel@tonic-gate 	uint_t		ts_logmap_iscancel_hit;
398*0Sstevel@tonic-gate 
399*0Sstevel@tonic-gate 	uint_t		ts_logscan;
400*0Sstevel@tonic-gate 	uint_t		ts_logscan_ud;
401*0Sstevel@tonic-gate 	uint_t		ts_logscan_delta;
402*0Sstevel@tonic-gate 	uint_t		ts_logscan_cancel;
403*0Sstevel@tonic-gate 	uint_t		ts_logscan_commit;
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate 	/* trans_thread.c */
406*0Sstevel@tonic-gate 	uint_t		ts_prewrite;
407*0Sstevel@tonic-gate 	uint_t		ts_prewrite_read;
408*0Sstevel@tonic-gate 	uint_t		ts_prewrite_write;
409*0Sstevel@tonic-gate 	uint_t		ts_trans_roll;
410*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_wait;
411*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_wait_nada;
412*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_wait_slow;
413*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_force;
414*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_nsud;
415*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_ref;
416*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_full;
417*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_logmap;
418*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_read;
419*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_reread;
420*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_wait_inuse;
421*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_prewrite;
422*0Sstevel@tonic-gate 	uint_t		ts_trans_roll_write;
423*0Sstevel@tonic-gate 
424*0Sstevel@tonic-gate 	/* trans_top.c */
425*0Sstevel@tonic-gate 	uint_t		ts_delta;
426*0Sstevel@tonic-gate 	uint_t		ts_ud_delta;
427*0Sstevel@tonic-gate 	uint_t		ts_ud_delta_log;
428*0Sstevel@tonic-gate 	uint_t		ts_cancel;
429*0Sstevel@tonic-gate 	uint_t		ts_iscancel;
430*0Sstevel@tonic-gate 	uint_t		ts_error;
431*0Sstevel@tonic-gate 	uint_t		ts_iserror;
432*0Sstevel@tonic-gate 	uint_t		ts_beginsync;
433*0Sstevel@tonic-gate 	uint_t		ts_active;
434*0Sstevel@tonic-gate 	uint_t		ts_activesync;
435*0Sstevel@tonic-gate 	uint_t		ts_beginasync;
436*0Sstevel@tonic-gate 	uint_t		ts_endsync;
437*0Sstevel@tonic-gate 	uint_t		ts_wantin;
438*0Sstevel@tonic-gate 	uint_t		ts_endasync;
439*0Sstevel@tonic-gate 	uint_t		ts_read;
440*0Sstevel@tonic-gate 	uint_t		ts_read_roll;
441*0Sstevel@tonic-gate 	uint_t		ts_readmt;
442*0Sstevel@tonic-gate 	uint_t		ts_write;
443*0Sstevel@tonic-gate 	uint_t		ts_writemt;
444*0Sstevel@tonic-gate 	uint_t		ts_writemt_done;
445*0Sstevel@tonic-gate 	uint_t		ts_log;
446*0Sstevel@tonic-gate 
447*0Sstevel@tonic-gate 	/* trans_log.c */
448*0Sstevel@tonic-gate 	uint_t		ts_logcommitdb;
449*0Sstevel@tonic-gate 
450*0Sstevel@tonic-gate 	uint_t		ts_push_dirty_bp;
451*0Sstevel@tonic-gate 	uint_t		ts_push_dirty_bp_extra;
452*0Sstevel@tonic-gate 	uint_t		ts_push_dirty_bp_fail;
453*0Sstevel@tonic-gate 
454*0Sstevel@tonic-gate 	uint_t		ts_alloc_bp;
455*0Sstevel@tonic-gate 	uint_t		ts_alloc_bp_free;
456*0Sstevel@tonic-gate 
457*0Sstevel@tonic-gate 	uint_t		ts_find_bp;
458*0Sstevel@tonic-gate 	uint_t		ts_find_bp_scan;
459*0Sstevel@tonic-gate 	uint_t		ts_find_bp_hit;
460*0Sstevel@tonic-gate 
461*0Sstevel@tonic-gate 	uint_t		ts_find_read_lof;
462*0Sstevel@tonic-gate 	uint_t		ts_find_read_lof_scan;
463*0Sstevel@tonic-gate 	uint_t		ts_find_read_lof_hit;
464*0Sstevel@tonic-gate 
465*0Sstevel@tonic-gate 	uint_t		ts_get_read_bp;
466*0Sstevel@tonic-gate 	uint_t		ts_get_read_bp_wr;
467*0Sstevel@tonic-gate 	uint_t		ts_get_read_bp_rd;
468*0Sstevel@tonic-gate 
469*0Sstevel@tonic-gate 	uint_t		ts_extend_write_bp;
470*0Sstevel@tonic-gate 	uint_t		ts_extend_write_bp_hit;
471*0Sstevel@tonic-gate 
472*0Sstevel@tonic-gate 	uint_t		ts_storebuf;
473*0Sstevel@tonic-gate 	uint_t		ts_fetchbuf;
474*0Sstevel@tonic-gate 	uint_t		ts_round_commit;
475*0Sstevel@tonic-gate 	uint_t		ts_push_commit;
476*0Sstevel@tonic-gate 
477*0Sstevel@tonic-gate 	uint_t		ts_inval_range;
478*0Sstevel@tonic-gate 	uint_t		ts_inval_range_scan;
479*0Sstevel@tonic-gate 	uint_t		ts_inval_range_hit;
480*0Sstevel@tonic-gate 
481*0Sstevel@tonic-gate 	uint_t		ts_writelog;
482*0Sstevel@tonic-gate 	uint_t		ts_writelog_max;
483*0Sstevel@tonic-gate 
484*0Sstevel@tonic-gate 	uint_t		ts_readlog;
485*0Sstevel@tonic-gate 	uint_t		ts_readlog_max;
486*0Sstevel@tonic-gate 
487*0Sstevel@tonic-gate 	uint_t		ts_get_write_bp;
488*0Sstevel@tonic-gate 	uint_t		ts_get_write_bp_steal;
489*0Sstevel@tonic-gate 
490*0Sstevel@tonic-gate 	uint_t		ts_writesync;
491*0Sstevel@tonic-gate 	uint_t		ts_writesync_log;
492*0Sstevel@tonic-gate 	uint_t		ts_writesync_nolog;
493*0Sstevel@tonic-gate 
494*0Sstevel@tonic-gate 	uint_t		ts_longmof_cnt;
495*0Sstevel@tonic-gate 
496*0Sstevel@tonic-gate } transstats;
497*0Sstevel@tonic-gate 
498*0Sstevel@tonic-gate #ifdef	DEBUG
499*0Sstevel@tonic-gate #define	TRANSSTATS(f)		(transstats.f++)
500*0Sstevel@tonic-gate #define	TRANSSTATSADD(f, n)	(transstats.f += (n))
501*0Sstevel@tonic-gate #define	TRANSSTATSMAX(m, v)	\
502*0Sstevel@tonic-gate 		if ((v) > transstats.m)\
503*0Sstevel@tonic-gate 			transstats.m = (v);
504*0Sstevel@tonic-gate #else
505*0Sstevel@tonic-gate #define	TRANSSTATS(f)
506*0Sstevel@tonic-gate #define	TRANSSTATSADD(f, n)
507*0Sstevel@tonic-gate #define	TRANSSTATSMAX(m, v)
508*0Sstevel@tonic-gate #endif /* DEBUG */
509*0Sstevel@tonic-gate 
510*0Sstevel@tonic-gate /*
511*0Sstevel@tonic-gate  * MAP TYPES
512*0Sstevel@tonic-gate  */
513*0Sstevel@tonic-gate enum maptypes	{
514*0Sstevel@tonic-gate 	deltamaptype, udmaptype, logmaptype, matamaptype, shadowmaptype
515*0Sstevel@tonic-gate };
516*0Sstevel@tonic-gate 
517*0Sstevel@tonic-gate /*
518*0Sstevel@tonic-gate  * MAP
519*0Sstevel@tonic-gate  */
520*0Sstevel@tonic-gate #define	DELTAMAP_NHASH	(512)
521*0Sstevel@tonic-gate #define	LOGMAP_NHASH	(2048)
522*0Sstevel@tonic-gate #define	MAP_INDEX(dev, mof, mtm) \
523*0Sstevel@tonic-gate 	((((mof) >> MAPBLOCKSHIFT) + (dev)) & ((mtm)->mtm_nhash-1))
524*0Sstevel@tonic-gate #define	MAP_HASH(dev, mof, mtm) \
525*0Sstevel@tonic-gate 	(mtm->mtm_hash + MAP_INDEX(dev, mof, mtm))
526*0Sstevel@tonic-gate 
527*0Sstevel@tonic-gate typedef struct mt_map {
528*0Sstevel@tonic-gate 	/*
529*0Sstevel@tonic-gate 	 * anchor doubly linked list this map's entries -- MUST BE FIRST
530*0Sstevel@tonic-gate 	 */
531*0Sstevel@tonic-gate 	mapentry_t	*mtm_next;
532*0Sstevel@tonic-gate 	mapentry_t	*mtm_prev;
533*0Sstevel@tonic-gate 
534*0Sstevel@tonic-gate 	int		mtm_flags;	/* generic flags */
535*0Sstevel@tonic-gate 	int		mtm_ref;	/* PTE like ref bit */
536*0Sstevel@tonic-gate 	uint_t		mtm_debug;	/* set at create time */
537*0Sstevel@tonic-gate 	uint_t		mtm_age;	/* mono-inc; tags mapentries */
538*0Sstevel@tonic-gate 	mapentry_t	*mtm_cancel;	/* to be canceled at commit */
539*0Sstevel@tonic-gate 	uint_t		mtm_nhash;	/* # of hash anchors */
540*0Sstevel@tonic-gate 	mapentry_t	**mtm_hash;	/* array of singly linked lists */
541*0Sstevel@tonic-gate 	struct topstats	*mtm_tops;	/* trans ops - enabled by an ioctl */
542*0Sstevel@tonic-gate 	int		mtm_nme;	/* # of mapentries */
543*0Sstevel@tonic-gate 	int		mtm_nmet;	/* # of mapentries this transaction */
544*0Sstevel@tonic-gate 	int		mtm_nud;	/* # of active userdata writes */
545*0Sstevel@tonic-gate 	int		mtm_nsud;	/* # of userdata scanned deltas */
546*0Sstevel@tonic-gate 	md_dev64_t	mtm_dev;	/* device identifying map */
547*0Sstevel@tonic-gate 
548*0Sstevel@tonic-gate 	/*
549*0Sstevel@tonic-gate 	 * the following are protected by the global map_mutex
550*0Sstevel@tonic-gate 	 */
551*0Sstevel@tonic-gate 	struct mt_map	*mtm_mapnext;	/* singly linked list of all maps */
552*0Sstevel@tonic-gate 	uint_t		mtm_refcnt;	/* reference count to this map */
553*0Sstevel@tonic-gate 	enum maptypes	mtm_type;	/* type of map */
554*0Sstevel@tonic-gate 
555*0Sstevel@tonic-gate 	/*
556*0Sstevel@tonic-gate 	 * used after logscan to set the log's tail
557*0Sstevel@tonic-gate 	 */
558*0Sstevel@tonic-gate 	off_t		mtm_tail_lof;
559*0Sstevel@tonic-gate 	size_t		mtm_tail_nb;
560*0Sstevel@tonic-gate 
561*0Sstevel@tonic-gate 	/*
562*0Sstevel@tonic-gate 	 * debug field for Scan test
563*0Sstevel@tonic-gate 	 */
564*0Sstevel@tonic-gate 	off_t		mtm_trimlof;	/* log was trimmed to this lof */
565*0Sstevel@tonic-gate 	off_t		mtm_trimtail;	/* tail lof before trimming */
566*0Sstevel@tonic-gate 	off_t		mtm_trimalof;	/* lof of last allocation delta */
567*0Sstevel@tonic-gate 	off_t		mtm_trimclof;	/* lof of last commit delta */
568*0Sstevel@tonic-gate 	off_t		mtm_trimrlof;	/* lof of last rolled delta */
569*0Sstevel@tonic-gate 	struct ml_unit	*mtm_ul;	/* log unit for this map */
570*0Sstevel@tonic-gate 
571*0Sstevel@tonic-gate 	/*
572*0Sstevel@tonic-gate 	 * moby trans stuff
573*0Sstevel@tonic-gate 	 */
574*0Sstevel@tonic-gate 	uint_t			mtm_tid;
575*0Sstevel@tonic-gate 	uint_t			mtm_committid;
576*0Sstevel@tonic-gate 	ushort_t		mtm_closed;
577*0Sstevel@tonic-gate 	ushort_t		mtm_seq;
578*0Sstevel@tonic-gate 	int			mtm_wantin;
579*0Sstevel@tonic-gate 	int			mtm_active;
580*0Sstevel@tonic-gate 	int			mtm_activesync;
581*0Sstevel@tonic-gate 	uint_t			mtm_dirty;
582*0Sstevel@tonic-gate 	kmutex_t		mtm_lock;
583*0Sstevel@tonic-gate 	kcondvar_t		mtm_cv_commit;
584*0Sstevel@tonic-gate 	kcondvar_t		mtm_cv_next;
585*0Sstevel@tonic-gate 	kcondvar_t		mtm_cv_eot;
586*0Sstevel@tonic-gate 
587*0Sstevel@tonic-gate 	/*
588*0Sstevel@tonic-gate 	 * mutex that protects all the fields in mt_map except
589*0Sstevel@tonic-gate 	 * mtm_mapnext and mtm_refcnt
590*0Sstevel@tonic-gate 	 */
591*0Sstevel@tonic-gate 	kmutex_t	mtm_mutex;
592*0Sstevel@tonic-gate 	kcondvar_t	mtm_cv;		/* generic conditional */
593*0Sstevel@tonic-gate 
594*0Sstevel@tonic-gate 	/*
595*0Sstevel@tonic-gate 	 * rw lock for the mapentry fields agenext and locnext
596*0Sstevel@tonic-gate 	 */
597*0Sstevel@tonic-gate 	md_krwlock_t	mtm_rwlock;
598*0Sstevel@tonic-gate 	/*
599*0Sstevel@tonic-gate 	 * DEBUG: runtestscan
600*0Sstevel@tonic-gate 	 */
601*0Sstevel@tonic-gate 	kmutex_t	mtm_scan_mutex;
602*0Sstevel@tonic-gate } mt_map_t;
603*0Sstevel@tonic-gate 
604*0Sstevel@tonic-gate /*
605*0Sstevel@tonic-gate  * mtm_flags
606*0Sstevel@tonic-gate  */
607*0Sstevel@tonic-gate #define	MTM_ROLL_EXIT		(0x00000001)
608*0Sstevel@tonic-gate #define	MTM_ROLL_RUNNING	(0x00000002)
609*0Sstevel@tonic-gate #define	MTM_FORCE_ROLL		(0x00000004)
610*0Sstevel@tonic-gate 
611*0Sstevel@tonic-gate /*
612*0Sstevel@tonic-gate  * Generic range checking macros
613*0Sstevel@tonic-gate  */
614*0Sstevel@tonic-gate #define	OVERLAP(sof, snb, dof, dnb) \
615*0Sstevel@tonic-gate 	((sof >= dof && sof < (dof + dnb)) || \
616*0Sstevel@tonic-gate 	(dof >= sof && dof < (sof + snb)))
617*0Sstevel@tonic-gate 
618*0Sstevel@tonic-gate #define	WITHIN(sof, snb, dof, dnb) ((sof >= dof) && ((sof+snb) <= (dof+dnb)))
619*0Sstevel@tonic-gate 
620*0Sstevel@tonic-gate #define	DATAoverlapME(mof, hnb, me) (OVERLAP(mof, hnb, me->me_mof, me->me_nb))
621*0Sstevel@tonic-gate #define	MEwithinDATA(me, mof, hnb) (WITHIN(me->me_mof, me->me_nb, mof, hnb))
622*0Sstevel@tonic-gate #define	DATAwithinME(mof, hnb, me) (WITHIN(mof, hnb, me->me_mof, me->me_nb))
623*0Sstevel@tonic-gate 
624*0Sstevel@tonic-gate 
625*0Sstevel@tonic-gate typedef struct mt_unit {
626*0Sstevel@tonic-gate 	struct mdc_unit	c;		/* common stuff */
627*0Sstevel@tonic-gate 	/*
628*0Sstevel@tonic-gate 	 * infrastructure
629*0Sstevel@tonic-gate 	 */
630*0Sstevel@tonic-gate 	mt_flags_t	un_flags;
631*0Sstevel@tonic-gate 	/*
632*0Sstevel@tonic-gate 	 * log and master device
633*0Sstevel@tonic-gate 	 */
634*0Sstevel@tonic-gate 	mdkey_t		un_m_key;
635*0Sstevel@tonic-gate 	md_dev64_t	un_m_dev;
636*0Sstevel@tonic-gate 	mdkey_t		un_l_key;
637*0Sstevel@tonic-gate 	md_dev64_t	un_l_dev;
638*0Sstevel@tonic-gate 	daddr32_t	un_l_sblk;	/* start block */
639*0Sstevel@tonic-gate 	daddr32_t	un_l_pwsblk;	/* prewrite start block */
640*0Sstevel@tonic-gate 	daddr32_t	un_l_nblks;	/* # of usable log blocks */
641*0Sstevel@tonic-gate 	daddr32_t	un_l_tblks;	/* total log blocks */
642*0Sstevel@tonic-gate 	daddr32_t	un_l_head;	/* sector offset of log head */
643*0Sstevel@tonic-gate 	daddr32_t	un_l_tail;	/* sector offset of log tail */
644*0Sstevel@tonic-gate 	uint_t		un_l_resv;	/* current log reservations */
645*0Sstevel@tonic-gate 	uint_t		un_l_maxresv;	/* max log reservations */
646*0Sstevel@tonic-gate 	uint_t		un_l_maxtransfer; /* maximum transfer at init */
647*0Sstevel@tonic-gate 	mddb_recid_t	un_l_recid;	/* database id */
648*0Sstevel@tonic-gate 	mt_l_error_t	un_l_error;	/* error state */
649*0Sstevel@tonic-gate 	struct timeval32 un_l_timestamp; /* time of last log state chg */
650*0Sstevel@tonic-gate 	md_dev64_t	un_s_dev;	/* shadow device for testing only */
651*0Sstevel@tonic-gate 	mt_debug_t	un_debug;	/* debug flags; set at create */
652*0Sstevel@tonic-gate 	md_dev64_t	un_dev;		/* this metatrans device */
653*0Sstevel@tonic-gate 	int		un_logreset;	/* part of _FIOLOGRESET ioctl stuff */
654*0Sstevel@tonic-gate 	struct timeval32 un_timestamp;	/* time of last trans state change */
655*0Sstevel@tonic-gate 	/*
656*0Sstevel@tonic-gate 	 * spares
657*0Sstevel@tonic-gate 	 */
658*0Sstevel@tonic-gate 	ulong_t		un_spare[16];
659*0Sstevel@tonic-gate 	/*
660*0Sstevel@tonic-gate 	 * following are incore only elements.
661*0Sstevel@tonic-gate 	 * Incore elements must always be at the end
662*0Sstevel@tonic-gate 	 * of this data struture.
663*0Sstevel@tonic-gate 	 */
664*0Sstevel@tonic-gate 	struct mt_unit	*un_next;
665*0Sstevel@tonic-gate 	struct ml_unit	*un_l_unit;
666*0Sstevel@tonic-gate 	struct ufstrans *un_ut;
667*0Sstevel@tonic-gate 	mt_map_t	*un_deltamap;
668*0Sstevel@tonic-gate 	mt_map_t	*un_udmap;
669*0Sstevel@tonic-gate 	mt_map_t	*un_logmap;
670*0Sstevel@tonic-gate 	mt_map_t	*un_matamap;
671*0Sstevel@tonic-gate 	mt_map_t	*un_shadowmap;
672*0Sstevel@tonic-gate } mt_unit_t;
673*0Sstevel@tonic-gate 
674*0Sstevel@tonic-gate 
675*0Sstevel@tonic-gate typedef struct mt_unit32_od {
676*0Sstevel@tonic-gate 	mdc_unit32_od_t	c;		/* common stuff */
677*0Sstevel@tonic-gate 	/*
678*0Sstevel@tonic-gate 	 * infrastructure
679*0Sstevel@tonic-gate 	 */
680*0Sstevel@tonic-gate 	mt_flags_t	un_flags;
681*0Sstevel@tonic-gate 	caddr32_t	xx_un_next;	/* anchored in log unit */
682*0Sstevel@tonic-gate 	/*
683*0Sstevel@tonic-gate 	 * log and master device
684*0Sstevel@tonic-gate 	 */
685*0Sstevel@tonic-gate 	mdkey_t		un_m_key;
686*0Sstevel@tonic-gate 	dev32_t		un_m_dev;
687*0Sstevel@tonic-gate 	mdkey_t		un_l_key;
688*0Sstevel@tonic-gate 	dev32_t		un_l_dev;
689*0Sstevel@tonic-gate 	daddr32_t	un_l_sblk;	/* start block */
690*0Sstevel@tonic-gate 	daddr32_t	un_l_pwsblk;	/* prewrite start block */
691*0Sstevel@tonic-gate 	daddr32_t	un_l_nblks;	/* # of usable log blocks */
692*0Sstevel@tonic-gate 	daddr32_t	un_l_tblks;	/* total log blocks */
693*0Sstevel@tonic-gate 	daddr32_t	un_l_head;	/* sector offset of log head */
694*0Sstevel@tonic-gate 	daddr32_t	un_l_tail;	/* sector offset of log tail */
695*0Sstevel@tonic-gate 	uint_t		un_l_resv;	/* current log reservations */
696*0Sstevel@tonic-gate 	uint_t		un_l_maxresv;	/* max log reservations */
697*0Sstevel@tonic-gate 	uint_t		un_l_maxtransfer; /* maximum transfer at init */
698*0Sstevel@tonic-gate 	mddb_recid_t	un_l_recid;	/* database id */
699*0Sstevel@tonic-gate 	caddr32_t	xx_un_l_unit;	/* log device unit struct */
700*0Sstevel@tonic-gate 	mt_l_error_t	un_l_error;	/* error state */
701*0Sstevel@tonic-gate 	struct timeval32 un_l_timestamp;	/* time of last log state chg */
702*0Sstevel@tonic-gate 	dev32_t		un_s_dev;	/* shadow device for testing only */
703*0Sstevel@tonic-gate 
704*0Sstevel@tonic-gate 	mt_debug_t	un_debug;	/* debug flags; set at create */
705*0Sstevel@tonic-gate 	caddr32_t	xx_un_ut;	/* ufstrans struct */
706*0Sstevel@tonic-gate 	dev32_t		un_dev;		/* this metatrans device */
707*0Sstevel@tonic-gate 	caddr32_t	xx_un_deltamap;	/* deltamap */
708*0Sstevel@tonic-gate 	caddr32_t	xx_un_udmap;	/* userdata map */
709*0Sstevel@tonic-gate 	caddr32_t	xx_un_logmap;	/* logmap includes moby trans stuff */
710*0Sstevel@tonic-gate 	caddr32_t	xx_un_matamap;	/* optional - matamap */
711*0Sstevel@tonic-gate 	caddr32_t	xx_un_shadowmap; /* optional - shadowmap */
712*0Sstevel@tonic-gate 	int		un_logreset;	/* part of _FIOLOGRESET ioctl stuff */
713*0Sstevel@tonic-gate 	struct timeval32 un_timestamp;	/* time of last trans state change */
714*0Sstevel@tonic-gate 	/*
715*0Sstevel@tonic-gate 	 * spares
716*0Sstevel@tonic-gate 	 */
717*0Sstevel@tonic-gate 	uint_t		un_spare[16];
718*0Sstevel@tonic-gate } mt_unit32_od_t;
719*0Sstevel@tonic-gate 
720*0Sstevel@tonic-gate /*
721*0Sstevel@tonic-gate  * prewrite info (per buf); stored as array at beginning of prewrite area
722*0Sstevel@tonic-gate  */
723*0Sstevel@tonic-gate struct prewrite {
724*0Sstevel@tonic-gate 	int		pw_bufsize;	/* every buffer is this size */
725*0Sstevel@tonic-gate 	daddr32_t	pw_blkno;	/* block number */
726*0Sstevel@tonic-gate 	dev32_t		pw_dev;		/* device to write to */
727*0Sstevel@tonic-gate 	ushort_t	pw_secmap;	/* bitmap 	*/
728*0Sstevel@tonic-gate 					/* 1's write this sector in the buf */
729*0Sstevel@tonic-gate 	ushort_t	pw_flags;
730*0Sstevel@tonic-gate };
731*0Sstevel@tonic-gate /*
732*0Sstevel@tonic-gate  * pw_flags
733*0Sstevel@tonic-gate  */
734*0Sstevel@tonic-gate #define	PW_INUSE	0x0001	/* this prewrite buf is in use */
735*0Sstevel@tonic-gate #define	PW_WAIT		0x0002	/* write in progress; wait for completion */
736*0Sstevel@tonic-gate #define	PW_REM		0x0004	/* remove deltas */
737*0Sstevel@tonic-gate 
738*0Sstevel@tonic-gate /*
739*0Sstevel@tonic-gate  * log state
740*0Sstevel@tonic-gate  */
741*0Sstevel@tonic-gate struct  logstate {
742*0Sstevel@tonic-gate 	off32_t		ls_head_lof;	/* log head */
743*0Sstevel@tonic-gate 	uint_t		ls_head_ident;	/* log head ident */
744*0Sstevel@tonic-gate 	uint_t		ls_head_tid;	/* log head tid */
745*0Sstevel@tonic-gate 	uint_t		ls_chksum;	/* checksum of structure */
746*0Sstevel@tonic-gate 	off32_t		ls_bol_lof;	/* needed for TS_Tools/dumplog.c */
747*0Sstevel@tonic-gate 	off32_t		ls_eol_lof;	/* needed for TS_Tools/dumplog.c */
748*0Sstevel@tonic-gate 	uint_t		ls_maxtransfer;	/* needed for TS_Tools/dumplog.c */
749*0Sstevel@tonic-gate 	daddr32_t	ls_pwsblk;	/* needed for TS_Tools/dumplog.c */
750*0Sstevel@tonic-gate };
751*0Sstevel@tonic-gate 
752*0Sstevel@tonic-gate /*
753*0Sstevel@tonic-gate  * log state defines
754*0Sstevel@tonic-gate  */
755*0Sstevel@tonic-gate #define	LS_SECTORS	(2)	/* number of sectors used by state area */
756*0Sstevel@tonic-gate 
757*0Sstevel@tonic-gate /*
758*0Sstevel@tonic-gate  * un_debug
759*0Sstevel@tonic-gate  *	MT_TRANSACT		- keep per thread accounting of tranactions
760*0Sstevel@tonic-gate  *	MT_MATAMAP		- double check deltas and ops against matamap
761*0Sstevel@tonic-gate  *	MT_WRITE_CHECK		- check master+deltas against metadata write
762*0Sstevel@tonic-gate  *	MT_LOG_WRITE_CHECK	- read after write for log writes
763*0Sstevel@tonic-gate  *	MT_CHECK_MAP		- check map after every insert/delete
764*0Sstevel@tonic-gate  *	MT_TRACE		- trace transactions (used with MT_TRANSACT)
765*0Sstevel@tonic-gate  *	MT_SIZE			- fail on size errors (used with MT_TRANSACT)
766*0Sstevel@tonic-gate  *	MT_NOASYNC		- force every op to be sync
767*0Sstevel@tonic-gate  *	MT_FORCEROLL		- forcibly roll the log after every commit
768*0Sstevel@tonic-gate  *	MT_SCAN			- running runtestscan; special case as needed
769*0Sstevel@tonic-gate  *	MT_SHADOW		- copy metatrans device writes to shadow dev.
770*0Sstevel@tonic-gate  *	MT_PREWRITE		- process prewrite area every roll
771*0Sstevel@tonic-gate  */
772*0Sstevel@tonic-gate #define	MT_TRANSACT		(0x00000001)
773*0Sstevel@tonic-gate #define	MT_MATAMAP		(0x00000002)
774*0Sstevel@tonic-gate #define	MT_WRITE_CHECK		(0x00000004)
775*0Sstevel@tonic-gate #define	MT_LOG_WRITE_CHECK	(0x00000008)
776*0Sstevel@tonic-gate #define	MT_CHECK_MAP		(0x00000010)
777*0Sstevel@tonic-gate #define	MT_TRACE		(0x00000020)
778*0Sstevel@tonic-gate #define	MT_SIZE			(0x00000040)
779*0Sstevel@tonic-gate #define	MT_NOASYNC		(0x00000080)
780*0Sstevel@tonic-gate #define	MT_FORCEROLL		(0x00000100)
781*0Sstevel@tonic-gate #define	MT_SCAN			(0x00000200)
782*0Sstevel@tonic-gate #define	MT_SHADOW		(0x00000400)
783*0Sstevel@tonic-gate #define	MT_PREWRITE		(0x00000800)
784*0Sstevel@tonic-gate 
785*0Sstevel@tonic-gate /* Type 2 trans records */
786*0Sstevel@tonic-gate #define	TRANS_REC	1
787*0Sstevel@tonic-gate #define	LOG_REC		2
788*0Sstevel@tonic-gate 
789*0Sstevel@tonic-gate #ifdef _KERNEL
790*0Sstevel@tonic-gate 
791*0Sstevel@tonic-gate typedef struct md_tps {			/* trans parent save */
792*0Sstevel@tonic-gate 	DAEMON_QUEUE
793*0Sstevel@tonic-gate 	struct mt_unit	*ps_un;
794*0Sstevel@tonic-gate 	mdi_unit_t	*ps_ui;
795*0Sstevel@tonic-gate 	buf_t		*ps_bp;
796*0Sstevel@tonic-gate 	size_t		ps_count;	/* Used for testing only. */
797*0Sstevel@tonic-gate 	kmutex_t	ps_mx;		/* protects ps_count. */
798*0Sstevel@tonic-gate } md_tps_t;
799*0Sstevel@tonic-gate 
800*0Sstevel@tonic-gate /*
801*0Sstevel@tonic-gate  * Log layer protos -- trans_log.c
802*0Sstevel@tonic-gate  */
803*0Sstevel@tonic-gate extern void		_init_ldl(void);
804*0Sstevel@tonic-gate extern void		_fini_ldl(void);
805*0Sstevel@tonic-gate extern void		md_ldl_round_commit(mt_unit_t *);
806*0Sstevel@tonic-gate extern void		md_ldl_push_commit(mt_unit_t *);
807*0Sstevel@tonic-gate extern int		md_ldl_need_commit(ml_unit_t *);
808*0Sstevel@tonic-gate extern int		md_ldl_has_space(ml_unit_t *, mapentry_t *);
809*0Sstevel@tonic-gate extern void		md_ldl_write(mt_unit_t *, caddr_t, offset_t,
810*0Sstevel@tonic-gate 					mapentry_t *);
811*0Sstevel@tonic-gate extern void		md_ldl_waito(ml_unit_t *);
812*0Sstevel@tonic-gate extern int		md_ldl_read(ml_unit_t *, caddr_t, offset_t, off_t,
813*0Sstevel@tonic-gate 					mapentry_t *);
814*0Sstevel@tonic-gate extern void		md_ldl_sethead(ml_unit_t *, off_t, uint_t,
815*0Sstevel@tonic-gate 					struct buf *);
816*0Sstevel@tonic-gate extern void		md_ldl_settail(ml_unit_t *, off_t, off_t,
817*0Sstevel@tonic-gate 					struct buf *);
818*0Sstevel@tonic-gate extern void		ldl_setpwvalid(ml_unit_t *);
819*0Sstevel@tonic-gate extern int		ldl_build_incore(ml_unit_t *, int);
820*0Sstevel@tonic-gate extern ml_unit_t	*ldl_findlog(mddb_recid_t);
821*0Sstevel@tonic-gate extern mddb_recid_t	ldl_create(mdkey_t, mt_unit_t *);
822*0Sstevel@tonic-gate extern void		ldl_utadd(mt_unit_t *);
823*0Sstevel@tonic-gate extern int		ldl_open_dev(mt_unit_t *, ml_unit_t *);
824*0Sstevel@tonic-gate extern void		ldl_close_dev(ml_unit_t *);
825*0Sstevel@tonic-gate extern int		ldl_snarf(void);
826*0Sstevel@tonic-gate extern void		ldl_logscan_seterror(ml_unit_t *);
827*0Sstevel@tonic-gate extern void		ldl_logscan_saverror(ml_unit_t *);
828*0Sstevel@tonic-gate extern size_t		md_ldl_logscan_nbcommit(off_t);
829*0Sstevel@tonic-gate extern int		md_ldl_logscan_read(ml_unit_t *, off_t *, size_t,
830*0Sstevel@tonic-gate 					caddr_t);
831*0Sstevel@tonic-gate extern void		md_ldl_logscan_begin(ml_unit_t *, daddr_t);
832*0Sstevel@tonic-gate extern void		md_ldl_logscan_end(ml_unit_t *);
833*0Sstevel@tonic-gate extern int		md_ldl_need_roll(ml_unit_t *);
834*0Sstevel@tonic-gate extern int		md_ldl_empty(ml_unit_t *);
835*0Sstevel@tonic-gate extern int		ldl_pwvalid(ml_unit_t *);
836*0Sstevel@tonic-gate extern void		ldl_waitscan(ml_unit_t *);
837*0Sstevel@tonic-gate extern void		ldl_errorbp(set_t, buf_t *, char *);
838*0Sstevel@tonic-gate extern void		md_ldl_seterror(ml_unit_t *);
839*0Sstevel@tonic-gate extern int		ldl_isherror(ml_unit_t *);
840*0Sstevel@tonic-gate extern int		ldl_iserror(ml_unit_t *);
841*0Sstevel@tonic-gate extern int		ldl_isanyerror(ml_unit_t *);
842*0Sstevel@tonic-gate extern void		ldl_start_scan(mt_unit_t *);
843*0Sstevel@tonic-gate extern void		ldl_opened_trans(mt_unit_t *, int);
844*0Sstevel@tonic-gate extern void		ldl_open_trans(mt_unit_t *, int);
845*0Sstevel@tonic-gate extern int		ldl_logreset(mt_unit_t *, buf_t *);
846*0Sstevel@tonic-gate extern void		ldl_close_trans(mt_unit_t *);
847*0Sstevel@tonic-gate extern size_t		md_ldl_bufsize(ml_unit_t *);
848*0Sstevel@tonic-gate extern void		ldl_open_underlying(mt_unit_t *);
849*0Sstevel@tonic-gate extern void		ldl_snarf_done();
850*0Sstevel@tonic-gate extern int		ldl_reset(mt_unit_t *, int, int);
851*0Sstevel@tonic-gate extern void		ldl_cleanup(ml_unit_t *);
852*0Sstevel@tonic-gate 
853*0Sstevel@tonic-gate /*
854*0Sstevel@tonic-gate  * trans driver layer -- mdtrans.c
855*0Sstevel@tonic-gate  */
856*0Sstevel@tonic-gate extern kmem_cache_t	*trans_child_cache;
857*0Sstevel@tonic-gate extern void		*md_trans_zalloc(size_t);
858*0Sstevel@tonic-gate extern void		*md_trans_zalloc_nosleep(size_t);
859*0Sstevel@tonic-gate extern void		*md_trans_alloc(size_t);
860*0Sstevel@tonic-gate extern void		*md_trans_alloc_nosleep(size_t);
861*0Sstevel@tonic-gate extern void		md_trans_free(void *, size_t);
862*0Sstevel@tonic-gate extern int		md_trans_not_wait(struct buf *cb);
863*0Sstevel@tonic-gate extern int		md_trans_not_done(struct buf *cb);
864*0Sstevel@tonic-gate extern int		md_trans_wait(struct buf *cb);
865*0Sstevel@tonic-gate extern int		trans_done(struct buf *cb);
866*0Sstevel@tonic-gate extern int		trans_done_shadow(struct buf *cb);
867*0Sstevel@tonic-gate extern void		trans_child_init(struct buf *bp);
868*0Sstevel@tonic-gate extern void		trans_close_all_devs(mt_unit_t *);
869*0Sstevel@tonic-gate extern int		trans_open_all_devs(mt_unit_t *);
870*0Sstevel@tonic-gate extern int		trans_build_incore(void *, int);
871*0Sstevel@tonic-gate extern void		trans_commit(mt_unit_t *, int);
872*0Sstevel@tonic-gate extern int		trans_detach(mt_unit_t *, int);
873*0Sstevel@tonic-gate extern void		trans_attach(mt_unit_t *, int);
874*0Sstevel@tonic-gate extern int		trans_reset(mt_unit_t *, minor_t, int, int);
875*0Sstevel@tonic-gate 
876*0Sstevel@tonic-gate /*
877*0Sstevel@tonic-gate  * transaction ioctl -- trans_ioctl.c
878*0Sstevel@tonic-gate  */
879*0Sstevel@tonic-gate 
880*0Sstevel@tonic-gate /* rename named service functions */
881*0Sstevel@tonic-gate md_ren_list_svc_t	trans_rename_listkids;
882*0Sstevel@tonic-gate md_ren_svc_t		trans_rename_check;
883*0Sstevel@tonic-gate md_ren_roleswap_svc_t	trans_renexch_update_kids;
884*0Sstevel@tonic-gate md_ren_roleswap_svc_t	trans_rename_update_self;
885*0Sstevel@tonic-gate md_ren_roleswap_svc_t	trans_exchange_parent_update_to;
886*0Sstevel@tonic-gate md_ren_roleswap_svc_t	trans_exchange_self_update_from_down;
887*0Sstevel@tonic-gate 
888*0Sstevel@tonic-gate /*
889*0Sstevel@tonic-gate  * transaction op layer -- trans_top.c
890*0Sstevel@tonic-gate  */
891*0Sstevel@tonic-gate extern void	_init_md_top(void);
892*0Sstevel@tonic-gate extern void	_fini_top(void);
893*0Sstevel@tonic-gate extern void	top_read(struct buf *, char *, mt_unit_t *, int, void *);
894*0Sstevel@tonic-gate extern void	md_top_read_roll(struct buf *, mt_unit_t *, ushort_t *);
895*0Sstevel@tonic-gate extern void	top_build_incore(mt_unit_t *);
896*0Sstevel@tonic-gate extern void	top_reset(mt_unit_t *, int, int);
897*0Sstevel@tonic-gate extern void	top_write(struct buf *, char *, mt_unit_t *, int, void *);
898*0Sstevel@tonic-gate 
899*0Sstevel@tonic-gate /*
900*0Sstevel@tonic-gate  * map layer -- trans_delta.c
901*0Sstevel@tonic-gate  */
902*0Sstevel@tonic-gate extern void		md_map_free_entries(mt_map_t *);
903*0Sstevel@tonic-gate extern int		md_matamap_overlap(mt_map_t *, offset_t, off_t);
904*0Sstevel@tonic-gate extern int		md_matamap_within(mt_map_t *, offset_t, off_t);
905*0Sstevel@tonic-gate extern int		md_deltamap_need_commit(mt_map_t *);
906*0Sstevel@tonic-gate extern void		md_deltamap_add(mt_map_t *, offset_t, off_t, delta_t,
907*0Sstevel@tonic-gate 				int (*)(), uintptr_t);
908*0Sstevel@tonic-gate extern mapentry_t	*md_deltamap_remove(mt_map_t *, offset_t, off_t);
909*0Sstevel@tonic-gate extern void		md_deltamap_del(mt_map_t *, offset_t, off_t);
910*0Sstevel@tonic-gate extern void		md_deltamap_push(mt_unit_t *);
911*0Sstevel@tonic-gate extern int		md_logmap_need_commit(mt_map_t *);
912*0Sstevel@tonic-gate extern int		md_logmap_need_roll_async(mt_map_t *);
913*0Sstevel@tonic-gate extern int		md_logmap_need_roll_sync(mt_map_t *);
914*0Sstevel@tonic-gate extern int		md_logmap_need_roll(mt_map_t *);
915*0Sstevel@tonic-gate extern void		md_logmap_start_roll(mt_unit_t *);
916*0Sstevel@tonic-gate extern void		md_logmap_kill_roll(mt_map_t *);
917*0Sstevel@tonic-gate extern void		md_logmap_forceroll(mt_map_t *);
918*0Sstevel@tonic-gate extern int		md_logmap_overlap(mt_map_t *, md_dev64_t, offset_t,
919*0Sstevel@tonic-gate 				off_t);
920*0Sstevel@tonic-gate extern void		md_logmap_remove_roll(mt_map_t *, md_dev64_t, offset_t,
921*0Sstevel@tonic-gate 				off_t);
922*0Sstevel@tonic-gate extern int		md_logmap_next_roll(mt_map_t *, offset_t *,
923*0Sstevel@tonic-gate 				md_dev64_t *);
924*0Sstevel@tonic-gate extern void		md_logmap_list_get(mt_map_t *, md_dev64_t, offset_t,
925*0Sstevel@tonic-gate 				off_t, mapentry_t **);
926*0Sstevel@tonic-gate extern void		md_logmap_list_get_roll(mt_map_t *, md_dev64_t,
927*0Sstevel@tonic-gate 				offset_t, off_t, mapentry_t **);
928*0Sstevel@tonic-gate extern void		md_logmap_list_put(mt_map_t *, mapentry_t *);
929*0Sstevel@tonic-gate extern void		md_logmap_read_mstr(ml_unit_t *, struct buf *, int,
930*0Sstevel@tonic-gate 				void *);
931*0Sstevel@tonic-gate extern void		md_logmap_secmap_roll(mapentry_t *, offset_t,
932*0Sstevel@tonic-gate 				ushort_t *);
933*0Sstevel@tonic-gate extern int		logmap_read_log(ml_unit_t *, char *, offset_t, off_t,
934*0Sstevel@tonic-gate 				mapentry_t *);
935*0Sstevel@tonic-gate extern void		md_logmap_make_space(mt_map_t *, ml_unit_t *,
936*0Sstevel@tonic-gate 				mapentry_t *);
937*0Sstevel@tonic-gate extern void		md_logmap_add(mt_unit_t *, md_dev64_t, char *, offset_t,
938*0Sstevel@tonic-gate 				mapentry_t *);
939*0Sstevel@tonic-gate extern void		md_logmap_add_ud(mt_unit_t *, md_dev64_t, char *,
940*0Sstevel@tonic-gate 				offset_t, mapentry_t *);
941*0Sstevel@tonic-gate extern void		md_logmap_commit(mt_unit_t *);
942*0Sstevel@tonic-gate extern void		md_logmap_sethead(mt_map_t *, ml_unit_t *,
943*0Sstevel@tonic-gate 				struct buf *);
944*0Sstevel@tonic-gate extern void		md_logmap_roll_dev(mt_map_t *, ml_unit_t *ul,
945*0Sstevel@tonic-gate 				md_dev64_t);
946*0Sstevel@tonic-gate extern void		md_logmap_roll_sud(mt_map_t *, ml_unit_t *ul,
947*0Sstevel@tonic-gate 				md_dev64_t, offset_t, off_t);
948*0Sstevel@tonic-gate extern int		md_logmap_ud_done(struct buf *);
949*0Sstevel@tonic-gate extern void		md_logmap_ud_wait();
950*0Sstevel@tonic-gate extern void		md_logmap_cancel(mt_unit_t *, md_dev64_t, offset_t,
951*0Sstevel@tonic-gate 				off_t);
952*0Sstevel@tonic-gate extern int		md_logmap_iscancel(mt_map_t *, md_dev64_t, offset_t,
953*0Sstevel@tonic-gate 				off_t);
954*0Sstevel@tonic-gate extern void		md_logmap_logscan(mt_unit_t *, daddr_t);
955*0Sstevel@tonic-gate extern void		map_build_incore(mt_unit_t *);
956*0Sstevel@tonic-gate extern void		map_reset(mt_unit_t *, int, int);
957*0Sstevel@tonic-gate extern void		_init_md_map(void);
958*0Sstevel@tonic-gate extern void		_fini_map(void);
959*0Sstevel@tonic-gate 
960*0Sstevel@tonic-gate /*
961*0Sstevel@tonic-gate  * scan and roll threads -- trans_thread.c
962*0Sstevel@tonic-gate  */
963*0Sstevel@tonic-gate extern void	md_trans_roll(ml_unit_t *);
964*0Sstevel@tonic-gate extern void	trans_scan(mt_unit_t *);
965*0Sstevel@tonic-gate extern void	trans_roll_prewrite(ml_unit_t *);
966*0Sstevel@tonic-gate 
967*0Sstevel@tonic-gate #endif	/* _KERNEL */
968*0Sstevel@tonic-gate 
969*0Sstevel@tonic-gate #ifdef	__cplusplus
970*0Sstevel@tonic-gate }
971*0Sstevel@tonic-gate #endif
972*0Sstevel@tonic-gate 
973*0Sstevel@tonic-gate #endif	/* _SYS_MD_TRANS_H */
974