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
16 #define BLKIO_FOC 0x10
18 #define BLKIO_SCHED_IDEL 0x1
22 typedef void (*blkio_cb)(struct blkio_req*);
23 typedef void (*req_handler)(struct blkio_req*);
27 struct llist_header reqs;
28 struct blkio_context* io_ctx;
40 struct llist_header queue;
46 req_handler handle_one;
56 * @brief Vectorized read request
63 * @return struct blkio_req*
66 blkio_vrd(struct vecbuf* vbuf,
73 * @brief Vectorized write request
80 * @return struct blkio_req*
83 blkio_vwr(struct vecbuf* vbuf,
90 blkio_free_req(struct blkio_req* req);
93 * @brief Commit an IO request to scheduler.
99 blkio_commit(struct blkio_context* ctx, struct blkio_req* req);
102 * @brief Schedule an IO request to be handled.
107 blkio_schedule(struct blkio_context* ctx);
110 * @brief Notify the scheduler when request is completed, either successful or
117 blkio_complete(struct blkio_req* req);
120 * @brief Create a new block IO scheduling context
122 * @param handler Handler to handle request
123 * @return struct blkio_context*
125 struct blkio_context*
126 blkio_newctx(req_handler handler);
128 #endif /* __LUNAIX_BLKIO_H */