1 #ifndef __LUNAIX_BLKIO_H
2 #define __LUNAIX_BLKIO_H
4 #include <lunaix/buffer.h>
5 #include <lunaix/ds/llist.h>
6 #include <lunaix/ds/waitq.h>
7 #include <lunaix/types.h>
9 #define BLKIO_WRITE 0x1
10 #define BLKIO_ERROR 0x2
12 #define BLKIO_BUSY 0x4
13 #define BLKIO_PENDING 0x8
15 #define BLKIO_WAIT 0x1
16 #define BLKIO_NOASYNC 0x2
19 #define BLKIO_FOC 0x10
21 #define BLKIO_SCHED_IDEL 0x1
25 typedef void (*blkio_cb)(struct blkio_req*);
26 typedef void (*req_handler)(struct blkio_req*);
30 struct llist_header reqs;
31 struct blkio_context* io_ctx;
43 struct llist_header queue;
49 req_handler handle_one;
59 * @brief Vectorized read request
66 * @return struct blkio_req*
69 blkio_vrd(struct vecbuf* vbuf,
76 * @brief Vectorized write request
83 * @return struct blkio_req*
86 blkio_vwr(struct vecbuf* vbuf,
93 blkio_free_req(struct blkio_req* req);
96 * @brief Commit an IO request to scheduler.
102 blkio_commit(struct blkio_context* ctx, struct blkio_req* req, int options);
105 * @brief Schedule an IO request to be handled.
110 blkio_schedule(struct blkio_context* ctx);
113 * @brief Notify the scheduler when request is completed, either successful or
120 blkio_complete(struct blkio_req* req);
123 * @brief Create a new block IO scheduling context
125 * @param handler Handler to handle request
126 * @return struct blkio_context*
128 struct blkio_context*
129 blkio_newctx(req_handler handler);
131 #endif /* __LUNAIX_BLKIO_H */