xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/vdev_impl.h (revision 084fd14f7c3336eb67ee283cabad2da8998b00d6)
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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
24  * Copyright (c) 2017, Intel Corporation.
25  * Copyright 2019 Joyent, Inc.
26  */
27 
28 #ifndef _SYS_VDEV_IMPL_H
29 #define	_SYS_VDEV_IMPL_H
30 
31 #include <sys/avl.h>
32 #include <sys/bpobj.h>
33 #include <sys/dmu.h>
34 #include <sys/metaslab.h>
35 #include <sys/nvpair.h>
36 #include <sys/space_map.h>
37 #include <sys/vdev.h>
38 #include <sys/dkio.h>
39 #include <sys/uberblock_impl.h>
40 #include <sys/vdev_indirect_mapping.h>
41 #include <sys/vdev_indirect_births.h>
42 #include <sys/vdev_removal.h>
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 /*
49  * Virtual device descriptors.
50  *
51  * All storage pool operations go through the virtual device framework,
52  * which provides data replication and I/O scheduling.
53  */
54 
55 /*
56  * Forward declarations that lots of things need.
57  */
58 typedef struct vdev_queue vdev_queue_t;
59 typedef struct vdev_cache vdev_cache_t;
60 typedef struct vdev_cache_entry vdev_cache_entry_t;
61 struct abd;
62 
63 extern int zfs_vdev_queue_depth_pct;
64 extern int zfs_vdev_def_queue_depth;
65 extern uint32_t zfs_vdev_async_write_max_active;
66 
67 /*
68  * Virtual device operations
69  */
70 typedef int	vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size,
71     uint64_t *ashift);
72 typedef void	vdev_close_func_t(vdev_t *vd);
73 typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize);
74 typedef void	vdev_io_start_func_t(zio_t *zio);
75 typedef void	vdev_io_done_func_t(zio_t *zio);
76 typedef void	vdev_state_change_func_t(vdev_t *vd, int, int);
77 typedef boolean_t vdev_need_resilver_func_t(vdev_t *vd, uint64_t, size_t);
78 typedef void	vdev_hold_func_t(vdev_t *vd);
79 typedef void	vdev_rele_func_t(vdev_t *vd);
80 
81 typedef void	vdev_remap_cb_t(uint64_t inner_offset, vdev_t *vd,
82     uint64_t offset, uint64_t size, void *arg);
83 typedef void	vdev_remap_func_t(vdev_t *vd, uint64_t offset, uint64_t size,
84     vdev_remap_cb_t callback, void *arg);
85 /*
86  * Given a target vdev, translates the logical range "in" to the physical
87  * range "res"
88  */
89 typedef void vdev_xlation_func_t(vdev_t *cvd, const range_seg_t *in,
90     range_seg_t *res);
91 
92 typedef struct vdev_ops {
93 	vdev_open_func_t		*vdev_op_open;
94 	vdev_close_func_t		*vdev_op_close;
95 	vdev_asize_func_t		*vdev_op_asize;
96 	vdev_io_start_func_t		*vdev_op_io_start;
97 	vdev_io_done_func_t		*vdev_op_io_done;
98 	vdev_state_change_func_t	*vdev_op_state_change;
99 	vdev_need_resilver_func_t	*vdev_op_need_resilver;
100 	vdev_hold_func_t		*vdev_op_hold;
101 	vdev_rele_func_t		*vdev_op_rele;
102 	vdev_remap_func_t		*vdev_op_remap;
103 	/*
104 	 * For translating ranges from non-leaf vdevs (e.g. raidz) to leaves.
105 	 * Used when initializing vdevs. Isn't used by leaf ops.
106 	 */
107 	vdev_xlation_func_t		*vdev_op_xlate;
108 	char				vdev_op_type[16];
109 	boolean_t			vdev_op_leaf;
110 } vdev_ops_t;
111 
112 /*
113  * Virtual device properties
114  */
115 struct vdev_cache_entry {
116 	struct abd	*ve_abd;
117 	uint64_t	ve_offset;
118 	uint64_t	ve_lastused;
119 	avl_node_t	ve_offset_node;
120 	avl_node_t	ve_lastused_node;
121 	uint32_t	ve_hits;
122 	uint16_t	ve_missed_update;
123 	zio_t		*ve_fill_io;
124 };
125 
126 struct vdev_cache {
127 	avl_tree_t	vc_offset_tree;
128 	avl_tree_t	vc_lastused_tree;
129 	kmutex_t	vc_lock;
130 };
131 
132 typedef struct vdev_queue_class {
133 	uint32_t	vqc_active;
134 
135 	/*
136 	 * Sorted by offset or timestamp, depending on if the queue is
137 	 * LBA-ordered vs FIFO.
138 	 */
139 	avl_tree_t	vqc_queued_tree;
140 } vdev_queue_class_t;
141 
142 struct vdev_queue {
143 	vdev_t		*vq_vdev;
144 	vdev_queue_class_t vq_class[ZIO_PRIORITY_NUM_QUEUEABLE];
145 	avl_tree_t	vq_active_tree;
146 	avl_tree_t	vq_read_offset_tree;
147 	avl_tree_t	vq_write_offset_tree;
148 	avl_tree_t	vq_trim_offset_tree;
149 	uint64_t	vq_last_offset;
150 	hrtime_t	vq_io_complete_ts; /* time last i/o completed */
151 	kmutex_t	vq_lock;
152 };
153 
154 typedef enum vdev_alloc_bias {
155 	VDEV_BIAS_NONE,
156 	VDEV_BIAS_LOG,		/* dedicated to ZIL data (SLOG) */
157 	VDEV_BIAS_SPECIAL,	/* dedicated to ddt, metadata, and small blks */
158 	VDEV_BIAS_DEDUP		/* dedicated to dedup metadata */
159 } vdev_alloc_bias_t;
160 
161 
162 /*
163  * On-disk indirect vdev state.
164  *
165  * An indirect vdev is described exclusively in the MOS config of a pool.
166  * The config for an indirect vdev includes several fields, which are
167  * accessed in memory by a vdev_indirect_config_t.
168  */
169 typedef struct vdev_indirect_config {
170 	/*
171 	 * Object (in MOS) which contains the indirect mapping. This object
172 	 * contains an array of vdev_indirect_mapping_entry_phys_t ordered by
173 	 * vimep_src. The bonus buffer for this object is a
174 	 * vdev_indirect_mapping_phys_t. This object is allocated when a vdev
175 	 * removal is initiated.
176 	 *
177 	 * Note that this object can be empty if none of the data on the vdev
178 	 * has been copied yet.
179 	 */
180 	uint64_t	vic_mapping_object;
181 
182 	/*
183 	 * Object (in MOS) which contains the birth times for the mapping
184 	 * entries. This object contains an array of
185 	 * vdev_indirect_birth_entry_phys_t sorted by vibe_offset. The bonus
186 	 * buffer for this object is a vdev_indirect_birth_phys_t. This object
187 	 * is allocated when a vdev removal is initiated.
188 	 *
189 	 * Note that this object can be empty if none of the vdev has yet been
190 	 * copied.
191 	 */
192 	uint64_t	vic_births_object;
193 
194 	/*
195 	 * This is the vdev ID which was removed previous to this vdev, or
196 	 * UINT64_MAX if there are no previously removed vdevs.
197 	 */
198 	uint64_t	vic_prev_indirect_vdev;
199 } vdev_indirect_config_t;
200 
201 /*
202  * Virtual device descriptor
203  */
204 struct vdev {
205 	/*
206 	 * Common to all vdev types.
207 	 */
208 	uint64_t	vdev_id;	/* child number in vdev parent	*/
209 	uint64_t	vdev_guid;	/* unique ID for this vdev	*/
210 	uint64_t	vdev_guid_sum;	/* self guid + all child guids	*/
211 	uint64_t	vdev_orig_guid;	/* orig. guid prior to remove	*/
212 	uint64_t	vdev_asize;	/* allocatable device capacity	*/
213 	uint64_t	vdev_min_asize;	/* min acceptable asize		*/
214 	uint64_t	vdev_max_asize;	/* max acceptable asize		*/
215 	uint64_t	vdev_ashift;	/* block alignment shift	*/
216 	uint64_t	vdev_state;	/* see VDEV_STATE_* #defines	*/
217 	uint64_t	vdev_prevstate;	/* used when reopening a vdev	*/
218 	vdev_ops_t	*vdev_ops;	/* vdev operations		*/
219 	spa_t		*vdev_spa;	/* spa for this vdev		*/
220 	void		*vdev_tsd;	/* type-specific data		*/
221 	vnode_t		*vdev_name_vp;	/* vnode for pathname		*/
222 	vnode_t		*vdev_devid_vp;	/* vnode for devid		*/
223 	vdev_t		*vdev_top;	/* top-level vdev		*/
224 	vdev_t		*vdev_parent;	/* parent vdev			*/
225 	vdev_t		**vdev_child;	/* array of children		*/
226 	uint64_t	vdev_children;	/* number of children		*/
227 	vdev_stat_t	vdev_stat;	/* virtual device statistics	*/
228 	boolean_t	vdev_expanding;	/* expand the vdev?		*/
229 	boolean_t	vdev_reopening;	/* reopen in progress?		*/
230 	boolean_t	vdev_nonrot;	/* true if solid state		*/
231 	int		vdev_open_error; /* error on last open		*/
232 	kthread_t	*vdev_open_thread; /* thread opening children	*/
233 	uint64_t	vdev_crtxg;	/* txg when top-level was added */
234 
235 	/*
236 	 * Top-level vdev state.
237 	 */
238 	uint64_t	vdev_ms_array;	/* metaslab array object	*/
239 	uint64_t	vdev_ms_shift;	/* metaslab size shift		*/
240 	uint64_t	vdev_ms_count;	/* number of metaslabs		*/
241 	metaslab_group_t *vdev_mg;	/* metaslab group		*/
242 	metaslab_t	**vdev_ms;	/* metaslab array		*/
243 	txg_list_t	vdev_ms_list;	/* per-txg dirty metaslab lists	*/
244 	txg_list_t	vdev_dtl_list;	/* per-txg dirty DTL lists	*/
245 	txg_node_t	vdev_txg_node;	/* per-txg dirty vdev linkage	*/
246 	boolean_t	vdev_remove_wanted; /* async remove wanted?	*/
247 	boolean_t	vdev_probe_wanted; /* async probe wanted?	*/
248 	list_node_t	vdev_config_dirty_node; /* config dirty list	*/
249 	list_node_t	vdev_state_dirty_node; /* state dirty list	*/
250 	uint64_t	vdev_deflate_ratio; /* deflation ratio (x512)	*/
251 	uint64_t	vdev_islog;	/* is an intent log device	*/
252 	uint64_t	vdev_removing;	/* device is being removed?	*/
253 	boolean_t	vdev_ishole;	/* is a hole in the namespace	*/
254 	uint64_t	vdev_top_zap;
255 	vdev_alloc_bias_t vdev_alloc_bias; /* metaslab allocation bias	*/
256 
257 	/* pool checkpoint related */
258 	space_map_t	*vdev_checkpoint_sm;	/* contains reserved blocks */
259 
260 	/* Initialize related */
261 	boolean_t	vdev_initialize_exit_wanted;
262 	vdev_initializing_state_t	vdev_initialize_state;
263 	list_node_t	vdev_initialize_node;
264 	kthread_t	*vdev_initialize_thread;
265 	/* Protects vdev_initialize_thread and vdev_initialize_state. */
266 	kmutex_t	vdev_initialize_lock;
267 	kcondvar_t	vdev_initialize_cv;
268 	uint64_t	vdev_initialize_offset[TXG_SIZE];
269 	uint64_t	vdev_initialize_last_offset;
270 	range_tree_t	*vdev_initialize_tree;	/* valid while initializing */
271 	uint64_t	vdev_initialize_bytes_est;
272 	uint64_t	vdev_initialize_bytes_done;
273 	time_t		vdev_initialize_action_time;	/* start and end time */
274 
275 	/* TRIM related */
276 	boolean_t	vdev_trim_exit_wanted;
277 	boolean_t	vdev_autotrim_exit_wanted;
278 	vdev_trim_state_t	vdev_trim_state;
279 	list_node_t	vdev_trim_node;
280 	kmutex_t	vdev_autotrim_lock;
281 	kcondvar_t	vdev_autotrim_cv;
282 	kthread_t	*vdev_autotrim_thread;
283 	/* Protects vdev_trim_thread and vdev_trim_state. */
284 	kmutex_t	vdev_trim_lock;
285 	kcondvar_t	vdev_trim_cv;
286 	kthread_t	*vdev_trim_thread;
287 	uint64_t	vdev_trim_offset[TXG_SIZE];
288 	uint64_t	vdev_trim_last_offset;
289 	uint64_t	vdev_trim_bytes_est;
290 	uint64_t	vdev_trim_bytes_done;
291 	uint64_t	vdev_trim_rate;		/* requested rate (bytes/sec) */
292 	uint64_t	vdev_trim_partial;	/* requested partial TRIM */
293 	uint64_t	vdev_trim_secure;	/* requested secure TRIM */
294 	time_t		vdev_trim_action_time;	/* start and end time */
295 
296 	/* The following is not in ZoL, but used for auto-trim test progress */
297 	uint64_t	vdev_autotrim_bytes_done;
298 
299 	/* for limiting outstanding I/Os (initialize and TRIM) */
300 	kmutex_t	vdev_initialize_io_lock;
301 	kcondvar_t	vdev_initialize_io_cv;
302 	uint64_t	vdev_initialize_inflight;
303 	kmutex_t	vdev_trim_io_lock;
304 	kcondvar_t	vdev_trim_io_cv;
305 	uint64_t	vdev_trim_inflight[2];
306 
307 	/*
308 	 * Values stored in the config for an indirect or removing vdev.
309 	 */
310 	vdev_indirect_config_t	vdev_indirect_config;
311 
312 	/*
313 	 * The vdev_indirect_rwlock protects the vdev_indirect_mapping
314 	 * pointer from changing on indirect vdevs (when it is condensed).
315 	 * Note that removing (not yet indirect) vdevs have different
316 	 * access patterns (the mapping is not accessed from open context,
317 	 * e.g. from zio_read) and locking strategy (e.g. svr_lock).
318 	 */
319 	krwlock_t vdev_indirect_rwlock;
320 	vdev_indirect_mapping_t *vdev_indirect_mapping;
321 	vdev_indirect_births_t *vdev_indirect_births;
322 
323 	/*
324 	 * In memory data structures used to manage the obsolete sm, for
325 	 * indirect or removing vdevs.
326 	 *
327 	 * The vdev_obsolete_segments is the in-core record of the segments
328 	 * that are no longer referenced anywhere in the pool (due to
329 	 * being freed or remapped and not referenced by any snapshots).
330 	 * During a sync, segments are added to vdev_obsolete_segments
331 	 * via vdev_indirect_mark_obsolete(); at the end of each sync
332 	 * pass, this is appended to vdev_obsolete_sm via
333 	 * vdev_indirect_sync_obsolete().  The vdev_obsolete_lock
334 	 * protects against concurrent modifications of vdev_obsolete_segments
335 	 * from multiple zio threads.
336 	 */
337 	kmutex_t	vdev_obsolete_lock;
338 	range_tree_t	*vdev_obsolete_segments;
339 	space_map_t	*vdev_obsolete_sm;
340 
341 	/*
342 	 * Protects the vdev_scan_io_queue field itself as well as the
343 	 * structure's contents (when present).
344 	 */
345 	kmutex_t	vdev_scan_io_queue_lock;
346 	struct dsl_scan_io_queue	*vdev_scan_io_queue;
347 
348 	/*
349 	 * Leaf vdev state.
350 	 */
351 	range_tree_t	*vdev_dtl[DTL_TYPES]; /* dirty time logs	*/
352 	space_map_t	*vdev_dtl_sm;	/* dirty time log space map	*/
353 	txg_node_t	vdev_dtl_node;	/* per-txg dirty DTL linkage	*/
354 	uint64_t	vdev_dtl_object; /* DTL object			*/
355 	uint64_t	vdev_psize;	/* physical device capacity	*/
356 	uint64_t	vdev_wholedisk;	/* true if this is a whole disk */
357 	uint64_t	vdev_offline;	/* persistent offline state	*/
358 	uint64_t	vdev_faulted;	/* persistent faulted state	*/
359 	uint64_t	vdev_degraded;	/* persistent degraded state	*/
360 	uint64_t	vdev_removed;	/* persistent removed state	*/
361 	uint64_t	vdev_resilver_txg; /* persistent resilvering state */
362 	uint64_t	vdev_nparity;	/* number of parity devices for raidz */
363 	char		*vdev_path;	/* vdev path (if any)		*/
364 	char		*vdev_devid;	/* vdev devid (if any)		*/
365 	char		*vdev_physpath;	/* vdev device path (if any)	*/
366 	char		*vdev_fru;	/* physical FRU location	*/
367 	uint64_t	vdev_not_present; /* not present during import	*/
368 	uint64_t	vdev_unspare;	/* unspare when resilvering done */
369 	boolean_t	vdev_nowritecache; /* true if flushwritecache failed */
370 	boolean_t	vdev_has_trim;	/* TRIM is supported		*/
371 	boolean_t	vdev_has_securetrim; /* secure TRIM is supported */
372 	boolean_t	vdev_checkremove; /* temporary online test	*/
373 	boolean_t	vdev_forcefault; /* force online fault		*/
374 	boolean_t	vdev_splitting;	/* split or repair in progress  */
375 	boolean_t	vdev_delayed_close; /* delayed device close?	*/
376 	boolean_t	vdev_tmpoffline; /* device taken offline temporarily? */
377 	boolean_t	vdev_detached;	/* device detached?		*/
378 	boolean_t	vdev_cant_read;	/* vdev is failing all reads	*/
379 	boolean_t	vdev_cant_write; /* vdev is failing all writes	*/
380 	boolean_t	vdev_isspare;	/* was a hot spare		*/
381 	boolean_t	vdev_isl2cache;	/* was a l2cache device		*/
382 	boolean_t	vdev_resilver_deferred;  /* resilver deferred */
383 	vdev_queue_t	vdev_queue;	/* I/O deadline schedule queue	*/
384 	vdev_cache_t	vdev_cache;	/* physical block cache		*/
385 	spa_aux_vdev_t	*vdev_aux;	/* for l2cache and spares vdevs	*/
386 	zio_t		*vdev_probe_zio; /* root of current probe	*/
387 	vdev_aux_t	vdev_label_aux;	/* on-disk aux state		*/
388 	uint64_t	vdev_leaf_zap;
389 	hrtime_t	vdev_mmp_pending; /* 0 if write finished	*/
390 	uint64_t	vdev_mmp_kstat_id;	/* to find kstat entry */
391 	list_node_t	vdev_leaf_node;		/* leaf vdev list */
392 
393 	/*
394 	 * For DTrace to work in userland (libzpool) context, these fields must
395 	 * remain at the end of the structure.  DTrace will use the kernel's
396 	 * CTF definition for 'struct vdev', and since the size of a kmutex_t is
397 	 * larger in userland, the offsets for the rest of the fields would be
398 	 * incorrect.
399 	 */
400 	kmutex_t	vdev_dtl_lock;	/* vdev_dtl_{map,resilver}	*/
401 	kmutex_t	vdev_stat_lock;	/* vdev_stat			*/
402 	kmutex_t	vdev_probe_lock; /* protects vdev_probe_zio	*/
403 };
404 
405 #define	VDEV_RAIDZ_MAXPARITY	3
406 
407 #define	VDEV_PAD_SIZE		(8 << 10)
408 /* 2 padding areas (vl_pad1 and vl_pad2) to skip */
409 #define	VDEV_SKIP_SIZE		VDEV_PAD_SIZE * 2
410 #define	VDEV_PHYS_SIZE		(112 << 10)
411 #define	VDEV_UBERBLOCK_RING	(128 << 10)
412 
413 /*
414  * MMP blocks occupy the last MMP_BLOCKS_PER_LABEL slots in the uberblock
415  * ring when MMP is enabled.
416  */
417 #define	MMP_BLOCKS_PER_LABEL	1
418 
419 /* The largest uberblock we support is 8k. */
420 #define	MAX_UBERBLOCK_SHIFT (13)
421 #define	VDEV_UBERBLOCK_SHIFT(vd)	\
422 	MIN(MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT), \
423 	    MAX_UBERBLOCK_SHIFT)
424 #define	VDEV_UBERBLOCK_COUNT(vd)	\
425 	(VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd))
426 #define	VDEV_UBERBLOCK_OFFSET(vd, n)	\
427 	offsetof(vdev_label_t, vl_uberblock[(n) << VDEV_UBERBLOCK_SHIFT(vd)])
428 #define	VDEV_UBERBLOCK_SIZE(vd)		(1ULL << VDEV_UBERBLOCK_SHIFT(vd))
429 
430 typedef struct vdev_phys {
431 	char		vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_eck_t)];
432 	zio_eck_t	vp_zbt;
433 } vdev_phys_t;
434 
435 typedef struct vdev_label {
436 	char		vl_pad1[VDEV_PAD_SIZE];			/*  8K */
437 	char		vl_pad2[VDEV_PAD_SIZE];			/*  8K */
438 	vdev_phys_t	vl_vdev_phys;				/* 112K	*/
439 	char		vl_uberblock[VDEV_UBERBLOCK_RING];	/* 128K	*/
440 } vdev_label_t;							/* 256K total */
441 
442 /*
443  * vdev_dirty() flags
444  */
445 #define	VDD_METASLAB	0x01
446 #define	VDD_DTL		0x02
447 
448 /* Offset of embedded boot loader region on each label */
449 #define	VDEV_BOOT_OFFSET	(2 * sizeof (vdev_label_t))
450 /*
451  * Size of embedded boot loader region on each label.
452  * The total size of the first two labels plus the boot area is 4MB.
453  */
454 #define	VDEV_BOOT_SIZE		(7ULL << 19)			/* 3.5M */
455 
456 /*
457  * Size of label regions at the start and end of each leaf device.
458  */
459 #define	VDEV_LABEL_START_SIZE	(2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)
460 #define	VDEV_LABEL_END_SIZE	(2 * sizeof (vdev_label_t))
461 #define	VDEV_LABELS		4
462 #define	VDEV_BEST_LABEL		VDEV_LABELS
463 
464 #define	VDEV_ALLOC_LOAD		0
465 #define	VDEV_ALLOC_ADD		1
466 #define	VDEV_ALLOC_SPARE	2
467 #define	VDEV_ALLOC_L2CACHE	3
468 #define	VDEV_ALLOC_ROOTPOOL	4
469 #define	VDEV_ALLOC_SPLIT	5
470 #define	VDEV_ALLOC_ATTACH	6
471 
472 /*
473  * Allocate or free a vdev
474  */
475 extern vdev_t *vdev_alloc_common(spa_t *spa, uint_t id, uint64_t guid,
476     vdev_ops_t *ops);
477 extern int vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *config,
478     vdev_t *parent, uint_t id, int alloctype);
479 extern void vdev_free(vdev_t *vd);
480 
481 /*
482  * Add or remove children and parents
483  */
484 extern void vdev_add_child(vdev_t *pvd, vdev_t *cvd);
485 extern void vdev_remove_child(vdev_t *pvd, vdev_t *cvd);
486 extern void vdev_compact_children(vdev_t *pvd);
487 extern vdev_t *vdev_add_parent(vdev_t *cvd, vdev_ops_t *ops);
488 extern void vdev_remove_parent(vdev_t *cvd);
489 
490 /*
491  * vdev sync load and sync
492  */
493 extern boolean_t vdev_log_state_valid(vdev_t *vd);
494 extern int vdev_load(vdev_t *vd);
495 extern int vdev_dtl_load(vdev_t *vd);
496 extern void vdev_sync(vdev_t *vd, uint64_t txg);
497 extern void vdev_sync_done(vdev_t *vd, uint64_t txg);
498 extern void vdev_dirty(vdev_t *vd, int flags, void *arg, uint64_t txg);
499 extern void vdev_dirty_leaves(vdev_t *vd, int flags, uint64_t txg);
500 
501 /*
502  * Available vdev types.
503  */
504 extern vdev_ops_t vdev_root_ops;
505 extern vdev_ops_t vdev_mirror_ops;
506 extern vdev_ops_t vdev_replacing_ops;
507 extern vdev_ops_t vdev_raidz_ops;
508 extern vdev_ops_t vdev_disk_ops;
509 extern vdev_ops_t vdev_file_ops;
510 extern vdev_ops_t vdev_missing_ops;
511 extern vdev_ops_t vdev_hole_ops;
512 extern vdev_ops_t vdev_spare_ops;
513 extern vdev_ops_t vdev_indirect_ops;
514 
515 /*
516  * Common size functions
517  */
518 extern void vdev_default_xlate(vdev_t *vd, const range_seg_t *in,
519     range_seg_t *out);
520 extern uint64_t vdev_default_asize(vdev_t *vd, uint64_t psize);
521 extern uint64_t vdev_get_min_asize(vdev_t *vd);
522 extern void vdev_set_min_asize(vdev_t *vd);
523 
524 /*
525  * Global variables
526  */
527 extern int vdev_standard_sm_blksz;
528 /* zdb uses this tunable, so it must be declared here to make lint happy. */
529 extern int zfs_vdev_cache_size;
530 
531 /*
532  * Functions from vdev_indirect.c
533  */
534 extern void vdev_indirect_sync_obsolete(vdev_t *vd, dmu_tx_t *tx);
535 extern boolean_t vdev_indirect_should_condense(vdev_t *vd);
536 extern void spa_condense_indirect_start_sync(vdev_t *vd, dmu_tx_t *tx);
537 extern int vdev_obsolete_sm_object(vdev_t *vd);
538 extern boolean_t vdev_obsolete_counts_are_precise(vdev_t *vd);
539 
540 /*
541  * Other miscellaneous functions
542  */
543 int vdev_checkpoint_sm_object(vdev_t *vd);
544 
545 /*
546  * The vdev_buf_t is used to translate between zio_t and buf_t, and back again.
547  */
548 typedef struct vdev_buf {
549 	buf_t	vb_buf;		/* buffer that describes the io */
550 	zio_t	*vb_io;		/* pointer back to the original zio_t */
551 } vdev_buf_t;
552 
553 #ifdef	__cplusplus
554 }
555 #endif
556 
557 #endif	/* _SYS_VDEV_IMPL_H */
558