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