summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-19 13:46:54 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-20 14:26:09 -0400
commit4889f3ebb59c926b8e53a2e12edd5009d7cd4cbe (patch)
tree3db9a5d6103aee648a0f04500cd9cbc276c62be8 /src
parent4b177a01a7f4e83f67af2200ec69505b75a3c399 (diff)
downloadbfs-4889f3ebb59c926b8e53a2e12edd5009d7cd4cbe.tar.xz
ioq: Arena-allocate ioq_cmd
Diffstat (limited to 'src')
-rw-r--r--src/ioq.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ioq.c b/src/ioq.c
index 3e304ce..33316fa 100644
--- a/src/ioq.c
+++ b/src/ioq.c
@@ -266,6 +266,9 @@ struct ioq {
/** The current size of the queue. */
size_t size;
+ /** ioq_cmd command arena. */
+ struct arena cmds;
+
/** Pending I/O requests. */
struct ioqq *pending;
/** Ready I/O responses. */
@@ -311,6 +314,7 @@ struct ioq *ioq_create(size_t depth, size_t nthreads) {
}
ioq->depth = depth;
+ ARENA_INIT(&ioq->cmds, union ioq_cmd);
ioq->pending = ioqq_create(depth);
if (!ioq->pending) {
@@ -345,7 +349,7 @@ int ioq_opendir(struct ioq *ioq, int dfd, const char *path, void *ptr) {
return -1;
}
- union ioq_cmd *cmd = ALLOC(union ioq_cmd);
+ union ioq_cmd *cmd = arena_alloc(&ioq->cmds);
if (!cmd) {
return -1;
}
@@ -385,8 +389,7 @@ struct ioq_res *ioq_trypop(struct ioq *ioq) {
}
void ioq_free(struct ioq *ioq, struct ioq_res *res) {
- union ioq_cmd *cmd = (union ioq_cmd *)res;
- free(cmd);
+ arena_free(&ioq->cmds, (union ioq_cmd *)res);
}
void ioq_destroy(struct ioq *ioq) {
@@ -407,5 +410,7 @@ void ioq_destroy(struct ioq *ioq) {
ioqq_destroy(ioq->ready);
ioqq_destroy(ioq->pending);
+ arena_destroy(&ioq->cmds);
+
free(ioq);
}