uringmachine 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +85 -0
  4. data/TODO.md +5 -0
  5. data/examples/echo_server.rb +18 -40
  6. data/examples/inout.rb +19 -0
  7. data/examples/nc.rb +36 -0
  8. data/ext/um/extconf.rb +6 -15
  9. data/ext/um/um.c +245 -53
  10. data/ext/um/um.h +21 -9
  11. data/ext/um/um_class.c +74 -87
  12. data/ext/um/um_const.c +184 -0
  13. data/ext/um/um_op.c +10 -13
  14. data/ext/um/um_utils.c +48 -3
  15. data/lib/uringmachine/version.rb +1 -1
  16. data/lib/uringmachine.rb +12 -0
  17. data/test/helper.rb +8 -0
  18. data/test/test_um.rb +227 -7
  19. data/vendor/liburing/.github/workflows/build.yml +29 -1
  20. data/vendor/liburing/.gitignore +1 -0
  21. data/vendor/liburing/CHANGELOG +15 -0
  22. data/vendor/liburing/CONTRIBUTING.md +165 -0
  23. data/vendor/liburing/configure +32 -0
  24. data/vendor/liburing/examples/Makefile +8 -1
  25. data/vendor/liburing/examples/kdigest.c +405 -0
  26. data/vendor/liburing/examples/proxy.c +75 -8
  27. data/vendor/liburing/liburing.pc.in +1 -1
  28. data/vendor/liburing/src/Makefile +16 -2
  29. data/vendor/liburing/src/include/liburing/io_uring.h +31 -0
  30. data/vendor/liburing/src/include/liburing/sanitize.h +39 -0
  31. data/vendor/liburing/src/include/liburing.h +31 -4
  32. data/vendor/liburing/src/liburing-ffi.map +5 -0
  33. data/vendor/liburing/src/liburing.map +1 -0
  34. data/vendor/liburing/src/queue.c +3 -0
  35. data/vendor/liburing/src/register.c +36 -0
  36. data/vendor/liburing/src/sanitize.c +176 -0
  37. data/vendor/liburing/src/setup.c +1 -1
  38. data/vendor/liburing/test/35fa71a030ca.c +7 -0
  39. data/vendor/liburing/test/500f9fbadef8.c +2 -0
  40. data/vendor/liburing/test/7ad0e4b2f83c.c +0 -25
  41. data/vendor/liburing/test/917257daa0fe.c +7 -0
  42. data/vendor/liburing/test/Makefile +31 -4
  43. data/vendor/liburing/test/a0908ae19763.c +7 -0
  44. data/vendor/liburing/test/a4c0b3decb33.c +7 -0
  45. data/vendor/liburing/test/accept.c +14 -4
  46. data/vendor/liburing/test/b19062a56726.c +7 -0
  47. data/vendor/liburing/test/bind-listen.c +2 -2
  48. data/vendor/liburing/test/buf-ring-nommap.c +10 -3
  49. data/vendor/liburing/test/buf-ring.c +2 -0
  50. data/vendor/liburing/test/coredump.c +7 -0
  51. data/vendor/liburing/test/cq-overflow.c +13 -1
  52. data/vendor/liburing/test/d4ae271dfaae.c +11 -3
  53. data/vendor/liburing/test/defer-taskrun.c +2 -2
  54. data/vendor/liburing/test/defer-tw-timeout.c +4 -1
  55. data/vendor/liburing/test/defer.c +2 -2
  56. data/vendor/liburing/test/double-poll-crash.c +1 -1
  57. data/vendor/liburing/test/eeed8b54e0df.c +2 -0
  58. data/vendor/liburing/test/eventfd.c +0 -1
  59. data/vendor/liburing/test/exit-no-cleanup.c +11 -0
  60. data/vendor/liburing/test/fadvise.c +9 -26
  61. data/vendor/liburing/test/fdinfo.c +9 -1
  62. data/vendor/liburing/test/file-register.c +14 -2
  63. data/vendor/liburing/test/file-update.c +1 -1
  64. data/vendor/liburing/test/file-verify.c +27 -16
  65. data/vendor/liburing/test/files-exit-hang-timeout.c +1 -2
  66. data/vendor/liburing/test/fixed-buf-iter.c +3 -1
  67. data/vendor/liburing/test/fixed-hugepage.c +12 -1
  68. data/vendor/liburing/test/fsnotify.c +1 -0
  69. data/vendor/liburing/test/futex.c +16 -4
  70. data/vendor/liburing/test/helpers.c +47 -0
  71. data/vendor/liburing/test/helpers.h +6 -0
  72. data/vendor/liburing/test/init-mem.c +5 -3
  73. data/vendor/liburing/test/io-cancel.c +0 -24
  74. data/vendor/liburing/test/io_uring_passthrough.c +2 -0
  75. data/vendor/liburing/test/io_uring_register.c +25 -6
  76. data/vendor/liburing/test/iopoll-leak.c +4 -0
  77. data/vendor/liburing/test/iopoll-overflow.c +1 -1
  78. data/vendor/liburing/test/iopoll.c +3 -3
  79. data/vendor/liburing/test/kallsyms.c +203 -0
  80. data/vendor/liburing/test/link-timeout.c +159 -0
  81. data/vendor/liburing/test/linked-defer-close.c +224 -0
  82. data/vendor/liburing/test/madvise.c +12 -25
  83. data/vendor/liburing/test/min-timeout-wait.c +0 -25
  84. data/vendor/liburing/test/min-timeout.c +0 -25
  85. data/vendor/liburing/test/mkdir.c +6 -0
  86. data/vendor/liburing/test/msg-ring.c +8 -2
  87. data/vendor/liburing/test/napi-test.c +15 -2
  88. data/vendor/liburing/test/no-mmap-inval.c +2 -0
  89. data/vendor/liburing/test/nop.c +44 -0
  90. data/vendor/liburing/test/ooo-file-unreg.c +1 -1
  91. data/vendor/liburing/test/open-close.c +40 -0
  92. data/vendor/liburing/test/openat2.c +37 -14
  93. data/vendor/liburing/test/poll-many.c +13 -7
  94. data/vendor/liburing/test/poll-mshot-update.c +17 -10
  95. data/vendor/liburing/test/poll-v-poll.c +6 -3
  96. data/vendor/liburing/test/pollfree.c +148 -0
  97. data/vendor/liburing/test/read-mshot-empty.c +156 -153
  98. data/vendor/liburing/test/read-mshot.c +276 -27
  99. data/vendor/liburing/test/read-write.c +78 -13
  100. data/vendor/liburing/test/recv-msgall-stream.c +3 -0
  101. data/vendor/liburing/test/recv-msgall.c +5 -0
  102. data/vendor/liburing/test/recvsend_bundle-inc.c +680 -0
  103. data/vendor/liburing/test/recvsend_bundle.c +92 -29
  104. data/vendor/liburing/test/reg-fd-only.c +14 -4
  105. data/vendor/liburing/test/regbuf-clone.c +187 -0
  106. data/vendor/liburing/test/regbuf-merge.c +7 -0
  107. data/vendor/liburing/test/register-restrictions.c +86 -85
  108. data/vendor/liburing/test/rename.c +59 -1
  109. data/vendor/liburing/test/ringbuf-read.c +5 -0
  110. data/vendor/liburing/test/ringbuf-status.c +5 -1
  111. data/vendor/liburing/test/runtests.sh +16 -1
  112. data/vendor/liburing/test/send-zerocopy.c +59 -0
  113. data/vendor/liburing/test/short-read.c +1 -0
  114. data/vendor/liburing/test/socket.c +43 -0
  115. data/vendor/liburing/test/splice.c +3 -1
  116. data/vendor/liburing/test/sq-poll-dup.c +1 -1
  117. data/vendor/liburing/test/sq-poll-share.c +2 -0
  118. data/vendor/liburing/test/sqpoll-disable-exit.c +8 -0
  119. data/vendor/liburing/test/sqpoll-exit-hang.c +1 -25
  120. data/vendor/liburing/test/sqpoll-sleep.c +1 -25
  121. data/vendor/liburing/test/statx.c +89 -0
  122. data/vendor/liburing/test/stdout.c +2 -0
  123. data/vendor/liburing/test/submit-and-wait.c +1 -25
  124. data/vendor/liburing/test/submit-reuse.c +4 -26
  125. data/vendor/liburing/test/symlink.c +12 -1
  126. data/vendor/liburing/test/sync-cancel.c +48 -21
  127. data/vendor/liburing/test/thread-exit.c +5 -0
  128. data/vendor/liburing/test/timeout-new.c +1 -26
  129. data/vendor/liburing/test/timeout.c +12 -26
  130. data/vendor/liburing/test/unlink.c +94 -1
  131. data/vendor/liburing/test/uring_cmd_ublk.c +1252 -0
  132. data/vendor/liburing/test/waitid.c +62 -8
  133. data/vendor/liburing/test/wq-aff.c +35 -0
  134. data/vendor/liburing/test/xfail_prep_link_timeout_out_of_scope.c +46 -0
  135. data/vendor/liburing/test/xfail_register_buffers_out_of_scope.c +51 -0
  136. metadata +17 -4
  137. data/examples/event_loop.rb +0 -69
  138. data/examples/fibers.rb +0 -105
@@ -60,7 +60,7 @@ static void close_sock_fds(int s_fd[], int c_fd[], int nr, bool fixed)
60
60
  close_fds(c_fd, nr);
61
61
  }
62
62
 
63
- static void queue_send(struct io_uring *ring, int fd)
63
+ static void *queue_send(struct io_uring *ring, int fd)
64
64
  {
65
65
  struct io_uring_sqe *sqe;
66
66
  struct data *d;
@@ -72,9 +72,11 @@ static void queue_send(struct io_uring *ring, int fd)
72
72
  sqe = io_uring_get_sqe(ring);
73
73
  io_uring_prep_writev(sqe, fd, &d->iov, 1, 0);
74
74
  sqe->user_data = 1;
75
+
76
+ return d;
75
77
  }
76
78
 
77
- static void queue_recv(struct io_uring *ring, int fd, bool fixed)
79
+ static void *queue_recv(struct io_uring *ring, int fd, bool fixed)
78
80
  {
79
81
  struct io_uring_sqe *sqe;
80
82
  struct data *d;
@@ -88,6 +90,8 @@ static void queue_recv(struct io_uring *ring, int fd, bool fixed)
88
90
  sqe->user_data = 2;
89
91
  if (fixed)
90
92
  sqe->flags |= IOSQE_FIXED_FILE;
93
+
94
+ return d;
91
95
  }
92
96
 
93
97
  static void queue_accept_multishot(struct io_uring *ring, int fd,
@@ -274,6 +278,8 @@ static int test_loop(struct io_uring *ring,
274
278
  int nr_fds = multishot ? MAX_FDS : 1;
275
279
  int multishot_idx = multishot ? INITIAL_USER_DATA : 0;
276
280
  int err_ret = T_EXIT_FAIL;
281
+ void* send_d = 0;
282
+ void* recv_d = 0;
277
283
 
278
284
  if (args.overflow)
279
285
  cause_overflow(ring);
@@ -340,8 +346,8 @@ static int test_loop(struct io_uring *ring,
340
346
  goto out;
341
347
  }
342
348
 
343
- queue_send(ring, c_fd[0]);
344
- queue_recv(ring, s_fd[0], fixed);
349
+ send_d = queue_send(ring, c_fd[0]);
350
+ recv_d = queue_recv(ring, s_fd[0], fixed);
345
351
 
346
352
  ret = io_uring_submit_and_wait(ring, 2);
347
353
  assert(ret != -1);
@@ -365,9 +371,13 @@ static int test_loop(struct io_uring *ring,
365
371
  }
366
372
 
367
373
  out:
374
+ free(send_d);
375
+ free(recv_d);
368
376
  close_sock_fds(s_fd, c_fd, nr_fds, fixed);
369
377
  return T_EXIT_PASS;
370
378
  err:
379
+ free(send_d);
380
+ free(recv_d);
371
381
  close_sock_fds(s_fd, c_fd, nr_fds, fixed);
372
382
  return err_ret;
373
383
  }
@@ -14,6 +14,7 @@
14
14
  #include "helpers.h"
15
15
  #include "../src/syscall.h"
16
16
 
17
+ #ifndef CONFIG_USE_SANITIZER
17
18
  int main(int argc, char *argv[])
18
19
  {
19
20
  if (argc > 1)
@@ -52,3 +53,9 @@ int main(int argc, char *argv[])
52
53
  __sys_io_uring_setup(0xc9f, (struct io_uring_params *) 0x20000200);
53
54
  return T_EXIT_PASS;
54
55
  }
56
+ #else
57
+ int main(int argc, char *argv[])
58
+ {
59
+ return T_EXIT_SKIP;
60
+ }
61
+ #endif
@@ -54,7 +54,7 @@ static int connect_client(struct io_uring *ring, unsigned short peer_port)
54
54
 
55
55
  sqe = io_uring_get_sqe(ring);
56
56
  io_uring_prep_send(sqe, CLI_INDEX, magic, strlen(magic), 0);
57
- sqe->flags |= IOSQE_FIXED_FILE | IOSQE_IO_LINK;
57
+ sqe->flags |= IOSQE_FIXED_FILE;
58
58
 
59
59
  submitted = ret = io_uring_submit(ring);
60
60
  if (ret < 0)
@@ -180,7 +180,7 @@ static int test_good_server(unsigned int ring_flags)
180
180
  io_uring_cqe_seen(&ring, cqe);
181
181
 
182
182
  sqe = io_uring_get_sqe(&ring);
183
- io_uring_prep_recv(sqe, CONN_INDEX, buf, BUFSIZ, 0);
183
+ io_uring_prep_recv(sqe, CONN_INDEX, buf, sizeof(buf), 0);
184
184
  sqe->flags |= IOSQE_FIXED_FILE;
185
185
 
186
186
  io_uring_submit(&ring);
@@ -46,8 +46,10 @@ int main(int argc, char *argv[])
46
46
  p.flags = IORING_SETUP_NO_MMAP;
47
47
  ret = io_uring_queue_init_mem(1, &ring, &p, ring_mem, 16384);
48
48
  if (ret < 0) {
49
- if (ret == -EINVAL || ret == -ENOMEM)
49
+ if (ret == -EINVAL || ret == -ENOMEM) {
50
+ free(ring_mem);
50
51
  return T_EXIT_SKIP;
52
+ }
51
53
  fprintf(stderr, "queue init failed %d\n", ret);
52
54
  return T_EXIT_FAIL;
53
55
  }
@@ -62,8 +64,10 @@ int main(int argc, char *argv[])
62
64
 
63
65
  ret = io_uring_register_buf_ring(&ring, &reg, 0);
64
66
  if (ret) {
65
- if (ret == -EINVAL)
67
+ if (ret == -EINVAL) {
68
+ free(ring_mem);
66
69
  return T_EXIT_SKIP;
70
+ }
67
71
  fprintf(stderr, "reg buf ring: %d\n", ret);
68
72
  return T_EXIT_FAIL;
69
73
  }
@@ -73,8 +77,10 @@ int main(int argc, char *argv[])
73
77
  br = mmap(NULL, ring_size, PROT_READ | PROT_WRITE,
74
78
  MAP_SHARED | MAP_POPULATE, ring.ring_fd, off);
75
79
  if (br == MAP_FAILED) {
76
- if (errno == ENOMEM)
80
+ if (errno == ENOMEM) {
81
+ free(ring_mem);
77
82
  return T_EXIT_SKIP;
83
+ }
78
84
  perror("mmap");
79
85
  return T_EXIT_FAIL;
80
86
  }
@@ -119,5 +125,6 @@ int main(int argc, char *argv[])
119
125
  io_uring_cqe_seen(&ring, cqe);
120
126
 
121
127
  io_uring_queue_exit(&ring);
128
+ free(ring_mem);
122
129
  return T_EXIT_PASS;
123
130
  }
@@ -57,6 +57,7 @@ static int test_mixed_reg2(int bgid)
57
57
 
58
58
  io_uring_free_buf_ring(&ring, br, 32, bgid);
59
59
  io_uring_queue_exit(&ring);
60
+ free(bufs);
60
61
  return 0;
61
62
  }
62
63
 
@@ -99,6 +100,7 @@ static int test_mixed_reg(int bgid)
99
100
  }
100
101
 
101
102
  io_uring_queue_exit(&ring);
103
+ free(bufs);
102
104
  return 0;
103
105
  }
104
106
 
@@ -16,6 +16,7 @@
16
16
  #include "liburing.h"
17
17
  #include "helpers.h"
18
18
 
19
+ #ifndef CONFIG_USE_SANITIZER
19
20
  static void test(void)
20
21
  {
21
22
  struct io_uring_sqe *sqe;
@@ -58,3 +59,9 @@ int main(int argc, char *argv[])
58
59
  unlink("core");
59
60
  return T_EXIT_PASS;
60
61
  }
62
+ #else
63
+ int main(int argc, char *argv[])
64
+ {
65
+ return T_EXIT_SKIP;
66
+ }
67
+ #endif
@@ -88,8 +88,10 @@ static int test_io(const char *file, unsigned long usecs, unsigned *drops,
88
88
  goto err;
89
89
  }
90
90
  offset = BS * (rand() % BUFFERS);
91
- if (fault && i == ENTRIES + 4)
91
+ if (fault && i == ENTRIES + 4) {
92
+ free(vecs[i].iov_base);
92
93
  vecs[i].iov_base = NULL;
94
+ }
93
95
  io_uring_prep_readv(sqe, fd, &vecs[i], 1, offset);
94
96
 
95
97
  ret = io_uring_submit(&ring);
@@ -523,8 +525,18 @@ int main(int argc, char *argv[])
523
525
  }
524
526
 
525
527
  unlink(fname);
528
+ if(vecs != NULL) {
529
+ for (i = 0; i < BUFFERS; i++)
530
+ free(vecs[i].iov_base);
531
+ }
532
+ free(vecs);
526
533
  return T_EXIT_PASS;
527
534
  err:
528
535
  unlink(fname);
536
+ if(vecs != NULL) {
537
+ for (i = 0; i < BUFFERS; i++)
538
+ free(vecs[i].iov_base);
539
+ }
540
+ free(vecs);
529
541
  return T_EXIT_FAIL;
530
542
  }
@@ -19,10 +19,10 @@
19
19
  int main(int argc, char *argv[])
20
20
  {
21
21
  struct io_uring ring;
22
- int i, fd, ret;
22
+ int i, fd, ret, __e;
23
23
  struct io_uring_sqe *sqe;
24
24
  struct io_uring_cqe *cqe;
25
- struct iovec *iovecs;
25
+ struct iovec *iovecs = NULL;
26
26
  struct io_uring_params p;
27
27
  char *fname;
28
28
  void *buf;
@@ -43,10 +43,13 @@ int main(int argc, char *argv[])
43
43
  }
44
44
 
45
45
  fd = open(fname, O_RDONLY | O_DIRECT);
46
+ __e = errno;
46
47
  if (fname != argv[1])
47
48
  unlink(fname);
48
49
  if (fd < 0) {
49
- perror("open");
50
+ if (__e == EINVAL || __e == EPERM || __e == EACCES)
51
+ return T_EXIT_SKIP;
52
+ fprintf(stderr, "open: %s\n", strerror(__e));
50
53
  goto out;
51
54
  }
52
55
 
@@ -92,5 +95,10 @@ int main(int argc, char *argv[])
92
95
  close(fd);
93
96
  out:
94
97
  io_uring_queue_exit(&ring);
98
+ if (iovecs != NULL) { //
99
+ for (i = 0; i < 10; i++)
100
+ free(iovecs[i].iov_base);
101
+ free(iovecs);
102
+ }
95
103
  return ret;
96
104
  }
@@ -196,12 +196,12 @@ static int test_exec(const char *filename)
196
196
 
197
197
  if (filename) {
198
198
  fd = open(filename, O_RDONLY | O_DIRECT);
199
- if (fd < 0 && errno == EINVAL)
199
+ if (fd < 0 && (errno == EINVAL || errno == EPERM || errno == EACCES))
200
200
  return T_EXIT_SKIP;
201
201
  } else {
202
202
  t_create_file(EXEC_FILENAME, EXEC_FILESIZE);
203
203
  fd = open(EXEC_FILENAME, O_RDONLY | O_DIRECT);
204
- if (fd < 0 && errno == EINVAL) {
204
+ if (fd < 0 && (errno == EINVAL || errno == EPERM || errno == EACCES)) {
205
205
  unlink(EXEC_FILENAME);
206
206
  return T_EXIT_SKIP;
207
207
  }
@@ -99,7 +99,7 @@ static int test_file(struct io_uring *ring, char *__fname)
99
99
 
100
100
  fd = open(fname, O_RDONLY | O_DIRECT);
101
101
  if (fd < 0) {
102
- if (errno == EINVAL) {
102
+ if (errno == EINVAL || errno == EPERM || errno == EACCES) {
103
103
  if (!__fname)
104
104
  unlink(fname);
105
105
  return T_EXIT_SKIP;
@@ -128,6 +128,7 @@ static int test_file(struct io_uring *ring, char *__fname)
128
128
  if (ret != 1) {
129
129
  fprintf(stderr, "unexpected wait ret %d\n", ret);
130
130
  close(fd);
131
+ free(buf);
131
132
  return T_EXIT_FAIL;
132
133
  }
133
134
 
@@ -141,10 +142,12 @@ static int test_file(struct io_uring *ring, char *__fname)
141
142
  if (i != 1) {
142
143
  fprintf(stderr, "Got %d request, expected 1\n", i);
143
144
  close(fd);
145
+ free(buf);
144
146
  return T_EXIT_FAIL;
145
147
  }
146
148
 
147
149
  close(fd);
150
+ free(buf);
148
151
  return T_EXIT_PASS;
149
152
  }
150
153
 
@@ -96,7 +96,7 @@ static int test_canceled_userdata(struct io_uring *ring)
96
96
  if (init_context(&ctx, ring, nr, OP_NOP))
97
97
  return 1;
98
98
 
99
- for (i = 0; i < nr; i++)
99
+ for (i = 0; i < nr - 1; i++)
100
100
  ctx.sqes[i]->flags |= IOSQE_IO_LINK;
101
101
 
102
102
  ret = io_uring_submit(ring);
@@ -130,7 +130,7 @@ static int test_thread_link_cancel(struct io_uring *ring)
130
130
  if (init_context(&ctx, ring, nr, OP_REMOVE_BUFFERS))
131
131
  return 1;
132
132
 
133
- for (i = 0; i < nr; i++)
133
+ for (i = 0; i < nr - 1; i++)
134
134
  ctx.sqes[i]->flags |= IOSQE_IO_LINK;
135
135
 
136
136
  ret = io_uring_submit(ring);
@@ -114,7 +114,7 @@ static uint64_t r[4] = {0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff};
114
114
  int main(int argc, char *argv[])
115
115
  {
116
116
  void *mmap_ret;
117
- #if !defined(__i386) && !defined(__x86_64__)
117
+ #if (!defined(__i386) && !defined(__x86_64__)) || defined(CONFIG_USE_SANITIZER)
118
118
  return T_EXIT_SKIP;
119
119
  #endif
120
120
 
@@ -113,8 +113,10 @@ int main(int argc, char *argv[])
113
113
  }
114
114
 
115
115
  close(fd);
116
+ free(iov.iov_base);
116
117
  return ret;
117
118
  err:
118
119
  close(fd);
120
+ free(iov.iov_base);
119
121
  return T_EXIT_FAIL;
120
122
  }
@@ -60,7 +60,6 @@ int main(int argc, char *argv[])
60
60
 
61
61
  sqe = io_uring_get_sqe(&ring);
62
62
  io_uring_prep_readv(sqe, evfd, &vec, 1, 0);
63
- sqe->flags |= IOSQE_IO_LINK;
64
63
  sqe->user_data = 2;
65
64
 
66
65
  ret = io_uring_submit(&ring);
@@ -19,6 +19,11 @@
19
19
  #include "liburing.h"
20
20
  #include "helpers.h"
21
21
 
22
+ // on fast enough machines with enough cores, the first few threads will post
23
+ // enough sem's to cause the main thread to exit while some threads are half way
24
+ // initialization. This causes a null deference somewhere in thread cleanup,
25
+ // which trips ASAN.
26
+ #ifndef CONFIG_USE_SANITIZER
22
27
  #define IORING_ENTRIES 8
23
28
 
24
29
  static pthread_t *threads;
@@ -115,3 +120,9 @@ int main(int argc, char *argv[])
115
120
  // Exit without resource cleanup
116
121
  exit(EXIT_SUCCESS);
117
122
  }
123
+ #else
124
+ int main(int argc, char *argv[])
125
+ {
126
+ return T_EXIT_SKIP;
127
+ }
128
+ #endif
@@ -18,30 +18,6 @@
18
18
  #define LOOPS 100
19
19
  #define MIN_LOOPS 10
20
20
 
21
- static unsigned long long utime_since(const struct timeval *s,
22
- const struct timeval *e)
23
- {
24
- long long sec, usec;
25
-
26
- sec = e->tv_sec - s->tv_sec;
27
- usec = (e->tv_usec - s->tv_usec);
28
- if (sec > 0 && usec < 0) {
29
- sec--;
30
- usec += 1000000;
31
- }
32
-
33
- sec *= 1000000;
34
- return sec + usec;
35
- }
36
-
37
- static unsigned long long utime_since_now(struct timeval *tv)
38
- {
39
- struct timeval end;
40
-
41
- gettimeofday(&end, NULL);
42
- return utime_since(tv, &end);
43
- }
44
-
45
21
  static int do_fadvise(struct io_uring *ring, int fd, off_t offset, off_t len,
46
22
  int advice)
47
23
  {
@@ -92,7 +68,7 @@ static long do_read(int fd, char *buf)
92
68
  perror("lseek");
93
69
  return -1;
94
70
  }
95
-
71
+
96
72
  gettimeofday(&tv, NULL);
97
73
  ret = read(fd, buf, FILE_SIZE);
98
74
  t = utime_since_now(&tv);
@@ -115,6 +91,8 @@ static int test_fadvise(struct io_uring *ring, const char *filename)
115
91
 
116
92
  fd = open(filename, O_RDONLY);
117
93
  if (fd < 0) {
94
+ if (errno == EPERM || errno == EACCES)
95
+ return T_EXIT_SKIP;
118
96
  perror("open");
119
97
  return 1;
120
98
  }
@@ -148,9 +126,12 @@ static int test_fadvise(struct io_uring *ring, const char *filename)
148
126
  return 1;
149
127
 
150
128
  if (cached_read < uncached_read &&
151
- cached_read2 < uncached_read)
129
+ cached_read2 < uncached_read) {
130
+ free(buf);
152
131
  return 0;
132
+ }
153
133
 
134
+ free(buf);
154
135
  return 2;
155
136
  }
156
137
 
@@ -174,6 +155,8 @@ int main(int argc, char *argv[])
174
155
  good = bad = 0;
175
156
  for (i = 0; i < LOOPS; i++) {
176
157
  ret = test_fadvise(&ring, fname);
158
+ if (ret == T_EXIT_SKIP)
159
+ return T_EXIT_SKIP;
177
160
  if (ret == 1) {
178
161
  fprintf(stderr, "read_fadvise failed\n");
179
162
  goto err;
@@ -80,7 +80,7 @@ static int __test_io(const char *file, struct io_uring *ring, int write,
80
80
  if (fixed) {
81
81
  ret = t_register_buffers(ring, vecs, BUFFERS);
82
82
  if (ret == T_SETUP_SKIP)
83
- return 0;
83
+ return T_EXIT_SKIP;
84
84
  if (ret != T_SETUP_OK) {
85
85
  fprintf(stderr, "buffer reg failed: %d\n", ret);
86
86
  goto err;
@@ -91,6 +91,8 @@ static int __test_io(const char *file, struct io_uring *ring, int write,
91
91
  if (fd < 0) {
92
92
  if (errno == EINVAL)
93
93
  return 0;
94
+ if (errno == EPERM || errno == EACCES)
95
+ return T_EXIT_SKIP;
94
96
  perror("file open");
95
97
  goto err;
96
98
  }
@@ -290,6 +292,7 @@ static int has_nonvec_read(void)
290
292
  if (ret == -EINVAL) {
291
293
  out:
292
294
  io_uring_queue_exit(&ring);
295
+ free(p);
293
296
  return 0;
294
297
  } else if (ret) {
295
298
  fprintf(stderr, "register_probe: %d\n", ret);
@@ -301,6 +304,7 @@ out:
301
304
  if (!(p->ops[IORING_OP_READ].flags & IO_URING_OP_SUPPORTED))
302
305
  goto out;
303
306
  io_uring_queue_exit(&ring);
307
+ free(p);
304
308
  return 1;
305
309
  }
306
310
 
@@ -318,6 +322,8 @@ static int test_eventfd_read(int flags)
318
322
  if (ret == T_SETUP_SKIP)
319
323
  return 0;
320
324
  if (ret != T_SETUP_OK) {
325
+ if (ret == -EINVAL)
326
+ return 0;
321
327
  fprintf(stderr, "ring create failed: %d\n", ret);
322
328
  return 1;
323
329
  }
@@ -384,6 +390,8 @@ int main(int argc, char *argv[])
384
390
 
385
391
  ret = test_io(fname, write, buffered, sqthread, fixed, nonvec,
386
392
  BS);
393
+ if (ret == T_EXIT_SKIP)
394
+ continue;
387
395
  if (ret) {
388
396
  fprintf(stderr, "test_io failed %d/%d/%d/%d/%d\n",
389
397
  write, buffered, sqthread, fixed, nonvec);
@@ -120,16 +120,21 @@ static int test_grow(struct io_uring *ring)
120
120
  fds = open_files(1, 0, off);
121
121
  ret = io_uring_register_files_update(ring, off, fds, 1);
122
122
  if (ret != 1) {
123
- if (off == 300 && ret == -EINVAL)
123
+ if (off == 300 && ret == -EINVAL) {
124
+ free(fds);
124
125
  break;
126
+ }
125
127
  fprintf(stderr, "%s: update ret=%d\n", __FUNCTION__, ret);
128
+ free(fds);
126
129
  break;
127
130
  }
128
131
  if (off >= 300) {
129
132
  fprintf(stderr, "%s: Succeeded beyond end-of-list?\n", __FUNCTION__);
133
+ free(fds);
130
134
  goto err;
131
135
  }
132
136
  off++;
137
+ free(fds);
133
138
  } while (1);
134
139
 
135
140
  ret = io_uring_unregister_files(ring);
@@ -363,8 +368,10 @@ static int test_basic(struct io_uring *ring, int fail)
363
368
  ret = io_uring_register_files(ring, files, 100);
364
369
  if (ret) {
365
370
  if (fail) {
366
- if (ret == -EBADF || ret == -EFAULT)
371
+ if (ret == -EBADF || ret == -EFAULT) {
372
+ close_files(files, nr_files, 0);
367
373
  return 0;
374
+ }
368
375
  }
369
376
  fprintf(stderr, "%s: register %d\n", __FUNCTION__, ret);
370
377
  goto err;
@@ -631,6 +638,7 @@ static int test_sparse_updates(void)
631
638
  ret = io_uring_register_files(&ring, fds, 256);
632
639
  if (ret) {
633
640
  fprintf(stderr, "file_register: %d\n", ret);
641
+ free(fds);
634
642
  return ret;
635
643
  }
636
644
 
@@ -639,6 +647,7 @@ static int test_sparse_updates(void)
639
647
  ret = io_uring_register_files_update(&ring, i, &newfd, 1);
640
648
  if (ret != 1) {
641
649
  fprintf(stderr, "file_update: %d\n", ret);
650
+ free(fds);
642
651
  return ret;
643
652
  }
644
653
  }
@@ -650,6 +659,7 @@ static int test_sparse_updates(void)
650
659
  ret = io_uring_register_files(&ring, fds, 256);
651
660
  if (ret) {
652
661
  fprintf(stderr, "file_register: %d\n", ret);
662
+ free(fds);
653
663
  return ret;
654
664
  }
655
665
 
@@ -658,12 +668,14 @@ static int test_sparse_updates(void)
658
668
  ret = io_uring_register_files_update(&ring, i, &newfd, 1);
659
669
  if (ret != 1) {
660
670
  fprintf(stderr, "file_update: %d\n", ret);
671
+ free(fds);
661
672
  return ret;
662
673
  }
663
674
  }
664
675
  io_uring_unregister_files(&ring);
665
676
 
666
677
  io_uring_queue_exit(&ring);
678
+ free(fds);
667
679
  return 0;
668
680
  }
669
681
 
@@ -174,7 +174,7 @@ static int test_update_no_table(void)
174
174
  ret = cqe->res;
175
175
  io_uring_cqe_seen(&ring, cqe);
176
176
  if (ret != -EMFILE && ret != -EINVAL && ret != -EOVERFLOW &&
177
- ret != -ENXIO) {
177
+ ret != -ENXIO && ret != -EBADF) {
178
178
  fprintf(stderr, "Bad cqe res: %d\n", ret);
179
179
  goto fail;
180
180
  }