| 86 | } |
| 87 | |
| 88 | static int test_parallel(struct io_uring *ring, int fd, int cmd_op) |
| 89 | { |
| 90 | struct io_uring_sqe *sqe; |
| 91 | struct io_uring_cqe *cqe; |
| 92 | int inflight = 0; |
| 93 | int max_inflight = 16; |
| 94 | int left = 1000; |
| 95 | int ret; |
| 96 | |
| 97 | while (left || inflight) { |
| 98 | int queued = 0; |
| 99 | unsigned head, nr_cqes = 0; |
| 100 | int lba_len = 8; |
| 101 | |
| 102 | while (inflight < max_inflight && left) { |
| 103 | int off = rand() % (MAX_TEST_LBAS - lba_len); |
| 104 | sqe = io_uring_get_sqe(ring); |
| 105 | assert(sqe != NULL); |
| 106 | |
| 107 | prep_blk_cmd(sqe, fd, off * lba_size, |
| 108 | lba_len * lba_size, cmd_op); |
| 109 | if (rand() & 1) |
| 110 | sqe->flags |= IOSQE_ASYNC; |
| 111 | |
| 112 | queued++; |
| 113 | left--; |
| 114 | inflight++; |
| 115 | } |
| 116 | if (queued) { |
| 117 | ret = io_uring_submit(ring); |
| 118 | if (ret != queued) { |
| 119 | fprintf(stderr, "io_uring_submit failed %d\n", ret); |
| 120 | return T_EXIT_FAIL; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | ret = io_uring_wait_cqe(ring, &cqe); |
| 125 | if (ret) { |
| 126 | fprintf(stderr, "io_uring_wait_cqe failed %d\n", ret); |
| 127 | exit(1); |
| 128 | } |
| 129 | |
| 130 | io_uring_for_each_cqe(ring, head, cqe) { |
| 131 | nr_cqes++; |
| 132 | inflight--; |
| 133 | if (cqe->res != 0) { |
| 134 | fprintf(stderr, "cmd %i failed %i\n", cmd_op, |
| 135 | cqe->res); |
| 136 | return T_EXIT_FAIL; |
| 137 | } |
| 138 | } |
| 139 | io_uring_cq_advance(ring, nr_cqes); |
| 140 | } |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | static int cmd_issue_verify(struct io_uring *ring, int fd, int lba, int len, |
no test coverage detected