Temporarily move taskq+util to libzpool until that directory is broken in to lib...
[zfs.git] / zfs / lib / libzpool / vdev_queue.c
index db79c8d..46fca0e 100644 (file)
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident  "@(#)vdev_queue.c       1.6     07/11/27 SMI"
-
 #include <sys/zfs_context.h>
 #include <sys/spa.h>
 #include <sys/vdev_impl.h>
@@ -191,6 +189,7 @@ vdev_queue_io_to_issue(vdev_queue_t *vq, uint64_t pending_limit)
        size = fio->io_size;
 
        while ((dio = AVL_PREV(tree, fio)) != NULL && IS_ADJACENT(dio, fio) &&
+           !((dio->io_flags | fio->io_flags) & ZIO_FLAG_DONT_AGGREGATE) &&
            size + dio->io_size <= zfs_vdev_aggregation_limit) {
                dio->io_delegate_next = fio;
                fio = dio;
@@ -198,6 +197,7 @@ vdev_queue_io_to_issue(vdev_queue_t *vq, uint64_t pending_limit)
        }
 
        while ((dio = AVL_NEXT(tree, lio)) != NULL && IS_ADJACENT(lio, dio) &&
+           !((lio->io_flags | dio->io_flags) & ZIO_FLAG_DONT_AGGREGATE) &&
            size + dio->io_size <= zfs_vdev_aggregation_limit) {
                lio->io_delegate_next = dio;
                lio = dio;
@@ -207,15 +207,12 @@ vdev_queue_io_to_issue(vdev_queue_t *vq, uint64_t pending_limit)
        if (fio != lio) {
                char *buf = zio_buf_alloc(size);
                uint64_t offset = 0;
-               int nagg = 0;
 
                ASSERT(size <= zfs_vdev_aggregation_limit);
 
-               aio = zio_vdev_child_io(fio, NULL, fio->io_vd,
-                   fio->io_offset, buf, size, fio->io_type,
-                   ZIO_PRIORITY_NOW, ZIO_FLAG_DONT_QUEUE |
-                   ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_PROPAGATE |
-                   ZIO_FLAG_NOBOOKMARK,
+               aio = zio_vdev_delegated_io(fio->io_vd, fio->io_offset,
+                   buf, size, fio->io_type, ZIO_PRIORITY_NOW,
+                   ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE,
                    vdev_queue_agg_io_done, NULL);
 
                aio->io_delegate_list = fio;
@@ -228,16 +225,10 @@ vdev_queue_io_to_issue(vdev_queue_t *vq, uint64_t pending_limit)
                        offset += dio->io_size;
                        vdev_queue_io_remove(vq, dio);
                        zio_vdev_io_bypass(dio);
-                       nagg++;
                }
 
                ASSERT(offset == size);
 
-               dprintf("%5s  T=%llu  off=%8llx  agg=%3d  "
-                   "old=%5llx  new=%5llx\n",
-                   zio_type_name[fio->io_type],
-                   fio->io_deadline, fio->io_offset, nagg, fio->io_size, size);
-
                avl_add(&vq->vq_pending_tree, aio);
 
                return (aio);
@@ -271,8 +262,7 @@ vdev_queue_io(zio_t *zio)
 
        mutex_enter(&vq->vq_lock);
 
-       zio->io_deadline = (zio->io_timestamp >> zfs_vdev_time_shift) +
-           zio->io_priority;
+       zio->io_deadline = (lbolt64 >> zfs_vdev_time_shift) + zio->io_priority;
 
        vdev_queue_io_add(vq, zio);
 
@@ -295,15 +285,13 @@ void
 vdev_queue_io_done(zio_t *zio)
 {
        vdev_queue_t *vq = &zio->io_vd->vdev_queue;
-       zio_t *nio;
-       int i;
 
        mutex_enter(&vq->vq_lock);
 
        avl_remove(&vq->vq_pending_tree, zio);
 
-       for (i = 0; i < zfs_vdev_ramp_rate; i++) {
-               nio = vdev_queue_io_to_issue(vq, zfs_vdev_max_pending);
+       for (int i = 0; i < zfs_vdev_ramp_rate; i++) {
+               zio_t *nio = vdev_queue_io_to_issue(vq, zfs_vdev_max_pending);
                if (nio == NULL)
                        break;
                mutex_exit(&vq->vq_lock);