Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Io uring libtevent #341

Open
wants to merge 5 commits into
base: SCALE-v4-19-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Build-Depends: bison,
docbook-xsl,
flex,
libacl1-dev,
libaio1,
libaio-dev,
libarchive-dev,
libblkid-dev,
libbsd-dev,
Expand Down Expand Up @@ -61,6 +63,7 @@ Package: truenas-samba
Architecture: any
Pre-Depends: dpkg (>= 1.15.6~), ${misc:Pre-Depends}
Depends: adduser,
libaio1,
libpam-modules,
libpam-runtime (>= 1.0.1-11),
lsb-base (>= 4.1+Debian),
Expand Down
40 changes: 22 additions & 18 deletions lib/tevent/testsuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
#endif
#ifdef HAVE_KQUEUE
#include "tevent_kqueue.h"
#endif
#else
#include "tevent_libaio.h"
#endif /* HAVE_KQUEUE */


static struct tevent_context *
Expand Down Expand Up @@ -1960,7 +1962,6 @@ static bool test_cached_pid(struct torture_context *test,
return true;
}

#ifdef HAVE_KQUEUE
static bool aio_recv(struct torture_context *test, struct tevent_req *req)
{
struct tevent_aiocb *taiocbp = NULL;
Expand All @@ -1979,18 +1980,17 @@ static bool aio_pread_send(struct torture_context *test,
int ret;
struct tevent_req *req = NULL;
struct tevent_aiocb *taiocbp = NULL;
struct aiocb *iocbp = NULL;
iocb_t *iocbp = NULL;

req = tevent_req_create(test, &taiocbp, struct tevent_aiocb);
torture_assert(test, req != NULL, "tevent_req_create()");
taiocbp->ev = ev;
taiocbp->req = req;

iocbp = tevent_ctx_get_iocb(taiocbp);
iocbp->aio_fildes = fd;
iocbp->aio_offset = offset;
iocbp->aio_buf = data;
iocbp->aio_nbytes = n;
torture_assert(test, iocbp != NULL, "tevent_ctx_get_iocb()");

tio_prep_pread(iocbp, fd, data, n, offset);

ret = tevent_add_aio_read(taiocbp);
torture_assert(test, ret != -1, "aio_pread_send()");
Expand All @@ -2008,18 +2008,17 @@ static bool aio_pwrite_send(struct torture_context *test,
int ret;
struct tevent_req *req = NULL;
struct tevent_aiocb *taiocbp = NULL;
struct aiocb *iocbp = NULL;
iocb_t *iocbp = NULL;

req = tevent_req_create(test, &taiocbp, struct tevent_aiocb);
torture_assert(test, req != NULL, "tevent_req_create()");
taiocbp->ev = ev;
taiocbp->req = req;

iocbp = tevent_ctx_get_iocb(taiocbp);
iocbp->aio_fildes = fd;
iocbp->aio_offset = offset;
iocbp->aio_buf = data;
iocbp->aio_nbytes = n;
torture_assert(test, iocbp != NULL, "tevent_ctx_get_iocb()");

tio_prep_pwrite(iocbp, fd, data, n, offset);

ret = tevent_add_aio_write(taiocbp);
torture_assert(test, ret != -1, "aio_write_send()");
Expand All @@ -2035,15 +2034,17 @@ static bool aio_fsync_send(struct torture_context *test,
int ret;
struct tevent_req *req = NULL;
struct tevent_aiocb *taiocbp = NULL;
struct aiocb *iocbp = NULL;
iocb_t *iocbp = NULL;

req = tevent_req_create(test, &taiocbp, struct tevent_aiocb);
torture_assert(test, req != NULL, "tevent_req_create()");
taiocbp->ev = ev;
taiocbp->req = req;

iocbp = tevent_ctx_get_iocb(taiocbp);
iocbp->aio_fildes = fd;
torture_assert(test, iocbp != NULL, "tevent_ctx_get_iocb()");

tio_prep_fsync(iocbp, fd);

ret = tevent_add_aio_fsync(taiocbp);
torture_assert(test, ret != -1, "aio_write_send()");
Expand Down Expand Up @@ -2119,18 +2120,21 @@ static bool test_event_kqueue_aio_fsync_cancel(struct torture_context *test,
torture_assert(test, fd != -1, "open() failed");

for (i = 0; i < INFLIGHT_REQ; i++) {
torture_comment(test, "fsync_cancel %d\n", i);
struct tevent_req *req = NULL;
ok = aio_fsync_send(test, ev_ctx, fd, &req);
torture_assert(test, ok, "aio_fsync_send() failed");
TALLOC_FREE(req);
}

torture_comment(test, "fsync_cancel complete\n");
if (tevent_loop_once(ev_ctx) == -1) {
TALLOC_FREE(ev_ctx);
torture_fail(test, talloc_asprintf(test, "Failed event loop %s\n", strerror(errno)));
TALLOC_FREE(ev_ctx);
return false;
}

torture_comment(test, "preparing to free event context\n");
TALLOC_FREE(ev_ctx);
return true;
}
Expand All @@ -2154,18 +2158,21 @@ static bool test_event_kqueue_aio_pread_cancel(struct torture_context *test,
torture_assert(test, fd != -1, "open() failed");

for (i = 0; i < INFLIGHT_REQ; i++) {
torture_comment(test, "pread_cancel %d\n", i);
struct tevent_req *req = NULL;
ok = aio_fsync_send(test, ev_ctx, fd, &req);
torture_assert(test, ok, "aio_fsync_send() failed");
TALLOC_FREE(req);
}

torture_comment(test, "pread_cancel complete\n");
if (tevent_loop_once(ev_ctx) == -1) {
TALLOC_FREE(ev_ctx);
torture_fail(test, talloc_asprintf(test, "Failed event loop %s\n", strerror(errno)));
return false;
}

torture_comment(test, "preparing to free event context\n");
TALLOC_FREE(ev_ctx);
return true;
}
Expand Down Expand Up @@ -2203,7 +2210,6 @@ static bool test_event_kqueue_aio_pwrite_cancel(struct torture_context *test,
TALLOC_FREE(ev_ctx);
return true;
}
#endif

struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx)
{
Expand Down Expand Up @@ -2278,7 +2284,6 @@ struct torture_suite *torture_local_event_aio(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "event_aio");

#ifdef HAVE_KQUEUE
torture_suite_add_simple_tcase_const(suite,
"basic_kqueue_aio",
test_event_kqueue_aio,
Expand All @@ -2298,6 +2303,5 @@ struct torture_suite *torture_local_event_aio(TALLOC_CTX *mem_ctx)
"aio_write_cancel_destructor",
test_event_kqueue_aio_pwrite_cancel,
NULL);
#endif /* HAVE_KQUEUE */
return suite;
}
Loading