t/io_uring: only calculate per-file depth if we have files
authorJens Axboe <axboe@kernel.dk>
Wed, 17 Apr 2024 22:33:28 +0000 (16:33 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 17 Apr 2024 22:34:47 +0000 (16:34 -0600)
If NOPs are used, then no files exist, and hence the app will throw
a floating point error when trying to divide by zero.

Fixes: 6067863c7016 ("t/io_uring: pre-calculate per-file depth")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 18e8b38e7d15ac1f00818511f5e4c4ec73d74b74..aa6e09e9edf94b3438e434dac0f4e21bb113d964 100644 (file)
@@ -974,7 +974,9 @@ static int setup_ring(struct submitter *s)
        for (i = 0; i < p.sq_entries; i++)
                sring->array[i] = i;
 
-       s->per_file_depth = (depth + s->nr_files - 1) / s->nr_files;
+       s->per_file_depth = INT_MAX;
+       if (s->nr_files)
+               s->per_file_depth = (depth + s->nr_files - 1) / s->nr_files;
        return 0;
 }