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

Function copy_file

examples/link-cp.c:110–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110static int copy_file(struct io_uring *ring, off_t insize)
111{
112 struct io_uring_cqe *cqe;
113 off_t this_size;
114 off_t offset;
115
116 offset = 0;
117 while (insize) {
118 int has_inflight = inflight;
119 int depth;
120
121 while (insize && inflight < QD) {
122 this_size = BS;
123 if (this_size > insize)
124 this_size = insize;
125 queue_rw_pair(ring, this_size, offset);
126 offset += this_size;
127 insize -= this_size;
128 inflight += 2;
129 }
130
131 if (has_inflight != inflight)
132 io_uring_submit(ring);
133
134 if (insize)
135 depth = QD;
136 else
137 depth = 1;
138 while (inflight >= depth) {
139 int ret;
140
141 ret = io_uring_wait_cqe(ring, &cqe);
142 if (ret < 0) {
143 printf("wait cqe: %s\n", strerror(-ret));
144 return 1;
145 }
146 if (handle_cqe(ring, cqe))
147 return 1;
148 inflight--;
149 }
150 }
151
152 return 0;
153}
154
155int main(int argc, char *argv[])
156{

Callers 1

mainFunction · 0.70

Calls 3

queue_rw_pairFunction · 0.85
io_uring_submitFunction · 0.85
handle_cqeFunction · 0.70

Tested by

no test coverage detected