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
18 #define BLKIO_FOC 0x10
20 #define BLKIO_SCHED_IDEL 0x1
24 typedef void (*blkio_cb)(struct blkio_req*);
25 typedef void (*req_handler)(struct blkio_req*);
29 struct llist_header reqs;
30 struct blkio_context* io_ctx;
42 struct llist_header queue;
48 req_handler handle_one;
58 * @brief Vectorized read request
65 * @return struct blkio_req*
68 blkio_vrd(struct vecbuf* vbuf,
75 * @brief Vectorized write request
82 * @return struct blkio_req*
85 blkio_vwr(struct vecbuf* vbuf,
92 blkio_free_req(struct blkio_req* req);
95 * @brief Commit an IO request to scheduler.
101 blkio_commit(struct blkio_context* ctx, struct blkio_req* req, int options);
104 * @brief Schedule an IO request to be handled.
109 blkio_schedule(struct blkio_context* ctx);
112 * @brief Notify the scheduler when request is completed, either successful or
119 blkio_complete(struct blkio_req* req);
122 * @brief Create a new block IO scheduling context
124 * @param handler Handler to handle request
125 * @return struct blkio_context*
127 struct blkio_context*
128 blkio_newctx(req_handler handler);
130 #endif /* __LUNAIX_BLKIO_H */