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

Function do_punch

test/file-verify.c:254–289  ·  view source on GitHub ↗

* For each chunk in file, DONTNEED a start, end, or middle segment of it. * We enter here with the file fully cached every time, either freshly * written or after other reads. This forces (at least) the buffered reads * to be handled incrementally, exercising that path. */

Source from the content-addressed store, hash-verified

252 * to be handled incrementally, exercising that path.
253 */
254static int do_punch(int fd)
255{
256 off_t offset = 0;
257 int punch_type;
258
259 while (offset + CHUNK_SIZE <= FSIZE) {
260 off_t punch_off;
261
262 punch_type = rand() % (PUNCH_END + 1);
263 switch (punch_type) {
264 default:
265 case PUNCH_NONE:
266 punch_off = -1; /* gcc... */
267 break;
268 case PUNCH_FRONT:
269 punch_off = offset;
270 break;
271 case PUNCH_MIDDLE:
272 punch_off = offset + PUNCH_SIZE;
273 break;
274 case PUNCH_END:
275 punch_off = offset + CHUNK_SIZE - PUNCH_SIZE;
276 break;
277 }
278
279 offset += CHUNK_SIZE;
280 if (punch_type == PUNCH_NONE)
281 continue;
282 if (posix_fadvise(fd, punch_off, PUNCH_SIZE, POSIX_FADV_DONTNEED) < 0) {
283 perror("posix_fadivse");
284 return 1;
285 }
286 }
287
288 return 0;
289}
290
291static int provide_buffers(struct io_uring *ring, void **buf)
292{

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected