spa.h revision 0a4e9518a44f226be6d39383330b5b1792d2f184
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 2007 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _SYS_SPA_H
27#define	_SYS_SPA_H
28
29#pragma ident	"%Z%%M%	%I%	%E% SMI"
30
31#include <sys/avl.h>
32#include <sys/zfs_context.h>
33#include <sys/nvpair.h>
34#include <sys/sysmacros.h>
35#include <sys/types.h>
36#include <sys/fs/zfs.h>
37
38#ifdef	__cplusplus
39extern "C" {
40#endif
41
42/*
43 * Forward references that lots of things need.
44 */
45typedef struct spa spa_t;
46typedef struct vdev vdev_t;
47typedef struct metaslab metaslab_t;
48typedef struct zilog zilog_t;
49typedef struct traverse_handle traverse_handle_t;
50struct dsl_pool;
51
52/*
53 * General-purpose 32-bit and 64-bit bitfield encodings.
54 */
55#define	BF32_DECODE(x, low, len)	P2PHASE((x) >> (low), 1U << (len))
56#define	BF64_DECODE(x, low, len)	P2PHASE((x) >> (low), 1ULL << (len))
57#define	BF32_ENCODE(x, low, len)	(P2PHASE((x), 1U << (len)) << (low))
58#define	BF64_ENCODE(x, low, len)	(P2PHASE((x), 1ULL << (len)) << (low))
59
60#define	BF32_GET(x, low, len)		BF32_DECODE(x, low, len)
61#define	BF64_GET(x, low, len)		BF64_DECODE(x, low, len)
62
63#define	BF32_SET(x, low, len, val)	\
64	((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))
65#define	BF64_SET(x, low, len, val)	\
66	((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))
67
68#define	BF32_GET_SB(x, low, len, shift, bias)	\
69	((BF32_GET(x, low, len) + (bias)) << (shift))
70#define	BF64_GET_SB(x, low, len, shift, bias)	\
71	((BF64_GET(x, low, len) + (bias)) << (shift))
72
73#define	BF32_SET_SB(x, low, len, shift, bias, val)	\
74	BF32_SET(x, low, len, ((val) >> (shift)) - (bias))
75#define	BF64_SET_SB(x, low, len, shift, bias, val)	\
76	BF64_SET(x, low, len, ((val) >> (shift)) - (bias))
77
78/*
79 * We currently support nine block sizes, from 512 bytes to 128K.
80 * We could go higher, but the benefits are near-zero and the cost
81 * of COWing a giant block to modify one byte would become excessive.
82 */
83#define	SPA_MINBLOCKSHIFT	9
84#define	SPA_MAXBLOCKSHIFT	17
85#define	SPA_MINBLOCKSIZE	(1ULL << SPA_MINBLOCKSHIFT)
86#define	SPA_MAXBLOCKSIZE	(1ULL << SPA_MAXBLOCKSHIFT)
87
88#define	SPA_BLOCKSIZES		(SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1)
89
90/*
91 * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
92 * The ASIZE encoding should be at least 64 times larger (6 more bits)
93 * to support up to 4-way RAID-Z mirror mode with worst-case gang block
94 * overhead, three DVAs per bp, plus one more bit in case we do anything
95 * else that expands the ASIZE.
96 */
97#define	SPA_LSIZEBITS		16	/* LSIZE up to 32M (2^16 * 512)	*/
98#define	SPA_PSIZEBITS		16	/* PSIZE up to 32M (2^16 * 512)	*/
99#define	SPA_ASIZEBITS		24	/* ASIZE up to 64 times larger	*/
100
101/*
102 * All SPA data is represented by 128-bit data virtual addresses (DVAs).
103 * The members of the dva_t should be considered opaque outside the SPA.
104 */
105typedef struct dva {
106	uint64_t	dva_word[2];
107} dva_t;
108
109/*
110 * Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
111 */
112typedef struct zio_cksum {
113	uint64_t	zc_word[4];
114} zio_cksum_t;
115
116/*
117 * Each block is described by its DVAs, time of birth, checksum, etc.
118 * The word-by-word, bit-by-bit layout of the blkptr is as follows:
119 *
120 *	64	56	48	40	32	24	16	8	0
121 *	+-------+-------+-------+-------+-------+-------+-------+-------+
122 * 0	|		vdev1		| GRID  |	  ASIZE		|
123 *	+-------+-------+-------+-------+-------+-------+-------+-------+
124 * 1	|G|			 offset1				|
125 *	+-------+-------+-------+-------+-------+-------+-------+-------+
126 * 2	|		vdev2		| GRID  |	  ASIZE		|
127 *	+-------+-------+-------+-------+-------+-------+-------+-------+
128 * 3	|G|			 offset2				|
129 *	+-------+-------+-------+-------+-------+-------+-------+-------+
130 * 4	|		vdev3		| GRID  |	  ASIZE		|
131 *	+-------+-------+-------+-------+-------+-------+-------+-------+
132 * 5	|G|			 offset3				|
133 *	+-------+-------+-------+-------+-------+-------+-------+-------+
134 * 6	|E| lvl | type	| cksum | comp	|     PSIZE	|     LSIZE	|
135 *	+-------+-------+-------+-------+-------+-------+-------+-------+
136 * 7	|			padding					|
137 *	+-------+-------+-------+-------+-------+-------+-------+-------+
138 * 8	|			padding					|
139 *	+-------+-------+-------+-------+-------+-------+-------+-------+
140 * 9	|			padding					|
141 *	+-------+-------+-------+-------+-------+-------+-------+-------+
142 * a	|			birth txg				|
143 *	+-------+-------+-------+-------+-------+-------+-------+-------+
144 * b	|			fill count				|
145 *	+-------+-------+-------+-------+-------+-------+-------+-------+
146 * c	|			checksum[0]				|
147 *	+-------+-------+-------+-------+-------+-------+-------+-------+
148 * d	|			checksum[1]				|
149 *	+-------+-------+-------+-------+-------+-------+-------+-------+
150 * e	|			checksum[2]				|
151 *	+-------+-------+-------+-------+-------+-------+-------+-------+
152 * f	|			checksum[3]				|
153 *	+-------+-------+-------+-------+-------+-------+-------+-------+
154 *
155 * Legend:
156 *
157 * vdev		virtual device ID
158 * offset	offset into virtual device
159 * LSIZE	logical size
160 * PSIZE	physical size (after compression)
161 * ASIZE	allocated size (including RAID-Z parity and gang block headers)
162 * GRID		RAID-Z layout information (reserved for future use)
163 * cksum	checksum function
164 * comp		compression function
165 * G		gang block indicator
166 * E		endianness
167 * type		DMU object type
168 * lvl		level of indirection
169 * birth txg	transaction group in which the block was born
170 * fill count	number of non-zero blocks under this bp
171 * checksum[4]	256-bit checksum of the data this bp describes
172 */
173typedef struct blkptr {
174	dva_t		blk_dva[3];	/* 128-bit Data Virtual Address	*/
175	uint64_t	blk_prop;	/* size, compression, type, etc	*/
176	uint64_t	blk_pad[3];	/* Extra space for the future	*/
177	uint64_t	blk_birth;	/* transaction group at birth	*/
178	uint64_t	blk_fill;	/* fill count			*/
179	zio_cksum_t	blk_cksum;	/* 256-bit checksum		*/
180} blkptr_t;
181
182#define	SPA_BLKPTRSHIFT	7		/* blkptr_t is 128 bytes	*/
183#define	SPA_DVAS_PER_BP	3		/* Number of DVAs in a bp	*/
184
185/*
186 * Macros to get and set fields in a bp or DVA.
187 */
188#define	DVA_GET_ASIZE(dva)	\
189	BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)
190#define	DVA_SET_ASIZE(dva, x)	\
191	BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x)
192
193#define	DVA_GET_GRID(dva)	BF64_GET((dva)->dva_word[0], 24, 8)
194#define	DVA_SET_GRID(dva, x)	BF64_SET((dva)->dva_word[0], 24, 8, x)
195
196#define	DVA_GET_VDEV(dva)	BF64_GET((dva)->dva_word[0], 32, 32)
197#define	DVA_SET_VDEV(dva, x)	BF64_SET((dva)->dva_word[0], 32, 32, x)
198
199#define	DVA_GET_OFFSET(dva)	\
200	BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)
201#define	DVA_SET_OFFSET(dva, x)	\
202	BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x)
203
204#define	DVA_GET_GANG(dva)	BF64_GET((dva)->dva_word[1], 63, 1)
205#define	DVA_SET_GANG(dva, x)	BF64_SET((dva)->dva_word[1], 63, 1, x)
206
207#define	BP_GET_LSIZE(bp)	\
208	(BP_IS_HOLE(bp) ? 0 : \
209	BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1))
210#define	BP_SET_LSIZE(bp, x)	\
211	BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
212
213#define	BP_GET_PSIZE(bp)	\
214	BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)
215#define	BP_SET_PSIZE(bp, x)	\
216	BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)
217
218#define	BP_GET_COMPRESS(bp)	BF64_GET((bp)->blk_prop, 32, 8)
219#define	BP_SET_COMPRESS(bp, x)	BF64_SET((bp)->blk_prop, 32, 8, x)
220
221#define	BP_GET_CHECKSUM(bp)	BF64_GET((bp)->blk_prop, 40, 8)
222#define	BP_SET_CHECKSUM(bp, x)	BF64_SET((bp)->blk_prop, 40, 8, x)
223
224#define	BP_GET_TYPE(bp)		BF64_GET((bp)->blk_prop, 48, 8)
225#define	BP_SET_TYPE(bp, x)	BF64_SET((bp)->blk_prop, 48, 8, x)
226
227#define	BP_GET_LEVEL(bp)	BF64_GET((bp)->blk_prop, 56, 5)
228#define	BP_SET_LEVEL(bp, x)	BF64_SET((bp)->blk_prop, 56, 5, x)
229
230#define	BP_GET_BYTEORDER(bp)	(0 - BF64_GET((bp)->blk_prop, 63, 1))
231#define	BP_SET_BYTEORDER(bp, x)	BF64_SET((bp)->blk_prop, 63, 1, x)
232
233#define	BP_GET_ASIZE(bp)	\
234	(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
235		DVA_GET_ASIZE(&(bp)->blk_dva[2]))
236
237#define	BP_GET_UCSIZE(bp) \
238	((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \
239	BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp));
240
241#define	BP_GET_NDVAS(bp)	\
242	(!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
243	!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
244	!!DVA_GET_ASIZE(&(bp)->blk_dva[2]))
245
246#define	BP_COUNT_GANG(bp)	\
247	(DVA_GET_GANG(&(bp)->blk_dva[0]) + \
248	DVA_GET_GANG(&(bp)->blk_dva[1]) + \
249	DVA_GET_GANG(&(bp)->blk_dva[2]))
250
251#define	DVA_EQUAL(dva1, dva2)	\
252	((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
253	(dva1)->dva_word[0] == (dva2)->dva_word[0])
254
255#define	ZIO_CHECKSUM_EQUAL(zc1, zc2) \
256	(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
257	((zc1).zc_word[1] - (zc2).zc_word[1]) | \
258	((zc1).zc_word[2] - (zc2).zc_word[2]) | \
259	((zc1).zc_word[3] - (zc2).zc_word[3])))
260
261
262#define	DVA_IS_VALID(dva)	(DVA_GET_ASIZE(dva) != 0)
263
264#define	ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3)	\
265{						\
266	(zcp)->zc_word[0] = w0;			\
267	(zcp)->zc_word[1] = w1;			\
268	(zcp)->zc_word[2] = w2;			\
269	(zcp)->zc_word[3] = w3;			\
270}
271
272#define	BP_IDENTITY(bp)		(&(bp)->blk_dva[0])
273#define	BP_IS_GANG(bp)		DVA_GET_GANG(BP_IDENTITY(bp))
274#define	BP_IS_HOLE(bp)		((bp)->blk_birth == 0)
275#define	BP_IS_OLDER(bp, txg)	(!BP_IS_HOLE(bp) && (bp)->blk_birth < (txg))
276
277#define	BP_ZERO_DVAS(bp)			\
278{						\
279	(bp)->blk_dva[0].dva_word[0] = 0;	\
280	(bp)->blk_dva[0].dva_word[1] = 0;	\
281	(bp)->blk_dva[1].dva_word[0] = 0;	\
282	(bp)->blk_dva[1].dva_word[1] = 0;	\
283	(bp)->blk_dva[2].dva_word[0] = 0;	\
284	(bp)->blk_dva[2].dva_word[1] = 0;	\
285	(bp)->blk_birth = 0;			\
286}
287
288#define	BP_ZERO(bp)				\
289{						\
290	BP_ZERO_DVAS(bp)			\
291	(bp)->blk_prop = 0;			\
292	(bp)->blk_pad[0] = 0;			\
293	(bp)->blk_pad[1] = 0;			\
294	(bp)->blk_pad[2] = 0;			\
295	(bp)->blk_fill = 0;			\
296	ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0);	\
297}
298
299/*
300 * Note: the byteorder is either 0 or -1, both of which are palindromes.
301 * This simplifies the endianness handling a bit.
302 */
303#ifdef _BIG_ENDIAN
304#define	ZFS_HOST_BYTEORDER	(0ULL)
305#else
306#define	ZFS_HOST_BYTEORDER	(-1ULL)
307#endif
308
309#define	BP_SHOULD_BYTESWAP(bp)	(BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)
310
311#define	BP_SPRINTF_LEN	320
312
313#include <sys/dmu.h>
314
315#define	BP_GET_BUFC_TYPE(bp)						\
316	(((BP_GET_LEVEL(bp) > 0) || (dmu_ot[BP_GET_TYPE(bp)].ot_metadata)) ? \
317	ARC_BUFC_METADATA : ARC_BUFC_DATA);
318/*
319 * Routines found in spa.c
320 */
321
322/* state manipulation functions */
323extern int spa_open(const char *pool, spa_t **, void *tag);
324extern int spa_get_stats(const char *pool, nvlist_t **config,
325    char *altroot, size_t buflen);
326extern int spa_create(const char *pool, nvlist_t *config, nvlist_t *props,
327    const char *history_str);
328extern int spa_import(const char *pool, nvlist_t *config, nvlist_t *props);
329extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
330extern int spa_destroy(char *pool);
331extern int spa_export(char *pool, nvlist_t **oldconfig);
332extern int spa_reset(char *pool);
333extern void spa_async_request(spa_t *spa, int flag);
334extern void spa_async_suspend(spa_t *spa);
335extern void spa_async_resume(spa_t *spa);
336extern spa_t *spa_inject_addref(char *pool);
337extern void spa_inject_delref(spa_t *spa);
338
339#define	SPA_ASYNC_REMOVE	0x01
340#define	SPA_ASYNC_RESILVER_DONE	0x02
341#define	SPA_ASYNC_SCRUB		0x04
342#define	SPA_ASYNC_RESILVER	0x08
343#define	SPA_ASYNC_CONFIG_UPDATE	0x10
344
345/* device manipulation */
346extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot);
347extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot,
348    int replacing);
349extern int spa_vdev_detach(spa_t *spa, uint64_t guid, int replace_done);
350extern int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare);
351extern int spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath);
352
353/* spare state (which is global across all pools) */
354extern void spa_spare_add(vdev_t *vd);
355extern void spa_spare_remove(vdev_t *vd);
356extern boolean_t spa_spare_exists(uint64_t guid, uint64_t *pool);
357extern void spa_spare_activate(vdev_t *vd);
358
359/* scrubbing */
360extern int spa_scrub(spa_t *spa, pool_scrub_type_t type, boolean_t force);
361extern void spa_scrub_suspend(spa_t *spa);
362extern void spa_scrub_resume(spa_t *spa);
363extern void spa_scrub_restart(spa_t *spa, uint64_t txg);
364
365/* spa syncing */
366extern void spa_sync(spa_t *spa, uint64_t txg); /* only for DMU use */
367extern void spa_sync_allpools(void);
368
369/*
370 * SPA configuration functions in spa_config.c
371 */
372
373#define	SPA_CONFIG_UPDATE_POOL	0
374#define	SPA_CONFIG_UPDATE_VDEVS	1
375
376extern void spa_config_sync(void);
377extern void spa_config_load(void);
378extern nvlist_t *spa_all_configs(uint64_t *);
379extern void spa_config_set(spa_t *spa, nvlist_t *config);
380extern nvlist_t *spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg,
381    int getstats);
382extern void spa_config_update(spa_t *spa, int what);
383
384/*
385 * Miscellaneous SPA routines in spa_misc.c
386 */
387
388/* Namespace manipulation */
389extern spa_t *spa_lookup(const char *name);
390extern spa_t *spa_add(const char *name, const char *altroot);
391extern void spa_remove(spa_t *spa);
392extern spa_t *spa_next(spa_t *prev);
393
394/* Refcount functions */
395extern void spa_open_ref(spa_t *spa, void *tag);
396extern void spa_close(spa_t *spa, void *tag);
397extern boolean_t spa_refcount_zero(spa_t *spa);
398
399/* Pool configuration lock */
400extern void spa_config_enter(spa_t *spa, krw_t rw, void *tag);
401extern void spa_config_exit(spa_t *spa, void *tag);
402extern boolean_t spa_config_held(spa_t *spa, krw_t rw);
403
404/* Pool vdev add/remove lock */
405extern uint64_t spa_vdev_enter(spa_t *spa);
406extern int spa_vdev_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error);
407
408/* Accessor functions */
409extern krwlock_t *spa_traverse_rwlock(spa_t *spa);
410extern int spa_traverse_wanted(spa_t *spa);
411extern struct dsl_pool *spa_get_dsl(spa_t *spa);
412extern blkptr_t *spa_get_rootblkptr(spa_t *spa);
413extern void spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp);
414extern void spa_altroot(spa_t *, char *, size_t);
415extern int spa_sync_pass(spa_t *spa);
416extern char *spa_name(spa_t *spa);
417extern uint64_t spa_guid(spa_t *spa);
418extern uint64_t spa_last_synced_txg(spa_t *spa);
419extern uint64_t spa_first_txg(spa_t *spa);
420extern uint64_t spa_version(spa_t *spa);
421extern int spa_state(spa_t *spa);
422extern uint64_t spa_freeze_txg(spa_t *spa);
423struct metaslab_class;
424extern uint64_t spa_get_alloc(spa_t *spa);
425extern uint64_t spa_get_space(spa_t *spa);
426extern uint64_t spa_get_dspace(spa_t *spa);
427extern uint64_t spa_get_asize(spa_t *spa, uint64_t lsize);
428extern uint64_t spa_version(spa_t *spa);
429extern int spa_max_replication(spa_t *spa);
430extern int spa_busy(void);
431extern uint8_t spa_get_failmode(spa_t *spa);
432
433/* Miscellaneous support routines */
434extern int spa_rename(const char *oldname, const char *newname);
435extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid);
436extern char *spa_strdup(const char *);
437extern void spa_strfree(char *);
438extern uint64_t spa_get_random(uint64_t range);
439extern void sprintf_blkptr(char *buf, int len, const blkptr_t *bp);
440extern void spa_freeze(spa_t *spa);
441extern void spa_upgrade(spa_t *spa, uint64_t version);
442extern void spa_evict_all(void);
443extern vdev_t *spa_lookup_by_guid(spa_t *spa, uint64_t guid);
444extern boolean_t spa_has_spare(spa_t *, uint64_t guid);
445extern uint64_t bp_get_dasize(spa_t *spa, const blkptr_t *bp);
446extern boolean_t spa_has_slogs(spa_t *spa);
447
448/* history logging */
449typedef enum history_log_type {
450	LOG_CMD_POOL_CREATE,
451	LOG_CMD_NORMAL,
452	LOG_INTERNAL
453} history_log_type_t;
454
455typedef struct history_arg {
456	const char *ha_history_str;
457	history_log_type_t ha_log_type;
458	history_internal_events_t ha_event;
459	char ha_zone[MAXPATHLEN];
460} history_arg_t;
461
462extern char *spa_his_ievent_table[];
463
464extern void spa_history_create_obj(spa_t *spa, dmu_tx_t *tx);
465extern int spa_history_get(spa_t *spa, uint64_t *offset, uint64_t *len_read,
466    char *his_buf);
467extern int spa_history_log(spa_t *spa, const char *his_buf,
468    history_log_type_t what);
469void spa_history_internal_log(history_internal_events_t event, spa_t *spa,
470    dmu_tx_t *tx, cred_t *cr, const char *fmt, ...);
471
472/* error handling */
473struct zbookmark;
474struct zio;
475extern void spa_log_error(spa_t *spa, struct zio *zio);
476extern void zfs_ereport_post(const char *class, spa_t *spa, vdev_t *vd,
477    struct zio *zio, uint64_t stateoroffset, uint64_t length);
478extern void zfs_post_ok(spa_t *spa, vdev_t *vd);
479extern void zfs_post_remove(spa_t *spa, vdev_t *vd);
480extern void zfs_post_autoreplace(spa_t *spa, vdev_t *vd);
481extern uint64_t spa_get_errlog_size(spa_t *spa);
482extern int spa_get_errlog(spa_t *spa, void *uaddr, size_t *count);
483extern void spa_errlog_rotate(spa_t *spa);
484extern void spa_errlog_drain(spa_t *spa);
485extern void spa_errlog_sync(spa_t *spa, uint64_t txg);
486extern void spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub);
487
488/* Initialization and termination */
489extern void spa_init(int flags);
490extern void spa_fini(void);
491
492/* properties */
493extern int spa_prop_set(spa_t *spa, nvlist_t *nvp);
494extern int spa_prop_get(spa_t *spa, nvlist_t **nvp);
495extern void spa_prop_clear_bootfs(spa_t *spa, uint64_t obj, dmu_tx_t *tx);
496
497/* asynchronous event notification */
498extern void spa_event_notify(spa_t *spa, vdev_t *vdev, const char *name);
499
500#ifdef ZFS_DEBUG
501#define	dprintf_bp(bp, fmt, ...) do {				\
502	if (zfs_flags & ZFS_DEBUG_DPRINTF) { 			\
503	char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP);	\
504	sprintf_blkptr(__blkbuf, BP_SPRINTF_LEN, (bp));		\
505	dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf);		\
506	kmem_free(__blkbuf, BP_SPRINTF_LEN);			\
507	} \
508_NOTE(CONSTCOND) } while (0)
509#else
510#define	dprintf_bp(bp, fmt, ...)
511#endif
512
513extern int spa_mode;			/* mode, e.g. FREAD | FWRITE */
514
515#ifdef	__cplusplus
516}
517#endif
518
519#endif	/* _SYS_SPA_H */
520