]>
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 | /* | |
d164b209 | 22 | * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
34dc7c2f BB |
23 | * Use is subject to license terms. |
24 | */ | |
25 | ||
cc92e9d0 | 26 | /* |
492f64e9 | 27 | * Copyright (c) 2012, 2018 by Delphix. All rights reserved. |
cc92e9d0 GW |
28 | */ |
29 | ||
34dc7c2f | 30 | #include <sys/zfs_context.h> |
34dc7c2f | 31 | #include <sys/vdev_impl.h> |
330847ff | 32 | #include <sys/spa_impl.h> |
34dc7c2f BB |
33 | #include <sys/zio.h> |
34 | #include <sys/avl.h> | |
e8b96c60 | 35 | #include <sys/dsl_pool.h> |
3dfb57a3 | 36 | #include <sys/metaslab_impl.h> |
e8b96c60 MA |
37 | #include <sys/spa.h> |
38 | #include <sys/spa_impl.h> | |
330847ff | 39 | #include <sys/kstat.h> |
a6255b7f | 40 | #include <sys/abd.h> |
34dc7c2f BB |
41 | |
42 | /* | |
e8b96c60 MA |
43 | * ZFS I/O Scheduler |
44 | * --------------- | |
45 | * | |
46 | * ZFS issues I/O operations to leaf vdevs to satisfy and complete zios. The | |
47 | * I/O scheduler determines when and in what order those operations are | |
48 | * issued. The I/O scheduler divides operations into five I/O classes | |
49 | * prioritized in the following order: sync read, sync write, async read, | |
50 | * async write, and scrub/resilver. Each queue defines the minimum and | |
51 | * maximum number of concurrent operations that may be issued to the device. | |
52 | * In addition, the device has an aggregate maximum. Note that the sum of the | |
53 | * per-queue minimums must not exceed the aggregate maximum. If the | |
54 | * sum of the per-queue maximums exceeds the aggregate maximum, then the | |
55 | * number of active i/os may reach zfs_vdev_max_active, in which case no | |
56 | * further i/os will be issued regardless of whether all per-queue | |
57 | * minimums have been met. | |
58 | * | |
59 | * For many physical devices, throughput increases with the number of | |
60 | * concurrent operations, but latency typically suffers. Further, physical | |
61 | * devices typically have a limit at which more concurrent operations have no | |
62 | * effect on throughput or can actually cause it to decrease. | |
63 | * | |
64 | * The scheduler selects the next operation to issue by first looking for an | |
65 | * I/O class whose minimum has not been satisfied. Once all are satisfied and | |
66 | * the aggregate maximum has not been hit, the scheduler looks for classes | |
67 | * whose maximum has not been satisfied. Iteration through the I/O classes is | |
68 | * done in the order specified above. No further operations are issued if the | |
69 | * aggregate maximum number of concurrent operations has been hit or if there | |
70 | * are no operations queued for an I/O class that has not hit its maximum. | |
71 | * Every time an i/o is queued or an operation completes, the I/O scheduler | |
72 | * looks for new operations to issue. | |
73 | * | |
74 | * All I/O classes have a fixed maximum number of outstanding operations | |
75 | * except for the async write class. Asynchronous writes represent the data | |
76 | * that is committed to stable storage during the syncing stage for | |
77 | * transaction groups (see txg.c). Transaction groups enter the syncing state | |
78 | * periodically so the number of queued async writes will quickly burst up and | |
79 | * then bleed down to zero. Rather than servicing them as quickly as possible, | |
80 | * the I/O scheduler changes the maximum number of active async write i/os | |
81 | * according to the amount of dirty data in the pool (see dsl_pool.c). Since | |
82 | * both throughput and latency typically increase with the number of | |
83 | * concurrent operations issued to physical devices, reducing the burstiness | |
84 | * in the number of concurrent operations also stabilizes the response time of | |
85 | * operations from other -- and in particular synchronous -- queues. In broad | |
86 | * strokes, the I/O scheduler will issue more concurrent operations from the | |
87 | * async write queue as there's more dirty data in the pool. | |
88 | * | |
89 | * Async Writes | |
90 | * | |
91 | * The number of concurrent operations issued for the async write I/O class | |
92 | * follows a piece-wise linear function defined by a few adjustable points. | |
93 | * | |
94 | * | o---------| <-- zfs_vdev_async_write_max_active | |
95 | * ^ | /^ | | |
96 | * | | / | | | |
97 | * active | / | | | |
98 | * I/O | / | | | |
99 | * count | / | | | |
100 | * | / | | | |
101 | * |------------o | | <-- zfs_vdev_async_write_min_active | |
102 | * 0|____________^______|_________| | |
103 | * 0% | | 100% of zfs_dirty_data_max | |
104 | * | | | |
105 | * | `-- zfs_vdev_async_write_active_max_dirty_percent | |
106 | * `--------- zfs_vdev_async_write_active_min_dirty_percent | |
107 | * | |
108 | * Until the amount of dirty data exceeds a minimum percentage of the dirty | |
109 | * data allowed in the pool, the I/O scheduler will limit the number of | |
110 | * concurrent operations to the minimum. As that threshold is crossed, the | |
111 | * number of concurrent operations issued increases linearly to the maximum at | |
112 | * the specified maximum percentage of the dirty data allowed in the pool. | |
113 | * | |
114 | * Ideally, the amount of dirty data on a busy pool will stay in the sloped | |
115 | * part of the function between zfs_vdev_async_write_active_min_dirty_percent | |
116 | * and zfs_vdev_async_write_active_max_dirty_percent. If it exceeds the | |
117 | * maximum percentage, this indicates that the rate of incoming data is | |
118 | * greater than the rate that the backend storage can handle. In this case, we | |
119 | * must further throttle incoming writes (see dmu_tx_delay() for details). | |
34dc7c2f | 120 | */ |
d3cc8b15 | 121 | |
34dc7c2f | 122 | /* |
e8b96c60 MA |
123 | * The maximum number of i/os active to each device. Ideally, this will be >= |
124 | * the sum of each queue's max_active. It must be at least the sum of each | |
125 | * queue's min_active. | |
34dc7c2f | 126 | */ |
e8b96c60 | 127 | uint32_t zfs_vdev_max_active = 1000; |
34dc7c2f | 128 | |
cb682a17 | 129 | /* |
e8b96c60 MA |
130 | * Per-queue limits on the number of i/os active to each device. If the |
131 | * number of active i/os is < zfs_vdev_max_active, then the min_active comes | |
132 | * into play. We will send min_active from each queue, and then select from | |
133 | * queues in the order defined by zio_priority_t. | |
134 | * | |
135 | * In general, smaller max_active's will lead to lower latency of synchronous | |
136 | * operations. Larger max_active's may lead to higher overall throughput, | |
137 | * depending on underlying storage. | |
138 | * | |
139 | * The ratio of the queues' max_actives determines the balance of performance | |
140 | * between reads, writes, and scrubs. E.g., increasing | |
141 | * zfs_vdev_scrub_max_active will cause the scrub or resilver to complete | |
142 | * more quickly, but reads and writes to have higher latency and lower | |
143 | * throughput. | |
cb682a17 | 144 | */ |
e8b96c60 MA |
145 | uint32_t zfs_vdev_sync_read_min_active = 10; |
146 | uint32_t zfs_vdev_sync_read_max_active = 10; | |
147 | uint32_t zfs_vdev_sync_write_min_active = 10; | |
148 | uint32_t zfs_vdev_sync_write_max_active = 10; | |
149 | uint32_t zfs_vdev_async_read_min_active = 1; | |
150 | uint32_t zfs_vdev_async_read_max_active = 3; | |
06226b59 | 151 | uint32_t zfs_vdev_async_write_min_active = 2; |
e8b96c60 MA |
152 | uint32_t zfs_vdev_async_write_max_active = 10; |
153 | uint32_t zfs_vdev_scrub_min_active = 1; | |
154 | uint32_t zfs_vdev_scrub_max_active = 2; | |
a1d477c2 MA |
155 | uint32_t zfs_vdev_removal_min_active = 1; |
156 | uint32_t zfs_vdev_removal_max_active = 2; | |
34dc7c2f | 157 | |
e8b96c60 MA |
158 | /* |
159 | * When the pool has less than zfs_vdev_async_write_active_min_dirty_percent | |
160 | * dirty data, use zfs_vdev_async_write_min_active. When it has more than | |
161 | * zfs_vdev_async_write_active_max_dirty_percent, use | |
162 | * zfs_vdev_async_write_max_active. The value is linearly interpolated | |
163 | * between min and max. | |
164 | */ | |
165 | int zfs_vdev_async_write_active_min_dirty_percent = 30; | |
166 | int zfs_vdev_async_write_active_max_dirty_percent = 60; | |
34dc7c2f BB |
167 | |
168 | /* | |
45d1cae3 BB |
169 | * To reduce IOPs, we aggregate small adjacent I/Os into one large I/O. |
170 | * For read I/Os, we also aggregate across small adjacency gaps; for writes | |
171 | * we include spans of optional I/Os to aid aggregation at the disk even when | |
172 | * they aren't able to help us aggregate at this level. | |
34dc7c2f | 173 | */ |
d4a72f23 | 174 | int zfs_vdev_aggregation_limit = 1 << 20; |
9babb374 | 175 | int zfs_vdev_read_gap_limit = 32 << 10; |
45d1cae3 | 176 | int zfs_vdev_write_gap_limit = 4 << 10; |
34dc7c2f | 177 | |
3dfb57a3 DB |
178 | /* |
179 | * Define the queue depth percentage for each top-level. This percentage is | |
180 | * used in conjunction with zfs_vdev_async_max_active to determine how many | |
181 | * allocations a specific top-level vdev should handle. Once the queue depth | |
182 | * reaches zfs_vdev_queue_depth_pct * zfs_vdev_async_write_max_active / 100 | |
183 | * then allocator will stop allocating blocks on that top-level device. | |
184 | * The default kernel setting is 1000% which will yield 100 allocations per | |
185 | * device. For userland testing, the default setting is 300% which equates | |
186 | * to 30 allocations per device. | |
187 | */ | |
188 | #ifdef _KERNEL | |
189 | int zfs_vdev_queue_depth_pct = 1000; | |
190 | #else | |
191 | int zfs_vdev_queue_depth_pct = 300; | |
192 | #endif | |
193 | ||
492f64e9 PD |
194 | /* |
195 | * When performing allocations for a given metaslab, we want to make sure that | |
196 | * there are enough IOs to aggregate together to improve throughput. We want to | |
197 | * ensure that there are at least 128k worth of IOs that can be aggregated, and | |
198 | * we assume that the average allocation size is 4k, so we need the queue depth | |
199 | * to be 32 per allocator to get good aggregation of sequential writes. | |
200 | */ | |
201 | int zfs_vdev_def_queue_depth = 32; | |
202 | ||
3dfb57a3 | 203 | |
34dc7c2f | 204 | int |
e8b96c60 | 205 | vdev_queue_offset_compare(const void *x1, const void *x2) |
34dc7c2f | 206 | { |
ee36c709 GN |
207 | const zio_t *z1 = (const zio_t *)x1; |
208 | const zio_t *z2 = (const zio_t *)x2; | |
34dc7c2f | 209 | |
ee36c709 | 210 | int cmp = AVL_CMP(z1->io_offset, z2->io_offset); |
34dc7c2f | 211 | |
ee36c709 GN |
212 | if (likely(cmp)) |
213 | return (cmp); | |
34dc7c2f | 214 | |
ee36c709 | 215 | return (AVL_PCMP(z1, z2)); |
34dc7c2f BB |
216 | } |
217 | ||
ec8501ee JG |
218 | static inline avl_tree_t * |
219 | vdev_queue_class_tree(vdev_queue_t *vq, zio_priority_t p) | |
220 | { | |
221 | return (&vq->vq_class[p].vqc_queued_tree); | |
222 | } | |
223 | ||
224 | static inline avl_tree_t * | |
225 | vdev_queue_type_tree(vdev_queue_t *vq, zio_type_t t) | |
226 | { | |
227 | ASSERT(t == ZIO_TYPE_READ || t == ZIO_TYPE_WRITE); | |
228 | if (t == ZIO_TYPE_READ) | |
229 | return (&vq->vq_read_offset_tree); | |
230 | else | |
231 | return (&vq->vq_write_offset_tree); | |
232 | } | |
233 | ||
34dc7c2f | 234 | int |
e8b96c60 | 235 | vdev_queue_timestamp_compare(const void *x1, const void *x2) |
34dc7c2f | 236 | { |
ee36c709 GN |
237 | const zio_t *z1 = (const zio_t *)x1; |
238 | const zio_t *z2 = (const zio_t *)x2; | |
34dc7c2f | 239 | |
ee36c709 | 240 | int cmp = AVL_CMP(z1->io_timestamp, z2->io_timestamp); |
34dc7c2f | 241 | |
ee36c709 GN |
242 | if (likely(cmp)) |
243 | return (cmp); | |
34dc7c2f | 244 | |
ee36c709 | 245 | return (AVL_PCMP(z1, z2)); |
34dc7c2f BB |
246 | } |
247 | ||
e8b96c60 MA |
248 | static int |
249 | vdev_queue_class_min_active(zio_priority_t p) | |
250 | { | |
251 | switch (p) { | |
252 | case ZIO_PRIORITY_SYNC_READ: | |
253 | return (zfs_vdev_sync_read_min_active); | |
254 | case ZIO_PRIORITY_SYNC_WRITE: | |
255 | return (zfs_vdev_sync_write_min_active); | |
256 | case ZIO_PRIORITY_ASYNC_READ: | |
257 | return (zfs_vdev_async_read_min_active); | |
258 | case ZIO_PRIORITY_ASYNC_WRITE: | |
259 | return (zfs_vdev_async_write_min_active); | |
260 | case ZIO_PRIORITY_SCRUB: | |
261 | return (zfs_vdev_scrub_min_active); | |
a1d477c2 MA |
262 | case ZIO_PRIORITY_REMOVAL: |
263 | return (zfs_vdev_removal_min_active); | |
e8b96c60 MA |
264 | default: |
265 | panic("invalid priority %u", p); | |
266 | return (0); | |
267 | } | |
268 | } | |
269 | ||
270 | static int | |
acbad6ff | 271 | vdev_queue_max_async_writes(spa_t *spa) |
e8b96c60 MA |
272 | { |
273 | int writes; | |
b7faa7aa G |
274 | uint64_t dirty = 0; |
275 | dsl_pool_t *dp = spa_get_dsl(spa); | |
e8b96c60 MA |
276 | uint64_t min_bytes = zfs_dirty_data_max * |
277 | zfs_vdev_async_write_active_min_dirty_percent / 100; | |
278 | uint64_t max_bytes = zfs_dirty_data_max * | |
279 | zfs_vdev_async_write_active_max_dirty_percent / 100; | |
280 | ||
b7faa7aa G |
281 | /* |
282 | * Async writes may occur before the assignment of the spa's | |
283 | * dsl_pool_t if a self-healing zio is issued prior to the | |
284 | * completion of dmu_objset_open_impl(). | |
285 | */ | |
286 | if (dp == NULL) | |
287 | return (zfs_vdev_async_write_max_active); | |
288 | ||
acbad6ff AR |
289 | /* |
290 | * Sync tasks correspond to interactive user actions. To reduce the | |
291 | * execution time of those actions we push data out as fast as possible. | |
292 | */ | |
b7faa7aa | 293 | if (spa_has_pending_synctask(spa)) |
acbad6ff | 294 | return (zfs_vdev_async_write_max_active); |
acbad6ff | 295 | |
b7faa7aa | 296 | dirty = dp->dp_dirty_total; |
e8b96c60 MA |
297 | if (dirty < min_bytes) |
298 | return (zfs_vdev_async_write_min_active); | |
299 | if (dirty > max_bytes) | |
300 | return (zfs_vdev_async_write_max_active); | |
301 | ||
302 | /* | |
303 | * linear interpolation: | |
304 | * slope = (max_writes - min_writes) / (max_bytes - min_bytes) | |
305 | * move right by min_bytes | |
306 | * move up by min_writes | |
307 | */ | |
308 | writes = (dirty - min_bytes) * | |
309 | (zfs_vdev_async_write_max_active - | |
310 | zfs_vdev_async_write_min_active) / | |
311 | (max_bytes - min_bytes) + | |
312 | zfs_vdev_async_write_min_active; | |
313 | ASSERT3U(writes, >=, zfs_vdev_async_write_min_active); | |
314 | ASSERT3U(writes, <=, zfs_vdev_async_write_max_active); | |
315 | return (writes); | |
316 | } | |
317 | ||
318 | static int | |
319 | vdev_queue_class_max_active(spa_t *spa, zio_priority_t p) | |
320 | { | |
321 | switch (p) { | |
322 | case ZIO_PRIORITY_SYNC_READ: | |
323 | return (zfs_vdev_sync_read_max_active); | |
324 | case ZIO_PRIORITY_SYNC_WRITE: | |
325 | return (zfs_vdev_sync_write_max_active); | |
326 | case ZIO_PRIORITY_ASYNC_READ: | |
327 | return (zfs_vdev_async_read_max_active); | |
328 | case ZIO_PRIORITY_ASYNC_WRITE: | |
acbad6ff | 329 | return (vdev_queue_max_async_writes(spa)); |
e8b96c60 MA |
330 | case ZIO_PRIORITY_SCRUB: |
331 | return (zfs_vdev_scrub_max_active); | |
a1d477c2 MA |
332 | case ZIO_PRIORITY_REMOVAL: |
333 | return (zfs_vdev_removal_max_active); | |
e8b96c60 MA |
334 | default: |
335 | panic("invalid priority %u", p); | |
336 | return (0); | |
337 | } | |
338 | } | |
339 | ||
340 | /* | |
341 | * Return the i/o class to issue from, or ZIO_PRIORITY_MAX_QUEUEABLE if | |
342 | * there is no eligible class. | |
343 | */ | |
344 | static zio_priority_t | |
345 | vdev_queue_class_to_issue(vdev_queue_t *vq) | |
346 | { | |
347 | spa_t *spa = vq->vq_vdev->vdev_spa; | |
348 | zio_priority_t p; | |
349 | ||
350 | if (avl_numnodes(&vq->vq_active_tree) >= zfs_vdev_max_active) | |
351 | return (ZIO_PRIORITY_NUM_QUEUEABLE); | |
352 | ||
353 | /* find a queue that has not reached its minimum # outstanding i/os */ | |
354 | for (p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) { | |
ec8501ee | 355 | if (avl_numnodes(vdev_queue_class_tree(vq, p)) > 0 && |
e8b96c60 MA |
356 | vq->vq_class[p].vqc_active < |
357 | vdev_queue_class_min_active(p)) | |
358 | return (p); | |
359 | } | |
360 | ||
361 | /* | |
362 | * If we haven't found a queue, look for one that hasn't reached its | |
363 | * maximum # outstanding i/os. | |
364 | */ | |
365 | for (p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) { | |
ec8501ee | 366 | if (avl_numnodes(vdev_queue_class_tree(vq, p)) > 0 && |
e8b96c60 MA |
367 | vq->vq_class[p].vqc_active < |
368 | vdev_queue_class_max_active(spa, p)) | |
369 | return (p); | |
370 | } | |
371 | ||
372 | /* No eligible queued i/os */ | |
373 | return (ZIO_PRIORITY_NUM_QUEUEABLE); | |
374 | } | |
375 | ||
34dc7c2f BB |
376 | void |
377 | vdev_queue_init(vdev_t *vd) | |
378 | { | |
379 | vdev_queue_t *vq = &vd->vdev_queue; | |
e8b96c60 | 380 | zio_priority_t p; |
34dc7c2f BB |
381 | |
382 | mutex_init(&vq->vq_lock, NULL, MUTEX_DEFAULT, NULL); | |
e8b96c60 | 383 | vq->vq_vdev = vd; |
36b454ab | 384 | taskq_init_ent(&vd->vdev_queue.vq_io_search.io_tqent); |
34dc7c2f | 385 | |
e8b96c60 MA |
386 | avl_create(&vq->vq_active_tree, vdev_queue_offset_compare, |
387 | sizeof (zio_t), offsetof(struct zio, io_queue_node)); | |
ec8501ee | 388 | avl_create(vdev_queue_type_tree(vq, ZIO_TYPE_READ), |
02730c33 BB |
389 | vdev_queue_offset_compare, sizeof (zio_t), |
390 | offsetof(struct zio, io_offset_node)); | |
ec8501ee | 391 | avl_create(vdev_queue_type_tree(vq, ZIO_TYPE_WRITE), |
02730c33 BB |
392 | vdev_queue_offset_compare, sizeof (zio_t), |
393 | offsetof(struct zio, io_offset_node)); | |
34dc7c2f | 394 | |
e8b96c60 | 395 | for (p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) { |
ec8501ee JG |
396 | int (*compfn) (const void *, const void *); |
397 | ||
e8b96c60 | 398 | /* |
ec8501ee JG |
399 | * The synchronous i/o queues are dispatched in FIFO rather |
400 | * than LBA order. This provides more consistent latency for | |
401 | * these i/os. | |
e8b96c60 | 402 | */ |
ec8501ee JG |
403 | if (p == ZIO_PRIORITY_SYNC_READ || p == ZIO_PRIORITY_SYNC_WRITE) |
404 | compfn = vdev_queue_timestamp_compare; | |
405 | else | |
406 | compfn = vdev_queue_offset_compare; | |
407 | avl_create(vdev_queue_class_tree(vq, p), compfn, | |
02730c33 | 408 | sizeof (zio_t), offsetof(struct zio, io_queue_node)); |
e8b96c60 | 409 | } |
9f500936 | 410 | |
d6c6590c | 411 | vq->vq_last_offset = 0; |
34dc7c2f BB |
412 | } |
413 | ||
414 | void | |
415 | vdev_queue_fini(vdev_t *vd) | |
416 | { | |
417 | vdev_queue_t *vq = &vd->vdev_queue; | |
418 | ||
1c27024e | 419 | for (zio_priority_t p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) |
ec8501ee | 420 | avl_destroy(vdev_queue_class_tree(vq, p)); |
e8b96c60 | 421 | avl_destroy(&vq->vq_active_tree); |
ec8501ee JG |
422 | avl_destroy(vdev_queue_type_tree(vq, ZIO_TYPE_READ)); |
423 | avl_destroy(vdev_queue_type_tree(vq, ZIO_TYPE_WRITE)); | |
34dc7c2f BB |
424 | |
425 | mutex_destroy(&vq->vq_lock); | |
426 | } | |
427 | ||
428 | static void | |
429 | vdev_queue_io_add(vdev_queue_t *vq, zio_t *zio) | |
430 | { | |
330847ff | 431 | spa_t *spa = zio->io_spa; |
d1261452 | 432 | spa_history_kstat_t *shk = &spa->spa_stats.io_history; |
330847ff | 433 | |
e8b96c60 | 434 | ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE); |
ec8501ee JG |
435 | avl_add(vdev_queue_class_tree(vq, zio->io_priority), zio); |
436 | avl_add(vdev_queue_type_tree(vq, zio->io_type), zio); | |
330847ff | 437 | |
d1261452 JG |
438 | if (shk->kstat != NULL) { |
439 | mutex_enter(&shk->lock); | |
440 | kstat_waitq_enter(shk->kstat->ks_data); | |
441 | mutex_exit(&shk->lock); | |
330847ff | 442 | } |
34dc7c2f BB |
443 | } |
444 | ||
445 | static void | |
446 | vdev_queue_io_remove(vdev_queue_t *vq, zio_t *zio) | |
447 | { | |
330847ff | 448 | spa_t *spa = zio->io_spa; |
d1261452 | 449 | spa_history_kstat_t *shk = &spa->spa_stats.io_history; |
330847ff | 450 | |
e8b96c60 | 451 | ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE); |
ec8501ee JG |
452 | avl_remove(vdev_queue_class_tree(vq, zio->io_priority), zio); |
453 | avl_remove(vdev_queue_type_tree(vq, zio->io_type), zio); | |
330847ff | 454 | |
d1261452 JG |
455 | if (shk->kstat != NULL) { |
456 | mutex_enter(&shk->lock); | |
457 | kstat_waitq_exit(shk->kstat->ks_data); | |
458 | mutex_exit(&shk->lock); | |
330847ff MA |
459 | } |
460 | } | |
461 | ||
462 | static void | |
463 | vdev_queue_pending_add(vdev_queue_t *vq, zio_t *zio) | |
464 | { | |
465 | spa_t *spa = zio->io_spa; | |
d1261452 | 466 | spa_history_kstat_t *shk = &spa->spa_stats.io_history; |
330847ff | 467 | |
e8b96c60 MA |
468 | ASSERT(MUTEX_HELD(&vq->vq_lock)); |
469 | ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE); | |
470 | vq->vq_class[zio->io_priority].vqc_active++; | |
471 | avl_add(&vq->vq_active_tree, zio); | |
330847ff | 472 | |
d1261452 JG |
473 | if (shk->kstat != NULL) { |
474 | mutex_enter(&shk->lock); | |
475 | kstat_runq_enter(shk->kstat->ks_data); | |
476 | mutex_exit(&shk->lock); | |
330847ff MA |
477 | } |
478 | } | |
479 | ||
480 | static void | |
481 | vdev_queue_pending_remove(vdev_queue_t *vq, zio_t *zio) | |
482 | { | |
483 | spa_t *spa = zio->io_spa; | |
d1261452 | 484 | spa_history_kstat_t *shk = &spa->spa_stats.io_history; |
330847ff | 485 | |
e8b96c60 MA |
486 | ASSERT(MUTEX_HELD(&vq->vq_lock)); |
487 | ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE); | |
488 | vq->vq_class[zio->io_priority].vqc_active--; | |
489 | avl_remove(&vq->vq_active_tree, zio); | |
330847ff | 490 | |
d1261452 JG |
491 | if (shk->kstat != NULL) { |
492 | kstat_io_t *ksio = shk->kstat->ks_data; | |
330847ff | 493 | |
d1261452 | 494 | mutex_enter(&shk->lock); |
330847ff MA |
495 | kstat_runq_exit(ksio); |
496 | if (zio->io_type == ZIO_TYPE_READ) { | |
497 | ksio->reads++; | |
498 | ksio->nread += zio->io_size; | |
499 | } else if (zio->io_type == ZIO_TYPE_WRITE) { | |
500 | ksio->writes++; | |
501 | ksio->nwritten += zio->io_size; | |
502 | } | |
d1261452 | 503 | mutex_exit(&shk->lock); |
330847ff | 504 | } |
34dc7c2f BB |
505 | } |
506 | ||
507 | static void | |
508 | vdev_queue_agg_io_done(zio_t *aio) | |
509 | { | |
e8b96c60 MA |
510 | if (aio->io_type == ZIO_TYPE_READ) { |
511 | zio_t *pio; | |
3dfb57a3 DB |
512 | zio_link_t *zl = NULL; |
513 | while ((pio = zio_walk_parents(aio, &zl)) != NULL) { | |
a6255b7f DQ |
514 | abd_copy_off(pio->io_abd, aio->io_abd, |
515 | 0, pio->io_offset - aio->io_offset, pio->io_size); | |
e8b96c60 MA |
516 | } |
517 | } | |
34dc7c2f | 518 | |
a6255b7f | 519 | abd_free(aio->io_abd); |
34dc7c2f BB |
520 | } |
521 | ||
9babb374 BB |
522 | /* |
523 | * Compute the range spanned by two i/os, which is the endpoint of the last | |
524 | * (lio->io_offset + lio->io_size) minus start of the first (fio->io_offset). | |
525 | * Conveniently, the gap between fio and lio is given by -IO_SPAN(lio, fio); | |
526 | * thus fio and lio are adjacent if and only if IO_SPAN(lio, fio) == 0. | |
527 | */ | |
528 | #define IO_SPAN(fio, lio) ((lio)->io_offset + (lio)->io_size - (fio)->io_offset) | |
529 | #define IO_GAP(fio, lio) (-IO_SPAN(lio, fio)) | |
34dc7c2f BB |
530 | |
531 | static zio_t * | |
e8b96c60 | 532 | vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio) |
34dc7c2f | 533 | { |
e8b96c60 | 534 | zio_t *first, *last, *aio, *dio, *mandatory, *nio; |
a76f3d04 | 535 | zio_link_t *zl = NULL; |
e8b96c60 MA |
536 | uint64_t maxgap = 0; |
537 | uint64_t size; | |
a58df6f5 | 538 | uint64_t limit; |
2d678f77 | 539 | int maxblocksize; |
e8b96c60 | 540 | boolean_t stretch = B_FALSE; |
ec8501ee | 541 | avl_tree_t *t = vdev_queue_type_tree(vq, zio->io_type); |
e8b96c60 | 542 | enum zio_flag flags = zio->io_flags & ZIO_FLAG_AGG_INHERIT; |
a6255b7f | 543 | abd_t *abd; |
e8b96c60 | 544 | |
2d678f77 BB |
545 | maxblocksize = spa_maxblocksize(vq->vq_vdev->vdev_spa); |
546 | limit = MAX(MIN(zfs_vdev_aggregation_limit, maxblocksize), 0); | |
34dc7c2f | 547 | |
a58df6f5 BB |
548 | if (zio->io_flags & ZIO_FLAG_DONT_AGGREGATE || limit == 0) |
549 | return (NULL); | |
34dc7c2f | 550 | |
e8b96c60 | 551 | first = last = zio; |
34dc7c2f | 552 | |
e8b96c60 MA |
553 | if (zio->io_type == ZIO_TYPE_READ) |
554 | maxgap = zfs_vdev_read_gap_limit; | |
fb5f0bc8 | 555 | |
e8b96c60 MA |
556 | /* |
557 | * We can aggregate I/Os that are sufficiently adjacent and of | |
558 | * the same flavor, as expressed by the AGG_INHERIT flags. | |
559 | * The latter requirement is necessary so that certain | |
560 | * attributes of the I/O, such as whether it's a normal I/O | |
561 | * or a scrub/resilver, can be preserved in the aggregate. | |
562 | * We can include optional I/Os, but don't allow them | |
563 | * to begin a range as they add no benefit in that situation. | |
564 | */ | |
45d1cae3 | 565 | |
e8b96c60 MA |
566 | /* |
567 | * We keep track of the last non-optional I/O. | |
568 | */ | |
569 | mandatory = (first->io_flags & ZIO_FLAG_OPTIONAL) ? NULL : first; | |
45d1cae3 | 570 | |
e8b96c60 MA |
571 | /* |
572 | * Walk backwards through sufficiently contiguous I/Os | |
8542ef85 | 573 | * recording the last non-optional I/O. |
e8b96c60 MA |
574 | */ |
575 | while ((dio = AVL_PREV(t, first)) != NULL && | |
576 | (dio->io_flags & ZIO_FLAG_AGG_INHERIT) == flags && | |
a58df6f5 | 577 | IO_SPAN(dio, last) <= limit && |
a1d477c2 MA |
578 | IO_GAP(dio, first) <= maxgap && |
579 | dio->io_type == zio->io_type) { | |
e8b96c60 MA |
580 | first = dio; |
581 | if (mandatory == NULL && !(first->io_flags & ZIO_FLAG_OPTIONAL)) | |
582 | mandatory = first; | |
583 | } | |
45d1cae3 | 584 | |
e8b96c60 MA |
585 | /* |
586 | * Skip any initial optional I/Os. | |
587 | */ | |
588 | while ((first->io_flags & ZIO_FLAG_OPTIONAL) && first != last) { | |
589 | first = AVL_NEXT(t, first); | |
590 | ASSERT(first != NULL); | |
591 | } | |
9babb374 | 592 | |
45d1cae3 | 593 | |
e8b96c60 MA |
594 | /* |
595 | * Walk forward through sufficiently contiguous I/Os. | |
8542ef85 MA |
596 | * The aggregation limit does not apply to optional i/os, so that |
597 | * we can issue contiguous writes even if they are larger than the | |
598 | * aggregation limit. | |
e8b96c60 MA |
599 | */ |
600 | while ((dio = AVL_NEXT(t, last)) != NULL && | |
601 | (dio->io_flags & ZIO_FLAG_AGG_INHERIT) == flags && | |
8542ef85 MA |
602 | (IO_SPAN(first, dio) <= limit || |
603 | (dio->io_flags & ZIO_FLAG_OPTIONAL)) && | |
2d678f77 | 604 | IO_SPAN(first, dio) <= maxblocksize && |
a1d477c2 MA |
605 | IO_GAP(last, dio) <= maxgap && |
606 | dio->io_type == zio->io_type) { | |
e8b96c60 MA |
607 | last = dio; |
608 | if (!(last->io_flags & ZIO_FLAG_OPTIONAL)) | |
609 | mandatory = last; | |
610 | } | |
611 | ||
612 | /* | |
613 | * Now that we've established the range of the I/O aggregation | |
614 | * we must decide what to do with trailing optional I/Os. | |
615 | * For reads, there's nothing to do. While we are unable to | |
616 | * aggregate further, it's possible that a trailing optional | |
617 | * I/O would allow the underlying device to aggregate with | |
618 | * subsequent I/Os. We must therefore determine if the next | |
619 | * non-optional I/O is close enough to make aggregation | |
620 | * worthwhile. | |
621 | */ | |
622 | if (zio->io_type == ZIO_TYPE_WRITE && mandatory != NULL) { | |
623 | zio_t *nio = last; | |
624 | while ((dio = AVL_NEXT(t, nio)) != NULL && | |
625 | IO_GAP(nio, dio) == 0 && | |
626 | IO_GAP(mandatory, dio) <= zfs_vdev_write_gap_limit) { | |
627 | nio = dio; | |
628 | if (!(nio->io_flags & ZIO_FLAG_OPTIONAL)) { | |
629 | stretch = B_TRUE; | |
630 | break; | |
45d1cae3 BB |
631 | } |
632 | } | |
e8b96c60 | 633 | } |
45d1cae3 | 634 | |
e8b96c60 | 635 | if (stretch) { |
8542ef85 MA |
636 | /* |
637 | * We are going to include an optional io in our aggregated | |
638 | * span, thus closing the write gap. Only mandatory i/os can | |
639 | * start aggregated spans, so make sure that the next i/o | |
640 | * after our span is mandatory. | |
641 | */ | |
e8b96c60 MA |
642 | dio = AVL_NEXT(t, last); |
643 | dio->io_flags &= ~ZIO_FLAG_OPTIONAL; | |
644 | } else { | |
8542ef85 | 645 | /* do not include the optional i/o */ |
e8b96c60 MA |
646 | while (last != mandatory && last != first) { |
647 | ASSERT(last->io_flags & ZIO_FLAG_OPTIONAL); | |
648 | last = AVL_PREV(t, last); | |
649 | ASSERT(last != NULL); | |
45d1cae3 | 650 | } |
34dc7c2f BB |
651 | } |
652 | ||
e8b96c60 MA |
653 | if (first == last) |
654 | return (NULL); | |
655 | ||
e8b96c60 | 656 | size = IO_SPAN(first, last); |
2d678f77 | 657 | ASSERT3U(size, <=, maxblocksize); |
e8b96c60 | 658 | |
a6255b7f DQ |
659 | abd = abd_alloc_for_io(size, B_TRUE); |
660 | if (abd == NULL) | |
6fe53787 BB |
661 | return (NULL); |
662 | ||
e8b96c60 | 663 | aio = zio_vdev_delegated_io(first->io_vd, first->io_offset, |
a6255b7f | 664 | abd, size, first->io_type, zio->io_priority, |
e8b96c60 MA |
665 | flags | ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE, |
666 | vdev_queue_agg_io_done, NULL); | |
667 | aio->io_timestamp = first->io_timestamp; | |
668 | ||
669 | nio = first; | |
670 | do { | |
671 | dio = nio; | |
672 | nio = AVL_NEXT(t, dio); | |
673 | ASSERT3U(dio->io_type, ==, aio->io_type); | |
674 | ||
675 | if (dio->io_flags & ZIO_FLAG_NODATA) { | |
676 | ASSERT3U(dio->io_type, ==, ZIO_TYPE_WRITE); | |
a6255b7f DQ |
677 | abd_zero_off(aio->io_abd, |
678 | dio->io_offset - aio->io_offset, dio->io_size); | |
e8b96c60 | 679 | } else if (dio->io_type == ZIO_TYPE_WRITE) { |
a6255b7f DQ |
680 | abd_copy_off(aio->io_abd, dio->io_abd, |
681 | dio->io_offset - aio->io_offset, 0, dio->io_size); | |
e8b96c60 | 682 | } |
d164b209 | 683 | |
e8b96c60 MA |
684 | zio_add_child(dio, aio); |
685 | vdev_queue_io_remove(vq, dio); | |
a76f3d04 BB |
686 | } while (dio != last); |
687 | ||
688 | /* | |
689 | * We need to drop the vdev queue's lock to avoid a deadlock that we | |
690 | * could encounter since this I/O will complete immediately. | |
691 | */ | |
692 | mutex_exit(&vq->vq_lock); | |
693 | while ((dio = zio_walk_parents(aio, &zl)) != NULL) { | |
e8b96c60 MA |
694 | zio_vdev_io_bypass(dio); |
695 | zio_execute(dio); | |
a76f3d04 BB |
696 | } |
697 | mutex_enter(&vq->vq_lock); | |
34dc7c2f | 698 | |
e8b96c60 MA |
699 | return (aio); |
700 | } | |
701 | ||
702 | static zio_t * | |
703 | vdev_queue_io_to_issue(vdev_queue_t *vq) | |
704 | { | |
705 | zio_t *zio, *aio; | |
706 | zio_priority_t p; | |
707 | avl_index_t idx; | |
ec8501ee | 708 | avl_tree_t *tree; |
e8b96c60 MA |
709 | |
710 | again: | |
711 | ASSERT(MUTEX_HELD(&vq->vq_lock)); | |
712 | ||
713 | p = vdev_queue_class_to_issue(vq); | |
34dc7c2f | 714 | |
e8b96c60 MA |
715 | if (p == ZIO_PRIORITY_NUM_QUEUEABLE) { |
716 | /* No eligible queued i/os */ | |
717 | return (NULL); | |
34dc7c2f BB |
718 | } |
719 | ||
e8b96c60 MA |
720 | /* |
721 | * For LBA-ordered queues (async / scrub), issue the i/o which follows | |
722 | * the most recently issued i/o in LBA (offset) order. | |
723 | * | |
724 | * For FIFO queues (sync), issue the i/o with the lowest timestamp. | |
725 | */ | |
ec8501ee | 726 | tree = vdev_queue_class_tree(vq, p); |
50b25b21 | 727 | vq->vq_io_search.io_timestamp = 0; |
d6c6590c GN |
728 | vq->vq_io_search.io_offset = vq->vq_last_offset - 1; |
729 | VERIFY3P(avl_find(tree, &vq->vq_io_search, &idx), ==, NULL); | |
ec8501ee | 730 | zio = avl_nearest(tree, idx, AVL_AFTER); |
e8b96c60 | 731 | if (zio == NULL) |
ec8501ee | 732 | zio = avl_first(tree); |
e8b96c60 MA |
733 | ASSERT3U(zio->io_priority, ==, p); |
734 | ||
735 | aio = vdev_queue_aggregate(vq, zio); | |
736 | if (aio != NULL) | |
737 | zio = aio; | |
738 | else | |
739 | vdev_queue_io_remove(vq, zio); | |
34dc7c2f | 740 | |
45d1cae3 BB |
741 | /* |
742 | * If the I/O is or was optional and therefore has no data, we need to | |
743 | * simply discard it. We need to drop the vdev queue's lock to avoid a | |
744 | * deadlock that we could encounter since this I/O will complete | |
745 | * immediately. | |
746 | */ | |
e8b96c60 | 747 | if (zio->io_flags & ZIO_FLAG_NODATA) { |
45d1cae3 | 748 | mutex_exit(&vq->vq_lock); |
e8b96c60 MA |
749 | zio_vdev_io_bypass(zio); |
750 | zio_execute(zio); | |
45d1cae3 BB |
751 | mutex_enter(&vq->vq_lock); |
752 | goto again; | |
753 | } | |
754 | ||
e8b96c60 | 755 | vdev_queue_pending_add(vq, zio); |
d6c6590c | 756 | vq->vq_last_offset = zio->io_offset + zio->io_size; |
34dc7c2f | 757 | |
e8b96c60 | 758 | return (zio); |
34dc7c2f BB |
759 | } |
760 | ||
761 | zio_t * | |
762 | vdev_queue_io(zio_t *zio) | |
763 | { | |
764 | vdev_queue_t *vq = &zio->io_vd->vdev_queue; | |
765 | zio_t *nio; | |
766 | ||
34dc7c2f BB |
767 | if (zio->io_flags & ZIO_FLAG_DONT_QUEUE) |
768 | return (zio); | |
769 | ||
e8b96c60 MA |
770 | /* |
771 | * Children i/os inherent their parent's priority, which might | |
772 | * not match the child's i/o type. Fix it up here. | |
773 | */ | |
774 | if (zio->io_type == ZIO_TYPE_READ) { | |
775 | if (zio->io_priority != ZIO_PRIORITY_SYNC_READ && | |
776 | zio->io_priority != ZIO_PRIORITY_ASYNC_READ && | |
a1d477c2 MA |
777 | zio->io_priority != ZIO_PRIORITY_SCRUB && |
778 | zio->io_priority != ZIO_PRIORITY_REMOVAL) | |
e8b96c60 MA |
779 | zio->io_priority = ZIO_PRIORITY_ASYNC_READ; |
780 | } else { | |
781 | ASSERT(zio->io_type == ZIO_TYPE_WRITE); | |
782 | if (zio->io_priority != ZIO_PRIORITY_SYNC_WRITE && | |
a1d477c2 MA |
783 | zio->io_priority != ZIO_PRIORITY_ASYNC_WRITE && |
784 | zio->io_priority != ZIO_PRIORITY_REMOVAL) | |
e8b96c60 MA |
785 | zio->io_priority = ZIO_PRIORITY_ASYNC_WRITE; |
786 | } | |
34dc7c2f | 787 | |
e8b96c60 | 788 | zio->io_flags |= ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE; |
34dc7c2f BB |
789 | |
790 | mutex_enter(&vq->vq_lock); | |
cb682a17 | 791 | zio->io_timestamp = gethrtime(); |
34dc7c2f | 792 | vdev_queue_io_add(vq, zio); |
e8b96c60 | 793 | nio = vdev_queue_io_to_issue(vq); |
34dc7c2f BB |
794 | mutex_exit(&vq->vq_lock); |
795 | ||
796 | if (nio == NULL) | |
797 | return (NULL); | |
798 | ||
799 | if (nio->io_done == vdev_queue_agg_io_done) { | |
800 | zio_nowait(nio); | |
801 | return (NULL); | |
802 | } | |
803 | ||
804 | return (nio); | |
805 | } | |
806 | ||
807 | void | |
808 | vdev_queue_io_done(zio_t *zio) | |
809 | { | |
810 | vdev_queue_t *vq = &zio->io_vd->vdev_queue; | |
e8b96c60 | 811 | zio_t *nio; |
34dc7c2f BB |
812 | |
813 | mutex_enter(&vq->vq_lock); | |
814 | ||
330847ff | 815 | vdev_queue_pending_remove(vq, zio); |
34dc7c2f | 816 | |
cb682a17 MA |
817 | zio->io_delta = gethrtime() - zio->io_timestamp; |
818 | vq->vq_io_complete_ts = gethrtime(); | |
cc92e9d0 GW |
819 | vq->vq_io_delta_ts = vq->vq_io_complete_ts - zio->io_timestamp; |
820 | ||
e8b96c60 | 821 | while ((nio = vdev_queue_io_to_issue(vq)) != NULL) { |
34dc7c2f BB |
822 | mutex_exit(&vq->vq_lock); |
823 | if (nio->io_done == vdev_queue_agg_io_done) { | |
824 | zio_nowait(nio); | |
825 | } else { | |
826 | zio_vdev_io_reissue(nio); | |
827 | zio_execute(nio); | |
828 | } | |
829 | mutex_enter(&vq->vq_lock); | |
830 | } | |
831 | ||
832 | mutex_exit(&vq->vq_lock); | |
833 | } | |
c28b2279 | 834 | |
a8b2e306 TC |
835 | void |
836 | vdev_queue_change_io_priority(zio_t *zio, zio_priority_t priority) | |
837 | { | |
838 | vdev_queue_t *vq = &zio->io_vd->vdev_queue; | |
839 | avl_tree_t *tree; | |
840 | ||
c26cf096 TH |
841 | /* |
842 | * ZIO_PRIORITY_NOW is used by the vdev cache code and the aggregate zio | |
843 | * code to issue IOs without adding them to the vdev queue. In this | |
844 | * case, the zio is already going to be issued as quickly as possible | |
845 | * and so it doesn't need any reprioitization to help. | |
846 | */ | |
847 | if (zio->io_priority == ZIO_PRIORITY_NOW) | |
848 | return; | |
849 | ||
a8b2e306 TC |
850 | ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE); |
851 | ASSERT3U(priority, <, ZIO_PRIORITY_NUM_QUEUEABLE); | |
852 | ||
853 | if (zio->io_type == ZIO_TYPE_READ) { | |
854 | if (priority != ZIO_PRIORITY_SYNC_READ && | |
855 | priority != ZIO_PRIORITY_ASYNC_READ && | |
856 | priority != ZIO_PRIORITY_SCRUB) | |
857 | priority = ZIO_PRIORITY_ASYNC_READ; | |
858 | } else { | |
859 | ASSERT(zio->io_type == ZIO_TYPE_WRITE); | |
860 | if (priority != ZIO_PRIORITY_SYNC_WRITE && | |
861 | priority != ZIO_PRIORITY_ASYNC_WRITE) | |
862 | priority = ZIO_PRIORITY_ASYNC_WRITE; | |
863 | } | |
864 | ||
865 | mutex_enter(&vq->vq_lock); | |
866 | ||
867 | /* | |
868 | * If the zio is in none of the queues we can simply change | |
869 | * the priority. If the zio is waiting to be submitted we must | |
870 | * remove it from the queue and re-insert it with the new priority. | |
871 | * Otherwise, the zio is currently active and we cannot change its | |
872 | * priority. | |
873 | */ | |
874 | tree = vdev_queue_class_tree(vq, zio->io_priority); | |
875 | if (avl_find(tree, zio, NULL) == zio) { | |
876 | avl_remove(vdev_queue_class_tree(vq, zio->io_priority), zio); | |
877 | zio->io_priority = priority; | |
878 | avl_add(vdev_queue_class_tree(vq, zio->io_priority), zio); | |
879 | } else if (avl_find(&vq->vq_active_tree, zio, NULL) != zio) { | |
880 | zio->io_priority = priority; | |
881 | } | |
882 | ||
883 | mutex_exit(&vq->vq_lock); | |
884 | } | |
885 | ||
9f500936 | 886 | /* |
d6c6590c | 887 | * As these two methods are only used for load calculations we're not |
9f500936 | 888 | * concerned if we get an incorrect value on 32bit platforms due to lack of |
889 | * vq_lock mutex use here, instead we prefer to keep it lock free for | |
890 | * performance. | |
891 | */ | |
892 | int | |
893 | vdev_queue_length(vdev_t *vd) | |
894 | { | |
895 | return (avl_numnodes(&vd->vdev_queue.vq_active_tree)); | |
896 | } | |
897 | ||
898 | uint64_t | |
d6c6590c | 899 | vdev_queue_last_offset(vdev_t *vd) |
9f500936 | 900 | { |
d6c6590c | 901 | return (vd->vdev_queue.vq_last_offset); |
9f500936 | 902 | } |
903 | ||
93ce2b4c | 904 | #if defined(_KERNEL) |
c28b2279 | 905 | module_param(zfs_vdev_aggregation_limit, int, 0644); |
c409e464 BB |
906 | MODULE_PARM_DESC(zfs_vdev_aggregation_limit, "Max vdev I/O aggregation size"); |
907 | ||
c409e464 BB |
908 | module_param(zfs_vdev_read_gap_limit, int, 0644); |
909 | MODULE_PARM_DESC(zfs_vdev_read_gap_limit, "Aggregate read I/O over gap"); | |
910 | ||
911 | module_param(zfs_vdev_write_gap_limit, int, 0644); | |
912 | MODULE_PARM_DESC(zfs_vdev_write_gap_limit, "Aggregate write I/O over gap"); | |
e8b96c60 MA |
913 | |
914 | module_param(zfs_vdev_max_active, int, 0644); | |
915 | MODULE_PARM_DESC(zfs_vdev_max_active, "Maximum number of active I/Os per vdev"); | |
916 | ||
917 | module_param(zfs_vdev_async_write_active_max_dirty_percent, int, 0644); | |
918 | MODULE_PARM_DESC(zfs_vdev_async_write_active_max_dirty_percent, | |
d1d7e268 | 919 | "Async write concurrency max threshold"); |
e8b96c60 MA |
920 | |
921 | module_param(zfs_vdev_async_write_active_min_dirty_percent, int, 0644); | |
922 | MODULE_PARM_DESC(zfs_vdev_async_write_active_min_dirty_percent, | |
d1d7e268 | 923 | "Async write concurrency min threshold"); |
e8b96c60 MA |
924 | |
925 | module_param(zfs_vdev_async_read_max_active, int, 0644); | |
926 | MODULE_PARM_DESC(zfs_vdev_async_read_max_active, | |
d1d7e268 | 927 | "Max active async read I/Os per vdev"); |
e8b96c60 MA |
928 | |
929 | module_param(zfs_vdev_async_read_min_active, int, 0644); | |
930 | MODULE_PARM_DESC(zfs_vdev_async_read_min_active, | |
d1d7e268 | 931 | "Min active async read I/Os per vdev"); |
e8b96c60 MA |
932 | |
933 | module_param(zfs_vdev_async_write_max_active, int, 0644); | |
934 | MODULE_PARM_DESC(zfs_vdev_async_write_max_active, | |
d1d7e268 | 935 | "Max active async write I/Os per vdev"); |
e8b96c60 MA |
936 | |
937 | module_param(zfs_vdev_async_write_min_active, int, 0644); | |
938 | MODULE_PARM_DESC(zfs_vdev_async_write_min_active, | |
d1d7e268 | 939 | "Min active async write I/Os per vdev"); |
e8b96c60 MA |
940 | |
941 | module_param(zfs_vdev_scrub_max_active, int, 0644); | |
942 | MODULE_PARM_DESC(zfs_vdev_scrub_max_active, "Max active scrub I/Os per vdev"); | |
943 | ||
944 | module_param(zfs_vdev_scrub_min_active, int, 0644); | |
945 | MODULE_PARM_DESC(zfs_vdev_scrub_min_active, "Min active scrub I/Os per vdev"); | |
946 | ||
947 | module_param(zfs_vdev_sync_read_max_active, int, 0644); | |
948 | MODULE_PARM_DESC(zfs_vdev_sync_read_max_active, | |
d1d7e268 | 949 | "Max active sync read I/Os per vdev"); |
e8b96c60 MA |
950 | |
951 | module_param(zfs_vdev_sync_read_min_active, int, 0644); | |
952 | MODULE_PARM_DESC(zfs_vdev_sync_read_min_active, | |
d1d7e268 | 953 | "Min active sync read I/Os per vdev"); |
e8b96c60 MA |
954 | |
955 | module_param(zfs_vdev_sync_write_max_active, int, 0644); | |
956 | MODULE_PARM_DESC(zfs_vdev_sync_write_max_active, | |
d1d7e268 | 957 | "Max active sync write I/Os per vdev"); |
e8b96c60 MA |
958 | |
959 | module_param(zfs_vdev_sync_write_min_active, int, 0644); | |
960 | MODULE_PARM_DESC(zfs_vdev_sync_write_min_active, | |
3757bff3 | 961 | "Min active sync write I/Os per vdev"); |
3dfb57a3 DB |
962 | |
963 | module_param(zfs_vdev_queue_depth_pct, int, 0644); | |
964 | MODULE_PARM_DESC(zfs_vdev_queue_depth_pct, | |
965 | "Queue depth percentage for each top-level vdev"); | |
c28b2279 | 966 | #endif |