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