]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/openzfs/module/zfs/vdev_queue.c
Import device-tree files from Linux 6.4
[FreeBSD/FreeBSD.git] / sys / contrib / openzfs / module / zfs / vdev_queue.c
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 https://opensource.org/licenses/CDDL-1.0.
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 /*
27  * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
28  */
29
30 #include <sys/zfs_context.h>
31 #include <sys/vdev_impl.h>
32 #include <sys/spa_impl.h>
33 #include <sys/zio.h>
34 #include <sys/avl.h>
35 #include <sys/dsl_pool.h>
36 #include <sys/metaslab_impl.h>
37 #include <sys/spa.h>
38 #include <sys/abd.h>
39
40 /*
41  * ZFS I/O Scheduler
42  * ---------------
43  *
44  * ZFS issues I/O operations to leaf vdevs to satisfy and complete zios.  The
45  * I/O scheduler determines when and in what order those operations are
46  * issued.  The I/O scheduler divides operations into five I/O classes
47  * prioritized in the following order: sync read, sync write, async read,
48  * async write, and scrub/resilver.  Each queue defines the minimum and
49  * maximum number of concurrent operations that may be issued to the device.
50  * In addition, the device has an aggregate maximum. Note that the sum of the
51  * per-queue minimums must not exceed the aggregate maximum. If the
52  * sum of the per-queue maximums exceeds the aggregate maximum, then the
53  * number of active i/os may reach zfs_vdev_max_active, in which case no
54  * further i/os will be issued regardless of whether all per-queue
55  * minimums have been met.
56  *
57  * For many physical devices, throughput increases with the number of
58  * concurrent operations, but latency typically suffers. Further, physical
59  * devices typically have a limit at which more concurrent operations have no
60  * effect on throughput or can actually cause it to decrease.
61  *
62  * The scheduler selects the next operation to issue by first looking for an
63  * I/O class whose minimum has not been satisfied. Once all are satisfied and
64  * the aggregate maximum has not been hit, the scheduler looks for classes
65  * whose maximum has not been satisfied. Iteration through the I/O classes is
66  * done in the order specified above. No further operations are issued if the
67  * aggregate maximum number of concurrent operations has been hit or if there
68  * are no operations queued for an I/O class that has not hit its maximum.
69  * Every time an i/o is queued or an operation completes, the I/O scheduler
70  * looks for new operations to issue.
71  *
72  * All I/O classes have a fixed maximum number of outstanding operations
73  * except for the async write class. Asynchronous writes represent the data
74  * that is committed to stable storage during the syncing stage for
75  * transaction groups (see txg.c). Transaction groups enter the syncing state
76  * periodically so the number of queued async writes will quickly burst up and
77  * then bleed down to zero. Rather than servicing them as quickly as possible,
78  * the I/O scheduler changes the maximum number of active async write i/os
79  * according to the amount of dirty data in the pool (see dsl_pool.c). Since
80  * both throughput and latency typically increase with the number of
81  * concurrent operations issued to physical devices, reducing the burstiness
82  * in the number of concurrent operations also stabilizes the response time of
83  * operations from other -- and in particular synchronous -- queues. In broad
84  * strokes, the I/O scheduler will issue more concurrent operations from the
85  * async write queue as there's more dirty data in the pool.
86  *
87  * Async Writes
88  *
89  * The number of concurrent operations issued for the async write I/O class
90  * follows a piece-wise linear function defined by a few adjustable points.
91  *
92  *        |                   o---------| <-- zfs_vdev_async_write_max_active
93  *   ^    |                  /^         |
94  *   |    |                 / |         |
95  * active |                /  |         |
96  *  I/O   |               /   |         |
97  * count  |              /    |         |
98  *        |             /     |         |
99  *        |------------o      |         | <-- zfs_vdev_async_write_min_active
100  *       0|____________^______|_________|
101  *        0%           |      |       100% of zfs_dirty_data_max
102  *                     |      |
103  *                     |      `-- zfs_vdev_async_write_active_max_dirty_percent
104  *                     `--------- zfs_vdev_async_write_active_min_dirty_percent
105  *
106  * Until the amount of dirty data exceeds a minimum percentage of the dirty
107  * data allowed in the pool, the I/O scheduler will limit the number of
108  * concurrent operations to the minimum. As that threshold is crossed, the
109  * number of concurrent operations issued increases linearly to the maximum at
110  * the specified maximum percentage of the dirty data allowed in the pool.
111  *
112  * Ideally, the amount of dirty data on a busy pool will stay in the sloped
113  * part of the function between zfs_vdev_async_write_active_min_dirty_percent
114  * and zfs_vdev_async_write_active_max_dirty_percent. If it exceeds the
115  * maximum percentage, this indicates that the rate of incoming data is
116  * greater than the rate that the backend storage can handle. In this case, we
117  * must further throttle incoming writes (see dmu_tx_delay() for details).
118  */
119
120 /*
121  * The maximum number of i/os active to each device.  Ideally, this will be >=
122  * the sum of each queue's max_active.
123  */
124 uint_t zfs_vdev_max_active = 1000;
125
126 /*
127  * Per-queue limits on the number of i/os active to each device.  If the
128  * number of active i/os is < zfs_vdev_max_active, then the min_active comes
129  * into play.  We will send min_active from each queue round-robin, and then
130  * send from queues in the order defined by zio_priority_t up to max_active.
131  * Some queues have additional mechanisms to limit number of active I/Os in
132  * addition to min_active and max_active, see below.
133  *
134  * In general, smaller max_active's will lead to lower latency of synchronous
135  * operations.  Larger max_active's may lead to higher overall throughput,
136  * depending on underlying storage.
137  *
138  * The ratio of the queues' max_actives determines the balance of performance
139  * between reads, writes, and scrubs.  E.g., increasing
140  * zfs_vdev_scrub_max_active will cause the scrub or resilver to complete
141  * more quickly, but reads and writes to have higher latency and lower
142  * throughput.
143  */
144 static uint_t zfs_vdev_sync_read_min_active = 10;
145 static uint_t zfs_vdev_sync_read_max_active = 10;
146 static uint_t zfs_vdev_sync_write_min_active = 10;
147 static uint_t zfs_vdev_sync_write_max_active = 10;
148 static uint_t zfs_vdev_async_read_min_active = 1;
149 /*  */ uint_t zfs_vdev_async_read_max_active = 3;
150 static uint_t zfs_vdev_async_write_min_active = 2;
151 /*  */ uint_t zfs_vdev_async_write_max_active = 10;
152 static uint_t zfs_vdev_scrub_min_active = 1;
153 static uint_t zfs_vdev_scrub_max_active = 3;
154 static uint_t zfs_vdev_removal_min_active = 1;
155 static uint_t zfs_vdev_removal_max_active = 2;
156 static uint_t zfs_vdev_initializing_min_active = 1;
157 static uint_t zfs_vdev_initializing_max_active = 1;
158 static uint_t zfs_vdev_trim_min_active = 1;
159 static uint_t zfs_vdev_trim_max_active = 2;
160 static uint_t zfs_vdev_rebuild_min_active = 1;
161 static uint_t zfs_vdev_rebuild_max_active = 3;
162
163 /*
164  * When the pool has less than zfs_vdev_async_write_active_min_dirty_percent
165  * dirty data, use zfs_vdev_async_write_min_active.  When it has more than
166  * zfs_vdev_async_write_active_max_dirty_percent, use
167  * zfs_vdev_async_write_max_active. The value is linearly interpolated
168  * between min and max.
169  */
170 uint_t zfs_vdev_async_write_active_min_dirty_percent = 30;
171 uint_t zfs_vdev_async_write_active_max_dirty_percent = 60;
172
173 /*
174  * For non-interactive I/O (scrub, resilver, removal, initialize and rebuild),
175  * the number of concurrently-active I/O's is limited to *_min_active, unless
176  * the vdev is "idle".  When there are no interactive I/Os active (sync or
177  * async), and zfs_vdev_nia_delay I/Os have completed since the last
178  * interactive I/O, then the vdev is considered to be "idle", and the number
179  * of concurrently-active non-interactive I/O's is increased to *_max_active.
180  */
181 static uint_t zfs_vdev_nia_delay = 5;
182
183 /*
184  * Some HDDs tend to prioritize sequential I/O so high that concurrent
185  * random I/O latency reaches several seconds.  On some HDDs it happens
186  * even if sequential I/Os are submitted one at a time, and so setting
187  * *_max_active to 1 does not help.  To prevent non-interactive I/Os, like
188  * scrub, from monopolizing the device no more than zfs_vdev_nia_credit
189  * I/Os can be sent while there are outstanding incomplete interactive
190  * I/Os.  This enforced wait ensures the HDD services the interactive I/O
191  * within a reasonable amount of time.
192  */
193 static uint_t zfs_vdev_nia_credit = 5;
194
195 /*
196  * To reduce IOPs, we aggregate small adjacent I/Os into one large I/O.
197  * For read I/Os, we also aggregate across small adjacency gaps; for writes
198  * we include spans of optional I/Os to aid aggregation at the disk even when
199  * they aren't able to help us aggregate at this level.
200  */
201 static uint_t zfs_vdev_aggregation_limit = 1 << 20;
202 static uint_t zfs_vdev_aggregation_limit_non_rotating = SPA_OLD_MAXBLOCKSIZE;
203 static uint_t zfs_vdev_read_gap_limit = 32 << 10;
204 static uint_t zfs_vdev_write_gap_limit = 4 << 10;
205
206 /*
207  * Define the queue depth percentage for each top-level. This percentage is
208  * used in conjunction with zfs_vdev_async_max_active to determine how many
209  * allocations a specific top-level vdev should handle. Once the queue depth
210  * reaches zfs_vdev_queue_depth_pct * zfs_vdev_async_write_max_active / 100
211  * then allocator will stop allocating blocks on that top-level device.
212  * The default kernel setting is 1000% which will yield 100 allocations per
213  * device. For userland testing, the default setting is 300% which equates
214  * to 30 allocations per device.
215  */
216 #ifdef _KERNEL
217 uint_t zfs_vdev_queue_depth_pct = 1000;
218 #else
219 uint_t zfs_vdev_queue_depth_pct = 300;
220 #endif
221
222 /*
223  * When performing allocations for a given metaslab, we want to make sure that
224  * there are enough IOs to aggregate together to improve throughput. We want to
225  * ensure that there are at least 128k worth of IOs that can be aggregated, and
226  * we assume that the average allocation size is 4k, so we need the queue depth
227  * to be 32 per allocator to get good aggregation of sequential writes.
228  */
229 uint_t zfs_vdev_def_queue_depth = 32;
230
231 static int
232 vdev_queue_offset_compare(const void *x1, const void *x2)
233 {
234         const zio_t *z1 = (const zio_t *)x1;
235         const zio_t *z2 = (const zio_t *)x2;
236
237         int cmp = TREE_CMP(z1->io_offset, z2->io_offset);
238
239         if (likely(cmp))
240                 return (cmp);
241
242         return (TREE_PCMP(z1, z2));
243 }
244
245 #define VDQ_T_SHIFT 29
246
247 static int
248 vdev_queue_to_compare(const void *x1, const void *x2)
249 {
250         const zio_t *z1 = (const zio_t *)x1;
251         const zio_t *z2 = (const zio_t *)x2;
252
253         int tcmp = TREE_CMP(z1->io_timestamp >> VDQ_T_SHIFT,
254             z2->io_timestamp >> VDQ_T_SHIFT);
255         int ocmp = TREE_CMP(z1->io_offset, z2->io_offset);
256         int cmp = tcmp ? tcmp : ocmp;
257
258         if (likely(cmp | (z1->io_queue_state == ZIO_QS_NONE)))
259                 return (cmp);
260
261         return (TREE_PCMP(z1, z2));
262 }
263
264 static inline boolean_t
265 vdev_queue_class_fifo(zio_priority_t p)
266 {
267         return (p == ZIO_PRIORITY_SYNC_READ || p == ZIO_PRIORITY_SYNC_WRITE ||
268             p == ZIO_PRIORITY_TRIM);
269 }
270
271 static void
272 vdev_queue_class_add(vdev_queue_t *vq, zio_t *zio)
273 {
274         zio_priority_t p = zio->io_priority;
275         vq->vq_cqueued |= 1U << p;
276         if (vdev_queue_class_fifo(p))
277                 list_insert_tail(&vq->vq_class[p].vqc_list, zio);
278         else
279                 avl_add(&vq->vq_class[p].vqc_tree, zio);
280 }
281
282 static void
283 vdev_queue_class_remove(vdev_queue_t *vq, zio_t *zio)
284 {
285         zio_priority_t p = zio->io_priority;
286         uint32_t empty;
287         if (vdev_queue_class_fifo(p)) {
288                 list_t *list = &vq->vq_class[p].vqc_list;
289                 list_remove(list, zio);
290                 empty = list_is_empty(list);
291         } else {
292                 avl_tree_t *tree = &vq->vq_class[p].vqc_tree;
293                 avl_remove(tree, zio);
294                 empty = avl_is_empty(tree);
295         }
296         vq->vq_cqueued &= ~(empty << p);
297 }
298
299 static uint_t
300 vdev_queue_class_min_active(vdev_queue_t *vq, zio_priority_t p)
301 {
302         switch (p) {
303         case ZIO_PRIORITY_SYNC_READ:
304                 return (zfs_vdev_sync_read_min_active);
305         case ZIO_PRIORITY_SYNC_WRITE:
306                 return (zfs_vdev_sync_write_min_active);
307         case ZIO_PRIORITY_ASYNC_READ:
308                 return (zfs_vdev_async_read_min_active);
309         case ZIO_PRIORITY_ASYNC_WRITE:
310                 return (zfs_vdev_async_write_min_active);
311         case ZIO_PRIORITY_SCRUB:
312                 return (vq->vq_ia_active == 0 ? zfs_vdev_scrub_min_active :
313                     MIN(vq->vq_nia_credit, zfs_vdev_scrub_min_active));
314         case ZIO_PRIORITY_REMOVAL:
315                 return (vq->vq_ia_active == 0 ? zfs_vdev_removal_min_active :
316                     MIN(vq->vq_nia_credit, zfs_vdev_removal_min_active));
317         case ZIO_PRIORITY_INITIALIZING:
318                 return (vq->vq_ia_active == 0 ?zfs_vdev_initializing_min_active:
319                     MIN(vq->vq_nia_credit, zfs_vdev_initializing_min_active));
320         case ZIO_PRIORITY_TRIM:
321                 return (zfs_vdev_trim_min_active);
322         case ZIO_PRIORITY_REBUILD:
323                 return (vq->vq_ia_active == 0 ? zfs_vdev_rebuild_min_active :
324                     MIN(vq->vq_nia_credit, zfs_vdev_rebuild_min_active));
325         default:
326                 panic("invalid priority %u", p);
327                 return (0);
328         }
329 }
330
331 static uint_t
332 vdev_queue_max_async_writes(spa_t *spa)
333 {
334         uint_t writes;
335         uint64_t dirty = 0;
336         dsl_pool_t *dp = spa_get_dsl(spa);
337         uint64_t min_bytes = zfs_dirty_data_max *
338             zfs_vdev_async_write_active_min_dirty_percent / 100;
339         uint64_t max_bytes = zfs_dirty_data_max *
340             zfs_vdev_async_write_active_max_dirty_percent / 100;
341
342         /*
343          * Async writes may occur before the assignment of the spa's
344          * dsl_pool_t if a self-healing zio is issued prior to the
345          * completion of dmu_objset_open_impl().
346          */
347         if (dp == NULL)
348                 return (zfs_vdev_async_write_max_active);
349
350         /*
351          * Sync tasks correspond to interactive user actions. To reduce the
352          * execution time of those actions we push data out as fast as possible.
353          */
354         dirty = dp->dp_dirty_total;
355         if (dirty > max_bytes || spa_has_pending_synctask(spa))
356                 return (zfs_vdev_async_write_max_active);
357
358         if (dirty < min_bytes)
359                 return (zfs_vdev_async_write_min_active);
360
361         /*
362          * linear interpolation:
363          * slope = (max_writes - min_writes) / (max_bytes - min_bytes)
364          * move right by min_bytes
365          * move up by min_writes
366          */
367         writes = (dirty - min_bytes) *
368             (zfs_vdev_async_write_max_active -
369             zfs_vdev_async_write_min_active) /
370             (max_bytes - min_bytes) +
371             zfs_vdev_async_write_min_active;
372         ASSERT3U(writes, >=, zfs_vdev_async_write_min_active);
373         ASSERT3U(writes, <=, zfs_vdev_async_write_max_active);
374         return (writes);
375 }
376
377 static uint_t
378 vdev_queue_class_max_active(vdev_queue_t *vq, zio_priority_t p)
379 {
380         switch (p) {
381         case ZIO_PRIORITY_SYNC_READ:
382                 return (zfs_vdev_sync_read_max_active);
383         case ZIO_PRIORITY_SYNC_WRITE:
384                 return (zfs_vdev_sync_write_max_active);
385         case ZIO_PRIORITY_ASYNC_READ:
386                 return (zfs_vdev_async_read_max_active);
387         case ZIO_PRIORITY_ASYNC_WRITE:
388                 return (vdev_queue_max_async_writes(vq->vq_vdev->vdev_spa));
389         case ZIO_PRIORITY_SCRUB:
390                 if (vq->vq_ia_active > 0) {
391                         return (MIN(vq->vq_nia_credit,
392                             zfs_vdev_scrub_min_active));
393                 } else if (vq->vq_nia_credit < zfs_vdev_nia_delay)
394                         return (MAX(1, zfs_vdev_scrub_min_active));
395                 return (zfs_vdev_scrub_max_active);
396         case ZIO_PRIORITY_REMOVAL:
397                 if (vq->vq_ia_active > 0) {
398                         return (MIN(vq->vq_nia_credit,
399                             zfs_vdev_removal_min_active));
400                 } else if (vq->vq_nia_credit < zfs_vdev_nia_delay)
401                         return (MAX(1, zfs_vdev_removal_min_active));
402                 return (zfs_vdev_removal_max_active);
403         case ZIO_PRIORITY_INITIALIZING:
404                 if (vq->vq_ia_active > 0) {
405                         return (MIN(vq->vq_nia_credit,
406                             zfs_vdev_initializing_min_active));
407                 } else if (vq->vq_nia_credit < zfs_vdev_nia_delay)
408                         return (MAX(1, zfs_vdev_initializing_min_active));
409                 return (zfs_vdev_initializing_max_active);
410         case ZIO_PRIORITY_TRIM:
411                 return (zfs_vdev_trim_max_active);
412         case ZIO_PRIORITY_REBUILD:
413                 if (vq->vq_ia_active > 0) {
414                         return (MIN(vq->vq_nia_credit,
415                             zfs_vdev_rebuild_min_active));
416                 } else if (vq->vq_nia_credit < zfs_vdev_nia_delay)
417                         return (MAX(1, zfs_vdev_rebuild_min_active));
418                 return (zfs_vdev_rebuild_max_active);
419         default:
420                 panic("invalid priority %u", p);
421                 return (0);
422         }
423 }
424
425 /*
426  * Return the i/o class to issue from, or ZIO_PRIORITY_NUM_QUEUEABLE if
427  * there is no eligible class.
428  */
429 static zio_priority_t
430 vdev_queue_class_to_issue(vdev_queue_t *vq)
431 {
432         uint32_t cq = vq->vq_cqueued;
433         zio_priority_t p, p1;
434
435         if (cq == 0 || vq->vq_active >= zfs_vdev_max_active)
436                 return (ZIO_PRIORITY_NUM_QUEUEABLE);
437
438         /*
439          * Find a queue that has not reached its minimum # outstanding i/os.
440          * Do round-robin to reduce starvation due to zfs_vdev_max_active
441          * and vq_nia_credit limits.
442          */
443         p1 = vq->vq_last_prio + 1;
444         if (p1 >= ZIO_PRIORITY_NUM_QUEUEABLE)
445                 p1 = 0;
446         for (p = p1; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) {
447                 if ((cq & (1U << p)) != 0 && vq->vq_cactive[p] <
448                     vdev_queue_class_min_active(vq, p))
449                         goto found;
450         }
451         for (p = 0; p < p1; p++) {
452                 if ((cq & (1U << p)) != 0 && vq->vq_cactive[p] <
453                     vdev_queue_class_min_active(vq, p))
454                         goto found;
455         }
456
457         /*
458          * If we haven't found a queue, look for one that hasn't reached its
459          * maximum # outstanding i/os.
460          */
461         for (p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) {
462                 if ((cq & (1U << p)) != 0 && vq->vq_cactive[p] <
463                     vdev_queue_class_max_active(vq, p))
464                         break;
465         }
466
467 found:
468         vq->vq_last_prio = p;
469         return (p);
470 }
471
472 void
473 vdev_queue_init(vdev_t *vd)
474 {
475         vdev_queue_t *vq = &vd->vdev_queue;
476         zio_priority_t p;
477
478         vq->vq_vdev = vd;
479
480         for (p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) {
481                 if (vdev_queue_class_fifo(p)) {
482                         list_create(&vq->vq_class[p].vqc_list,
483                             sizeof (zio_t),
484                             offsetof(struct zio, io_queue_node.l));
485                 } else {
486                         avl_create(&vq->vq_class[p].vqc_tree,
487                             vdev_queue_to_compare, sizeof (zio_t),
488                             offsetof(struct zio, io_queue_node.a));
489                 }
490         }
491         avl_create(&vq->vq_read_offset_tree,
492             vdev_queue_offset_compare, sizeof (zio_t),
493             offsetof(struct zio, io_offset_node));
494         avl_create(&vq->vq_write_offset_tree,
495             vdev_queue_offset_compare, sizeof (zio_t),
496             offsetof(struct zio, io_offset_node));
497
498         vq->vq_last_offset = 0;
499         list_create(&vq->vq_active_list, sizeof (struct zio),
500             offsetof(struct zio, io_queue_node.l));
501         mutex_init(&vq->vq_lock, NULL, MUTEX_DEFAULT, NULL);
502 }
503
504 void
505 vdev_queue_fini(vdev_t *vd)
506 {
507         vdev_queue_t *vq = &vd->vdev_queue;
508
509         for (zio_priority_t p = 0; p < ZIO_PRIORITY_NUM_QUEUEABLE; p++) {
510                 if (vdev_queue_class_fifo(p))
511                         list_destroy(&vq->vq_class[p].vqc_list);
512                 else
513                         avl_destroy(&vq->vq_class[p].vqc_tree);
514         }
515         avl_destroy(&vq->vq_read_offset_tree);
516         avl_destroy(&vq->vq_write_offset_tree);
517
518         list_destroy(&vq->vq_active_list);
519         mutex_destroy(&vq->vq_lock);
520 }
521
522 static void
523 vdev_queue_io_add(vdev_queue_t *vq, zio_t *zio)
524 {
525         zio->io_queue_state = ZIO_QS_QUEUED;
526         vdev_queue_class_add(vq, zio);
527         if (zio->io_type == ZIO_TYPE_READ)
528                 avl_add(&vq->vq_read_offset_tree, zio);
529         else if (zio->io_type == ZIO_TYPE_WRITE)
530                 avl_add(&vq->vq_write_offset_tree, zio);
531 }
532
533 static void
534 vdev_queue_io_remove(vdev_queue_t *vq, zio_t *zio)
535 {
536         vdev_queue_class_remove(vq, zio);
537         if (zio->io_type == ZIO_TYPE_READ)
538                 avl_remove(&vq->vq_read_offset_tree, zio);
539         else if (zio->io_type == ZIO_TYPE_WRITE)
540                 avl_remove(&vq->vq_write_offset_tree, zio);
541         zio->io_queue_state = ZIO_QS_NONE;
542 }
543
544 static boolean_t
545 vdev_queue_is_interactive(zio_priority_t p)
546 {
547         switch (p) {
548         case ZIO_PRIORITY_SCRUB:
549         case ZIO_PRIORITY_REMOVAL:
550         case ZIO_PRIORITY_INITIALIZING:
551         case ZIO_PRIORITY_REBUILD:
552                 return (B_FALSE);
553         default:
554                 return (B_TRUE);
555         }
556 }
557
558 static void
559 vdev_queue_pending_add(vdev_queue_t *vq, zio_t *zio)
560 {
561         ASSERT(MUTEX_HELD(&vq->vq_lock));
562         ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE);
563         vq->vq_cactive[zio->io_priority]++;
564         vq->vq_active++;
565         if (vdev_queue_is_interactive(zio->io_priority)) {
566                 if (++vq->vq_ia_active == 1)
567                         vq->vq_nia_credit = 1;
568         } else if (vq->vq_ia_active > 0) {
569                 vq->vq_nia_credit--;
570         }
571         zio->io_queue_state = ZIO_QS_ACTIVE;
572         list_insert_tail(&vq->vq_active_list, zio);
573 }
574
575 static void
576 vdev_queue_pending_remove(vdev_queue_t *vq, zio_t *zio)
577 {
578         ASSERT(MUTEX_HELD(&vq->vq_lock));
579         ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE);
580         vq->vq_cactive[zio->io_priority]--;
581         vq->vq_active--;
582         if (vdev_queue_is_interactive(zio->io_priority)) {
583                 if (--vq->vq_ia_active == 0)
584                         vq->vq_nia_credit = 0;
585                 else
586                         vq->vq_nia_credit = zfs_vdev_nia_credit;
587         } else if (vq->vq_ia_active == 0)
588                 vq->vq_nia_credit++;
589         list_remove(&vq->vq_active_list, zio);
590         zio->io_queue_state = ZIO_QS_NONE;
591 }
592
593 static void
594 vdev_queue_agg_io_done(zio_t *aio)
595 {
596         abd_free(aio->io_abd);
597 }
598
599 /*
600  * Compute the range spanned by two i/os, which is the endpoint of the last
601  * (lio->io_offset + lio->io_size) minus start of the first (fio->io_offset).
602  * Conveniently, the gap between fio and lio is given by -IO_SPAN(lio, fio);
603  * thus fio and lio are adjacent if and only if IO_SPAN(lio, fio) == 0.
604  */
605 #define IO_SPAN(fio, lio) ((lio)->io_offset + (lio)->io_size - (fio)->io_offset)
606 #define IO_GAP(fio, lio) (-IO_SPAN(lio, fio))
607
608 /*
609  * Sufficiently adjacent io_offset's in ZIOs will be aggregated. We do this
610  * by creating a gang ABD from the adjacent ZIOs io_abd's. By using
611  * a gang ABD we avoid doing memory copies to and from the parent,
612  * child ZIOs. The gang ABD also accounts for gaps between adjacent
613  * io_offsets by simply getting the zero ABD for writes or allocating
614  * a new ABD for reads and placing them in the gang ABD as well.
615  */
616 static zio_t *
617 vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio)
618 {
619         zio_t *first, *last, *aio, *dio, *mandatory, *nio;
620         uint64_t maxgap = 0;
621         uint64_t size;
622         uint64_t limit;
623         boolean_t stretch = B_FALSE;
624         uint64_t next_offset;
625         abd_t *abd;
626         avl_tree_t *t;
627
628         /*
629          * TRIM aggregation should not be needed since code in zfs_trim.c can
630          * submit TRIM I/O for extents up to zfs_trim_extent_bytes_max (128M).
631          */
632         if (zio->io_type == ZIO_TYPE_TRIM)
633                 return (NULL);
634
635         if (zio->io_flags & ZIO_FLAG_DONT_AGGREGATE)
636                 return (NULL);
637
638         if (vq->vq_vdev->vdev_nonrot)
639                 limit = zfs_vdev_aggregation_limit_non_rotating;
640         else
641                 limit = zfs_vdev_aggregation_limit;
642         if (limit == 0)
643                 return (NULL);
644         limit = MIN(limit, SPA_MAXBLOCKSIZE);
645
646         /*
647          * I/Os to distributed spares are directly dispatched to the dRAID
648          * leaf vdevs for aggregation.  See the comment at the end of the
649          * zio_vdev_io_start() function.
650          */
651         ASSERT(vq->vq_vdev->vdev_ops != &vdev_draid_spare_ops);
652
653         first = last = zio;
654
655         if (zio->io_type == ZIO_TYPE_READ) {
656                 maxgap = zfs_vdev_read_gap_limit;
657                 t = &vq->vq_read_offset_tree;
658         } else {
659                 ASSERT3U(zio->io_type, ==, ZIO_TYPE_WRITE);
660                 t = &vq->vq_write_offset_tree;
661         }
662
663         /*
664          * We can aggregate I/Os that are sufficiently adjacent and of
665          * the same flavor, as expressed by the AGG_INHERIT flags.
666          * The latter requirement is necessary so that certain
667          * attributes of the I/O, such as whether it's a normal I/O
668          * or a scrub/resilver, can be preserved in the aggregate.
669          * We can include optional I/Os, but don't allow them
670          * to begin a range as they add no benefit in that situation.
671          */
672
673         /*
674          * We keep track of the last non-optional I/O.
675          */
676         mandatory = (first->io_flags & ZIO_FLAG_OPTIONAL) ? NULL : first;
677
678         /*
679          * Walk backwards through sufficiently contiguous I/Os
680          * recording the last non-optional I/O.
681          */
682         zio_flag_t flags = zio->io_flags & ZIO_FLAG_AGG_INHERIT;
683         while ((dio = AVL_PREV(t, first)) != NULL &&
684             (dio->io_flags & ZIO_FLAG_AGG_INHERIT) == flags &&
685             IO_SPAN(dio, last) <= limit &&
686             IO_GAP(dio, first) <= maxgap &&
687             dio->io_type == zio->io_type) {
688                 first = dio;
689                 if (mandatory == NULL && !(first->io_flags & ZIO_FLAG_OPTIONAL))
690                         mandatory = first;
691         }
692
693         /*
694          * Skip any initial optional I/Os.
695          */
696         while ((first->io_flags & ZIO_FLAG_OPTIONAL) && first != last) {
697                 first = AVL_NEXT(t, first);
698                 ASSERT(first != NULL);
699         }
700
701
702         /*
703          * Walk forward through sufficiently contiguous I/Os.
704          * The aggregation limit does not apply to optional i/os, so that
705          * we can issue contiguous writes even if they are larger than the
706          * aggregation limit.
707          */
708         while ((dio = AVL_NEXT(t, last)) != NULL &&
709             (dio->io_flags & ZIO_FLAG_AGG_INHERIT) == flags &&
710             (IO_SPAN(first, dio) <= limit ||
711             (dio->io_flags & ZIO_FLAG_OPTIONAL)) &&
712             IO_SPAN(first, dio) <= SPA_MAXBLOCKSIZE &&
713             IO_GAP(last, dio) <= maxgap &&
714             dio->io_type == zio->io_type) {
715                 last = dio;
716                 if (!(last->io_flags & ZIO_FLAG_OPTIONAL))
717                         mandatory = last;
718         }
719
720         /*
721          * Now that we've established the range of the I/O aggregation
722          * we must decide what to do with trailing optional I/Os.
723          * For reads, there's nothing to do. While we are unable to
724          * aggregate further, it's possible that a trailing optional
725          * I/O would allow the underlying device to aggregate with
726          * subsequent I/Os. We must therefore determine if the next
727          * non-optional I/O is close enough to make aggregation
728          * worthwhile.
729          */
730         if (zio->io_type == ZIO_TYPE_WRITE && mandatory != NULL) {
731                 zio_t *nio = last;
732                 while ((dio = AVL_NEXT(t, nio)) != NULL &&
733                     IO_GAP(nio, dio) == 0 &&
734                     IO_GAP(mandatory, dio) <= zfs_vdev_write_gap_limit) {
735                         nio = dio;
736                         if (!(nio->io_flags & ZIO_FLAG_OPTIONAL)) {
737                                 stretch = B_TRUE;
738                                 break;
739                         }
740                 }
741         }
742
743         if (stretch) {
744                 /*
745                  * We are going to include an optional io in our aggregated
746                  * span, thus closing the write gap.  Only mandatory i/os can
747                  * start aggregated spans, so make sure that the next i/o
748                  * after our span is mandatory.
749                  */
750                 dio = AVL_NEXT(t, last);
751                 ASSERT3P(dio, !=, NULL);
752                 dio->io_flags &= ~ZIO_FLAG_OPTIONAL;
753         } else {
754                 /* do not include the optional i/o */
755                 while (last != mandatory && last != first) {
756                         ASSERT(last->io_flags & ZIO_FLAG_OPTIONAL);
757                         last = AVL_PREV(t, last);
758                         ASSERT(last != NULL);
759                 }
760         }
761
762         if (first == last)
763                 return (NULL);
764
765         size = IO_SPAN(first, last);
766         ASSERT3U(size, <=, SPA_MAXBLOCKSIZE);
767
768         abd = abd_alloc_gang();
769         if (abd == NULL)
770                 return (NULL);
771
772         aio = zio_vdev_delegated_io(first->io_vd, first->io_offset,
773             abd, size, first->io_type, zio->io_priority,
774             flags | ZIO_FLAG_DONT_QUEUE, vdev_queue_agg_io_done, NULL);
775         aio->io_timestamp = first->io_timestamp;
776
777         nio = first;
778         next_offset = first->io_offset;
779         do {
780                 dio = nio;
781                 nio = AVL_NEXT(t, dio);
782                 ASSERT3P(dio, !=, NULL);
783                 zio_add_child(dio, aio);
784                 vdev_queue_io_remove(vq, dio);
785
786                 if (dio->io_offset != next_offset) {
787                         /* allocate a buffer for a read gap */
788                         ASSERT3U(dio->io_type, ==, ZIO_TYPE_READ);
789                         ASSERT3U(dio->io_offset, >, next_offset);
790                         abd = abd_alloc_for_io(
791                             dio->io_offset - next_offset, B_TRUE);
792                         abd_gang_add(aio->io_abd, abd, B_TRUE);
793                 }
794                 if (dio->io_abd &&
795                     (dio->io_size != abd_get_size(dio->io_abd))) {
796                         /* abd size not the same as IO size */
797                         ASSERT3U(abd_get_size(dio->io_abd), >, dio->io_size);
798                         abd = abd_get_offset_size(dio->io_abd, 0, dio->io_size);
799                         abd_gang_add(aio->io_abd, abd, B_TRUE);
800                 } else {
801                         if (dio->io_flags & ZIO_FLAG_NODATA) {
802                                 /* allocate a buffer for a write gap */
803                                 ASSERT3U(dio->io_type, ==, ZIO_TYPE_WRITE);
804                                 ASSERT3P(dio->io_abd, ==, NULL);
805                                 abd_gang_add(aio->io_abd,
806                                     abd_get_zeros(dio->io_size), B_TRUE);
807                         } else {
808                                 /*
809                                  * We pass B_FALSE to abd_gang_add()
810                                  * because we did not allocate a new
811                                  * ABD, so it is assumed the caller
812                                  * will free this ABD.
813                                  */
814                                 abd_gang_add(aio->io_abd, dio->io_abd,
815                                     B_FALSE);
816                         }
817                 }
818                 next_offset = dio->io_offset + dio->io_size;
819         } while (dio != last);
820         ASSERT3U(abd_get_size(aio->io_abd), ==, aio->io_size);
821
822         /*
823          * Callers must call zio_vdev_io_bypass() and zio_execute() for
824          * aggregated (parent) I/Os so that we could avoid dropping the
825          * queue's lock here to avoid a deadlock that we could encounter
826          * due to lock order reversal between vq_lock and io_lock in
827          * zio_change_priority().
828          */
829         return (aio);
830 }
831
832 static zio_t *
833 vdev_queue_io_to_issue(vdev_queue_t *vq)
834 {
835         zio_t *zio, *aio;
836         zio_priority_t p;
837         avl_index_t idx;
838         avl_tree_t *tree;
839
840 again:
841         ASSERT(MUTEX_HELD(&vq->vq_lock));
842
843         p = vdev_queue_class_to_issue(vq);
844
845         if (p == ZIO_PRIORITY_NUM_QUEUEABLE) {
846                 /* No eligible queued i/os */
847                 return (NULL);
848         }
849
850         if (vdev_queue_class_fifo(p)) {
851                 zio = list_head(&vq->vq_class[p].vqc_list);
852         } else {
853                 /*
854                  * For LBA-ordered queues (async / scrub / initializing),
855                  * issue the I/O which follows the most recently issued I/O
856                  * in LBA (offset) order, but to avoid starvation only within
857                  * the same 0.5 second interval as the first I/O.
858                  */
859                 tree = &vq->vq_class[p].vqc_tree;
860                 zio = aio = avl_first(tree);
861                 if (zio->io_offset < vq->vq_last_offset) {
862                         vq->vq_io_search.io_timestamp = zio->io_timestamp;
863                         vq->vq_io_search.io_offset = vq->vq_last_offset;
864                         zio = avl_find(tree, &vq->vq_io_search, &idx);
865                         if (zio == NULL) {
866                                 zio = avl_nearest(tree, idx, AVL_AFTER);
867                                 if (zio == NULL ||
868                                     (zio->io_timestamp >> VDQ_T_SHIFT) !=
869                                     (aio->io_timestamp >> VDQ_T_SHIFT))
870                                         zio = aio;
871                         }
872                 }
873         }
874         ASSERT3U(zio->io_priority, ==, p);
875
876         aio = vdev_queue_aggregate(vq, zio);
877         if (aio != NULL) {
878                 zio = aio;
879         } else {
880                 vdev_queue_io_remove(vq, zio);
881
882                 /*
883                  * If the I/O is or was optional and therefore has no data, we
884                  * need to simply discard it. We need to drop the vdev queue's
885                  * lock to avoid a deadlock that we could encounter since this
886                  * I/O will complete immediately.
887                  */
888                 if (zio->io_flags & ZIO_FLAG_NODATA) {
889                         mutex_exit(&vq->vq_lock);
890                         zio_vdev_io_bypass(zio);
891                         zio_execute(zio);
892                         mutex_enter(&vq->vq_lock);
893                         goto again;
894                 }
895         }
896
897         vdev_queue_pending_add(vq, zio);
898         vq->vq_last_offset = zio->io_offset + zio->io_size;
899
900         return (zio);
901 }
902
903 zio_t *
904 vdev_queue_io(zio_t *zio)
905 {
906         vdev_queue_t *vq = &zio->io_vd->vdev_queue;
907         zio_t *dio, *nio;
908         zio_link_t *zl = NULL;
909
910         if (zio->io_flags & ZIO_FLAG_DONT_QUEUE)
911                 return (zio);
912
913         /*
914          * Children i/os inherent their parent's priority, which might
915          * not match the child's i/o type.  Fix it up here.
916          */
917         if (zio->io_type == ZIO_TYPE_READ) {
918                 ASSERT(zio->io_priority != ZIO_PRIORITY_TRIM);
919
920                 if (zio->io_priority != ZIO_PRIORITY_SYNC_READ &&
921                     zio->io_priority != ZIO_PRIORITY_ASYNC_READ &&
922                     zio->io_priority != ZIO_PRIORITY_SCRUB &&
923                     zio->io_priority != ZIO_PRIORITY_REMOVAL &&
924                     zio->io_priority != ZIO_PRIORITY_INITIALIZING &&
925                     zio->io_priority != ZIO_PRIORITY_REBUILD) {
926                         zio->io_priority = ZIO_PRIORITY_ASYNC_READ;
927                 }
928         } else if (zio->io_type == ZIO_TYPE_WRITE) {
929                 ASSERT(zio->io_priority != ZIO_PRIORITY_TRIM);
930
931                 if (zio->io_priority != ZIO_PRIORITY_SYNC_WRITE &&
932                     zio->io_priority != ZIO_PRIORITY_ASYNC_WRITE &&
933                     zio->io_priority != ZIO_PRIORITY_REMOVAL &&
934                     zio->io_priority != ZIO_PRIORITY_INITIALIZING &&
935                     zio->io_priority != ZIO_PRIORITY_REBUILD) {
936                         zio->io_priority = ZIO_PRIORITY_ASYNC_WRITE;
937                 }
938         } else {
939                 ASSERT(zio->io_type == ZIO_TYPE_TRIM);
940                 ASSERT(zio->io_priority == ZIO_PRIORITY_TRIM);
941         }
942
943         zio->io_flags |= ZIO_FLAG_DONT_QUEUE;
944         zio->io_timestamp = gethrtime();
945
946         mutex_enter(&vq->vq_lock);
947         vdev_queue_io_add(vq, zio);
948         nio = vdev_queue_io_to_issue(vq);
949         mutex_exit(&vq->vq_lock);
950
951         if (nio == NULL)
952                 return (NULL);
953
954         if (nio->io_done == vdev_queue_agg_io_done) {
955                 while ((dio = zio_walk_parents(nio, &zl)) != NULL) {
956                         ASSERT3U(dio->io_type, ==, nio->io_type);
957                         zio_vdev_io_bypass(dio);
958                         zio_execute(dio);
959                 }
960                 zio_nowait(nio);
961                 return (NULL);
962         }
963
964         return (nio);
965 }
966
967 void
968 vdev_queue_io_done(zio_t *zio)
969 {
970         vdev_queue_t *vq = &zio->io_vd->vdev_queue;
971         zio_t *dio, *nio;
972         zio_link_t *zl = NULL;
973
974         hrtime_t now = gethrtime();
975         vq->vq_io_complete_ts = now;
976         vq->vq_io_delta_ts = zio->io_delta = now - zio->io_timestamp;
977
978         mutex_enter(&vq->vq_lock);
979         vdev_queue_pending_remove(vq, zio);
980
981         while ((nio = vdev_queue_io_to_issue(vq)) != NULL) {
982                 mutex_exit(&vq->vq_lock);
983                 if (nio->io_done == vdev_queue_agg_io_done) {
984                         while ((dio = zio_walk_parents(nio, &zl)) != NULL) {
985                                 ASSERT3U(dio->io_type, ==, nio->io_type);
986                                 zio_vdev_io_bypass(dio);
987                                 zio_execute(dio);
988                         }
989                         zio_nowait(nio);
990                 } else {
991                         zio_vdev_io_reissue(nio);
992                         zio_execute(nio);
993                 }
994                 mutex_enter(&vq->vq_lock);
995         }
996
997         mutex_exit(&vq->vq_lock);
998 }
999
1000 void
1001 vdev_queue_change_io_priority(zio_t *zio, zio_priority_t priority)
1002 {
1003         vdev_queue_t *vq = &zio->io_vd->vdev_queue;
1004
1005         /*
1006          * ZIO_PRIORITY_NOW is used by the vdev cache code and the aggregate zio
1007          * code to issue IOs without adding them to the vdev queue. In this
1008          * case, the zio is already going to be issued as quickly as possible
1009          * and so it doesn't need any reprioritization to help.
1010          */
1011         if (zio->io_priority == ZIO_PRIORITY_NOW)
1012                 return;
1013
1014         ASSERT3U(zio->io_priority, <, ZIO_PRIORITY_NUM_QUEUEABLE);
1015         ASSERT3U(priority, <, ZIO_PRIORITY_NUM_QUEUEABLE);
1016
1017         if (zio->io_type == ZIO_TYPE_READ) {
1018                 if (priority != ZIO_PRIORITY_SYNC_READ &&
1019                     priority != ZIO_PRIORITY_ASYNC_READ &&
1020                     priority != ZIO_PRIORITY_SCRUB)
1021                         priority = ZIO_PRIORITY_ASYNC_READ;
1022         } else {
1023                 ASSERT(zio->io_type == ZIO_TYPE_WRITE);
1024                 if (priority != ZIO_PRIORITY_SYNC_WRITE &&
1025                     priority != ZIO_PRIORITY_ASYNC_WRITE)
1026                         priority = ZIO_PRIORITY_ASYNC_WRITE;
1027         }
1028
1029         mutex_enter(&vq->vq_lock);
1030
1031         /*
1032          * If the zio is in none of the queues we can simply change
1033          * the priority. If the zio is waiting to be submitted we must
1034          * remove it from the queue and re-insert it with the new priority.
1035          * Otherwise, the zio is currently active and we cannot change its
1036          * priority.
1037          */
1038         if (zio->io_queue_state == ZIO_QS_QUEUED) {
1039                 vdev_queue_class_remove(vq, zio);
1040                 zio->io_priority = priority;
1041                 vdev_queue_class_add(vq, zio);
1042         } else if (zio->io_queue_state == ZIO_QS_NONE) {
1043                 zio->io_priority = priority;
1044         }
1045
1046         mutex_exit(&vq->vq_lock);
1047 }
1048
1049 /*
1050  * As these two methods are only used for load calculations we're not
1051  * concerned if we get an incorrect value on 32bit platforms due to lack of
1052  * vq_lock mutex use here, instead we prefer to keep it lock free for
1053  * performance.
1054  */
1055 uint32_t
1056 vdev_queue_length(vdev_t *vd)
1057 {
1058         return (vd->vdev_queue.vq_active);
1059 }
1060
1061 uint64_t
1062 vdev_queue_last_offset(vdev_t *vd)
1063 {
1064         return (vd->vdev_queue.vq_last_offset);
1065 }
1066
1067 uint64_t
1068 vdev_queue_class_length(vdev_t *vd, zio_priority_t p)
1069 {
1070         vdev_queue_t *vq = &vd->vdev_queue;
1071         if (vdev_queue_class_fifo(p))
1072                 return (list_is_empty(&vq->vq_class[p].vqc_list) == 0);
1073         else
1074                 return (avl_numnodes(&vq->vq_class[p].vqc_tree));
1075 }
1076
1077 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, aggregation_limit, UINT, ZMOD_RW,
1078         "Max vdev I/O aggregation size");
1079
1080 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, aggregation_limit_non_rotating, UINT,
1081         ZMOD_RW, "Max vdev I/O aggregation size for non-rotating media");
1082
1083 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, read_gap_limit, UINT, ZMOD_RW,
1084         "Aggregate read I/O over gap");
1085
1086 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, write_gap_limit, UINT, ZMOD_RW,
1087         "Aggregate write I/O over gap");
1088
1089 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, max_active, UINT, ZMOD_RW,
1090         "Maximum number of active I/Os per vdev");
1091
1092 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, async_write_active_max_dirty_percent,
1093         UINT, ZMOD_RW, "Async write concurrency max threshold");
1094
1095 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, async_write_active_min_dirty_percent,
1096         UINT, ZMOD_RW, "Async write concurrency min threshold");
1097
1098 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, async_read_max_active, UINT, ZMOD_RW,
1099         "Max active async read I/Os per vdev");
1100
1101 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, async_read_min_active, UINT, ZMOD_RW,
1102         "Min active async read I/Os per vdev");
1103
1104 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, async_write_max_active, UINT, ZMOD_RW,
1105         "Max active async write I/Os per vdev");
1106
1107 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, async_write_min_active, UINT, ZMOD_RW,
1108         "Min active async write I/Os per vdev");
1109
1110 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, initializing_max_active, UINT, ZMOD_RW,
1111         "Max active initializing I/Os per vdev");
1112
1113 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, initializing_min_active, UINT, ZMOD_RW,
1114         "Min active initializing I/Os per vdev");
1115
1116 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, removal_max_active, UINT, ZMOD_RW,
1117         "Max active removal I/Os per vdev");
1118
1119 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, removal_min_active, UINT, ZMOD_RW,
1120         "Min active removal I/Os per vdev");
1121
1122 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, scrub_max_active, UINT, ZMOD_RW,
1123         "Max active scrub I/Os per vdev");
1124
1125 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, scrub_min_active, UINT, ZMOD_RW,
1126         "Min active scrub I/Os per vdev");
1127
1128 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, sync_read_max_active, UINT, ZMOD_RW,
1129         "Max active sync read I/Os per vdev");
1130
1131 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, sync_read_min_active, UINT, ZMOD_RW,
1132         "Min active sync read I/Os per vdev");
1133
1134 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, sync_write_max_active, UINT, ZMOD_RW,
1135         "Max active sync write I/Os per vdev");
1136
1137 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, sync_write_min_active, UINT, ZMOD_RW,
1138         "Min active sync write I/Os per vdev");
1139
1140 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, trim_max_active, UINT, ZMOD_RW,
1141         "Max active trim/discard I/Os per vdev");
1142
1143 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, trim_min_active, UINT, ZMOD_RW,
1144         "Min active trim/discard I/Os per vdev");
1145
1146 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, rebuild_max_active, UINT, ZMOD_RW,
1147         "Max active rebuild I/Os per vdev");
1148
1149 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, rebuild_min_active, UINT, ZMOD_RW,
1150         "Min active rebuild I/Os per vdev");
1151
1152 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, nia_credit, UINT, ZMOD_RW,
1153         "Number of non-interactive I/Os to allow in sequence");
1154
1155 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, nia_delay, UINT, ZMOD_RW,
1156         "Number of non-interactive I/Os before _max_active");
1157
1158 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, queue_depth_pct, UINT, ZMOD_RW,
1159         "Queue depth percentage for each top-level vdev");
1160
1161 ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, def_queue_depth, UINT, ZMOD_RW,
1162         "Default queue depth for each allocator");