/
githubmirror
/
libblkio
Обзор
Документация
Войти
/
githubmirror
/
libblkio
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.1.0
tests/queue-full.c
63 строки
1 KB
Stefan Hajnoczi
LICENSE: relicense to MIT OR APACHE-2.0
31 авг 2022, 18:43
31 авг 2022, 18:43
501476a
Код
Авторство
О чём код?
// SPDX-License-Identifier: (MIT OR Apache-2.0) #include "util.h" enum { TEST_FILE_SIZE = 2 * 1024 * 1024, TEST_NUM_ENTRIES = 16, MAX_COMPLETIONS = 8, // NUM_REQS is defined as such to ensure we reproduce the blkio_do_io() hang // reported in https://gitlab.com/libblkio/libblkio/-/issues/38 NUM_REQS = TEST_NUM_ENTRIES * 2 + MAX_COMPLETIONS + 1, }; static char filename[] = "queue-full-XXXXXX"; static void cleanup(void) { unlink(filename); } /* * Verify that more than num-entries requests can be added. */ int main(int argc, char **argv) { struct test_opts opts; struct blkio *b; struct blkioq *q; struct blkio_completion completions[MAX_COMPLETIONS]; int fd; parse_generic_opts(&opts, argc, argv); ok(blkio_create(opts.driver, &b)); assert(b); register_cleanup(cleanup); fd = create_file(filename, TEST_FILE_SIZE); ok(blkio_set_int(b, "fd", fd)); ok(blkio_connect(b)); fd = -1; /* ownership passed to libblkio */ ok(blkio_set_int(b, "num-queues", 1)); ok(blkio_set_int(b, "num-entries", TEST_NUM_ENTRIES)); ok(blkio_start(b)); q = blkio_get_queue(b, 0); assert(q); for (int i = 0; i < NUM_REQS; i++) { blkioq_flush(q, NULL, 0); } for (int i = 0; i < NUM_REQS; ) { int num = blkioq_do_io(q, completions, 1, MAX_COMPLETIONS, NULL); assert(num >= 1); i += num; } blkio_destroy(&b); return 0; }