MCPcopy Create free account
hub / github.com/axboe/liburing / __test_io

Function __test_io

test/iopoll.c:58–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static int __test_io(const char *file, struct io_uring *ring, int write, int sqthread,
59 int fixed, int buf_select)
60{
61 struct io_uring_sqe *sqe;
62 struct io_uring_cqe *cqe;
63 int open_flags;
64 int i, fd = -1, ret;
65 off_t offset;
66
67 if (buf_select) {
68 write = 0;
69 fixed = 0;
70 }
71 if (buf_select && provide_buffers(ring))
72 return 1;
73
74 if (write)
75 open_flags = O_WRONLY;
76 else
77 open_flags = O_RDONLY;
78 open_flags |= O_DIRECT;
79
80 if (fixed) {
81 ret = t_register_buffers(ring, vecs, BUFFERS);
82 if (ret == T_SETUP_SKIP)
83 return 0;
84 if (ret != T_SETUP_OK) {
85 fprintf(stderr, "buffer reg failed: %d\n", ret);
86 goto err;
87 }
88 }
89 fd = open(file, open_flags);
90 if (fd < 0) {
91 if (errno == EINVAL || errno == EPERM || errno == EACCES)
92 return 0;
93 perror("file open");
94 goto err;
95 }
96 if (sqthread) {
97 ret = io_uring_register_files(ring, &fd, 1);
98 if (ret) {
99 fprintf(stderr, "file reg failed: %d\n", ret);
100 goto err;
101 }
102 }
103
104 offset = 0;
105 for (i = 0; i < BUFFERS; i++) {
106 sqe = io_uring_get_sqe(ring);
107 if (!sqe) {
108 fprintf(stderr, "sqe get failed\n");
109 goto err;
110 }
111 offset = BS * (rand() % BUFFERS);
112 if (write) {
113 int do_fixed = fixed;
114 int use_fd = fd;
115

Callers 1

test_ioFunction · 0.70

Calls 7

t_register_buffersFunction · 0.85
io_uring_register_filesFunction · 0.85
io_uring_submitFunction · 0.85
provide_buffersFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by 1

test_ioFunction · 0.56