diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-02-15 12:46:23 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-02-15 12:46:23 -0500 |
commit | 71cffe72d83dd3ba31198d66a97cea83ba6b352e (patch) | |
tree | 34b97db27d803971bf8e47f8fd9682c39d888f87 | |
parent | 08e23800dcccc0bc302dabc18ba5f5b8f78c846d (diff) | |
download | bfs-71cffe72d83dd3ba31198d66a97cea83ba6b352e.tar.xz |
ioq: Don't push immediately in ioq_check_cancel()
-rw-r--r-- | src/ioq.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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); } } |