Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet/dist/uts/common/fs/zfs reduce stack usag...



details:   https://anonhg.NetBSD.org/src/rev/d6c88796b282
branches:  trunk
changeset: 1011261:d6c88796b282
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Jun 24 16:16:01 2020 +0000

description:
reduce stack usage in vdev_queue_io_to_issue() - zio_t is about 1KB, and
the function potentially recurses into itself

part of fix for PR kern/55402 by Frank Kardel

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (33 lines):

diff -r 6566e1099fb3 -r d6c88796b282 external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c   Wed Jun 24 15:05:45 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_queue.c   Wed Jun 24 16:16:01 2020 +0000
@@ -798,7 +798,7 @@
        zio_priority_t p;
        avl_index_t idx;
        avl_tree_t *tree;
-       zio_t search;
+       zio_t *search;
 
 again:
        ASSERT(MUTEX_HELD(&vq->vq_lock));
@@ -817,10 +817,16 @@
         * For FIFO queues (sync), issue the i/o with the lowest timestamp.
         */
        tree = vdev_queue_class_tree(vq, p);
-       search.io_timestamp = 0;
-       search.io_offset = vq->vq_last_offset + 1;
-       VERIFY3P(avl_find(tree, &search, &idx), ==, NULL);
-       zio = avl_nearest(tree, idx, AVL_AFTER);
+       search = kmem_zalloc(sizeof (*search), KM_NOSLEEP);
+       if (search) {
+               search->io_offset = vq->vq_last_offset + 1;
+               VERIFY3P(avl_find(tree, &search, &idx), ==, NULL);
+               kmem_free(search, sizeof (*search));
+               zio = avl_nearest(tree, idx, AVL_AFTER);
+       } else {
+               /* Can't find nearest, fallback to first */
+               zio = NULL;
+       }
        if (zio == NULL)
                zio = avl_first(tree);
        ASSERT3U(zio->io_priority, ==, p);



Home | Main Index | Thread Index | Old Index