From 881be872675e4cff153c27c641980451c4a3f479 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 14 Jul 2024 19:40:31 +0200 Subject: kernel: make the adhoc VfsQueue queues use ReqQueue instead I'm still not sure if I should use sys/queue.h for this. But yeah, this is more consistent, and it will also let me switch over to O(1) insertions later on. --- src/kernel/vfs/request.h | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'src/kernel/vfs/request.h') diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h index 616c044..6786e72 100644 --- a/src/kernel/vfs/request.h +++ b/src/kernel/vfs/request.h @@ -4,6 +4,10 @@ #include #include +struct ReqQueue { + VfsReq *head; +}; + struct VfsBackend { /* amount of using references * VfsMount @@ -11,17 +15,15 @@ struct VfsBackend { * Handle * once it reaches 0, it'll never increase */ size_t usehcnt; /* VfsMount */ - /* amount of providing references - * Proc - * 0 - orphaned, will never increase */ - // TODO move this into .user - size_t provhcnt; - VfsReq *queue; bool is_user; union { struct { Proc *handler; + ReqQueue queue; /* kernel backends keep their own queues */ + /* amount of processes that control this backend + * won't ever increase if it becomes 0 */ + size_t provhcnt; } user; struct { void (*accept)(VfsReq *); @@ -56,10 +58,7 @@ struct VfsReq { Proc *caller; VfsBackend *backend; - VfsReq *queue_next; - VfsReq *postqueue_next; /* used by kernel backends */ - /* only one of these queues is in use at a given moment, they could - * be merged into a single field */ + VfsReq *reqqueue_next; }; /** Assigns the vfs_request to the caller, and dispatches the call */ @@ -79,13 +78,10 @@ void vfsback_userdown(VfsBackend *); /** Decrements the "provider" reference count. */ void vfsback_provdown(VfsBackend *); -struct ReqQueue { - VfsReq *head; -}; -void postqueue_init(ReqQueue *q); -void postqueue_join(ReqQueue *q, VfsReq *req); -VfsReq *postqueue_pop(ReqQueue *q); +void reqqueue_init(ReqQueue *q); +void reqqueue_join(ReqQueue *q, VfsReq *req); +VfsReq *reqqueue_pop(ReqQueue *q); -/** If there are any pending read requests, and the ring buffer isn't empty, fulfill them - * all with a single read. */ -void postqueue_ringreadall(ReqQueue *q, ring_t *r); +/** If there are any pending read requests, and the ring buffer isn't empty, + * fulfill them all with a single read. */ +void reqqueue_ringreadall(ReqQueue *q, ring_t *r); -- cgit v1.2.3