summaryrefslogtreecommitdiffstats
path: root/src/ioq.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-20 12:02:08 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-20 14:26:09 -0400
commita1490d98a1aebb3bfbd3873613977d0341ec7f98 (patch)
tree1320ab9e60b30621fedf29c50d42135dac8b4a2f /src/ioq.c
parent4889f3ebb59c926b8e53a2e12edd5009d7cd4cbe (diff)
downloadbfs-a1490d98a1aebb3bfbd3873613977d0341ec7f98.tar.xz
dir: Arena-allocate directories
Diffstat (limited to 'src/ioq.c')
-rw-r--r--src/ioq.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ioq.c b/src/ioq.c
index 33316fa..47b082a 100644
--- a/src/ioq.c
+++ b/src/ioq.c
@@ -20,9 +20,11 @@
* An I/O queue request.
*/
struct ioq_req {
+ /** Directory allocation. */
+ struct bfs_dir *dir;
/** Base file descriptor for openat(). */
int dfd;
- /** Relative path to dfd. */
+ /** Path to open, relative to dfd. */
const char *path;
/** Arbitrary user data. */
@@ -295,10 +297,12 @@ static void *ioq_work(void *ptr) {
struct ioq_res *res = &cmd->res;
res->ptr = req.ptr;
- res->dir = bfs_opendir(req.dfd, req.path);
- res->error = errno;
- if (res->dir) {
+ res->dir = req.dir;
+ res->error = 0;
+ if (bfs_opendir(req.dir, req.dfd, req.path) == 0) {
bfs_polldir(res->dir);
+ } else {
+ res->error = errno;
}
ioqq_push(ioq->ready, cmd);
@@ -344,7 +348,7 @@ fail:
return NULL;
}
-int ioq_opendir(struct ioq *ioq, int dfd, const char *path, void *ptr) {
+int ioq_opendir(struct ioq *ioq, struct bfs_dir *dir, int dfd, const char *path, void *ptr) {
if (ioq->size >= ioq->depth) {
return -1;
}
@@ -355,6 +359,7 @@ int ioq_opendir(struct ioq *ioq, int dfd, const char *path, void *ptr) {
}
struct ioq_req *req = &cmd->req;
+ req->dir = dir;
req->dfd = dfd;
req->path = path;
req->ptr = ptr;