2 * UCW Library -- Asynchronous I/O
4 * (c) 2006 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
13 #include <ucw/workqueue.h>
14 #include <ucw/clists.h>
16 #ifdef CONFIG_UCW_CLEAN_ABI
17 #define asio_cleanup_queue ucw_asio_cleanup_queue
18 #define asio_get ucw_asio_get
19 #define asio_init_queue ucw_asio_init_queue
20 #define asio_put ucw_asio_put
21 #define asio_submit ucw_asio_submit
22 #define asio_sync ucw_asio_sync
23 #define asio_wait ucw_asio_wait
27 * This module takes care of scheduling and executing asynchronous I/O requests
28 * on files opened with O_DIRECT. It is primarily used by the fb-direct fastbuf
29 * back-end, but you can use it explicitly, too.
31 * You can define several I/O queues, each for use by a single thread. Requests
32 * on a single queue are always processed in order of their submits, requests
33 * from different queues may be interleaved (although the current implementation
34 * does not do so). Normal read and write requests are returned to their queue
35 * when they are completed. Write-back requests are automatically freed when
36 * done, but the number of such requests in fly is limited in order to avoid
37 * consuming all memory, so a submit of a write-back request can block.
41 uns buffer_size; // How large buffers do we use [user-settable]
42 uns max_writebacks; // Maximum number of writeback requests active [user-settable]
43 uns allocated_requests;
44 uns running_requests; // Total number of running requests
45 uns running_writebacks; // How many of them are writebacks
46 clist idle_list; // Recycled requests waiting for get
47 clist done_list; // Finished requests
48 struct work_queue queue;
49 uns use_count; // For use by the caller
56 ASIO_WRITE_BACK, // Background write with no success notification
60 struct work work; // asio_requests are internally just work nodes
61 struct asio_queue *queue;
69 void *user_data; // For use by the caller
72 void asio_init_queue(struct asio_queue *q); // Initialize a new queue
73 void asio_cleanup_queue(struct asio_queue *q);
74 struct asio_request *asio_get(struct asio_queue *q); // Get an empty request
75 void asio_submit(struct asio_request *r); // Submit the request (can block if too many writebacks)
76 struct asio_request *asio_wait(struct asio_queue *q); // Wait for the first finished request, NULL if no more
77 void asio_put(struct asio_request *r); // Return a finished request for recycling
78 void asio_sync(struct asio_queue *q); // Wait until all requests are finished
80 #endif /* !_UCW_ASIO_H */