t/io_uring: ensure batch counts are smaller or equal to depth
authorJens Axboe <axboe@kernel.dk>
Thu, 23 Sep 2021 15:15:16 +0000 (09:15 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 23 Sep 2021 15:15:16 +0000 (09:15 -0600)
If you use a batch submit or complete count that's larger than the
depth, then t/io_uring will stall. Make sure to sanitize the counts
so that any batch values is always <= total depth.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 1adb8789d199e7bc00511bff51cde18efa650e27..af1b8fa8ace0ecf909e59a8d8db20cfefa4d4417 100644 (file)
@@ -617,6 +617,11 @@ int main(int argc, char *argv[])
                }
        }
 
+       if (batch_complete > depth)
+               batch_complete = depth;
+       if (batch_submit > depth)
+               batch_submit = depth;
+
        submitter = calloc(nthreads, sizeof(*submitter) +
                                depth * sizeof(struct iovec));
        for (j = 0; j < nthreads; j++) {