fix: (blkio) enforce disk io buffer size alignment (to block size)
[lunaix-os.git] / lunaix-os / kernel / block / blkio.c
index 44531c4091636ef09309db1e6dc59135b553d767..c5d688f633990b7de08ac982bdc93f80af570a58 100644 (file)
@@ -24,6 +24,7 @@ __blkio_req_create(struct vecbuf* buffer,
                                 .flags = options,
                                 .evt_args = evt_args };
     breq->vbuf = buffer;
+    waitq_init(&breq->wait);
     return breq;
 }
 
@@ -76,7 +77,7 @@ blkio_commit(struct blkio_context* ctx, struct blkio_req* req)
     llist_append(&ctx->queue, &req->reqs);
 
     // if the pipeline is not running (e.g., stalling). Then we should schedule
-    // one immediately and kick it start.
+    // one immediately and kick it started.
     if (!ctx->busy) {
         blkio_schedule(ctx);
     }
@@ -102,14 +103,19 @@ void
 blkio_complete(struct blkio_req* req)
 {
     req->flags &= ~(BLKIO_BUSY | BLKIO_PENDING);
+
     if (req->completed) {
         req->completed(req);
     }
+
+    // FIXME Not working in first process! Need a dummy process.
+    // Wake all blocked processes on completion,
+    //  albeit should be no more than one process in everycase (by design)
+    pwake_all(&req->wait);
+
     if ((req->flags & BLKIO_FOC)) {
         blkio_free_req(req);
     }
 
     req->io_ctx->busy--;
-
-    blkio_schedule(req->io_ctx);
 }
\ No newline at end of file