From 71cffe72d83dd3ba31198d66a97cea83ba6b352e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 15 Feb 2024 12:46:23 -0500 Subject: ioq: Don't push immediately in ioq_check_cancel() --- src/ioq.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ioq.c b/src/ioq.c index 2558d62..b57daba 100644 --- a/src/ioq.c +++ b/src/ioq.c @@ -446,7 +446,6 @@ static bool ioq_check_cancel(struct ioq *ioq, struct ioq_ent *ent) { } ent->result = -EINTR; - ioqq_push(ioq->ready, ent); return true; } @@ -481,12 +480,6 @@ static void ioq_dispatch_sync(struct ioq *ioq, struct ioq_ent *ent) { ent->result = -ENOSYS; } -/** Complete a single request synchronously. */ -static void ioq_complete(struct ioq *ioq, struct ioq_ent *ent) { - ioq_dispatch_sync(ioq, ent); - ioqq_push(ioq->ready, ent); -} - #if BFS_USE_LIBURING /** io_uring worker state. */ @@ -568,6 +561,7 @@ static struct io_uring_sqe *ioq_dispatch_async(struct io_uring *ring, struct ioq static void ioq_prep_sqe(struct ioq_ring_state *state, struct ioq_ent *ent) { struct ioq *ioq = state->ioq; if (ioq_check_cancel(ioq, ent)) { + ioqq_push(ioq->ready, ent); return; } @@ -576,7 +570,8 @@ static void ioq_prep_sqe(struct ioq_ring_state *state, struct ioq_ent *ent) { io_uring_sqe_set_data(sqe, ent); ++state->prepped; } else { - ioq_complete(ioq, ent); + ioq_dispatch_sync(ioq, ent); + ioqq_push(ioq->ready, ent); } } @@ -615,7 +610,7 @@ static void ioq_reap_cqe(struct ioq_ring_state *state, struct io_uring_cqe *cqe) int fd = ent->result; if (ioq_check_cancel(ioq, ent)) { xclose(fd); - return; + goto push; } struct ioq_opendir *args = &ent->opendir; @@ -694,8 +689,9 @@ static void ioq_sync_work(struct ioq_thread *thread) { } if (!ioq_check_cancel(ioq, ent)) { - ioq_complete(ioq, ent); + ioq_dispatch_sync(ioq, ent); } + ioqq_push(ioq->ready, ent); } } -- cgit v1.2.3