]>
Commit | Line | Data |
---|---|---|
cd748f27 | 1 | /* |
b9ae18aa | 2 | * DiskThreads.h |
cd748f27 | 3 | * |
b9ae18aa | 4 | * Internal declarations for the DiskThreads routines |
cd748f27 | 5 | */ |
6 | ||
b9ae18aa | 7 | #ifndef __DISKTHREADS_H__ |
8 | #define __DISKTHREADS_H__ | |
cd748f27 | 9 | |
02529124 AJ |
10 | #include "dlink.h" |
11 | #include "typedefs.h" | |
12 | ||
32d002cb | 13 | #if AUFS_IO_THREADS |
f85c88f3 | 14 | #define NUMTHREADS AUFS_IO_THREADS |
cd748f27 | 15 | #else |
55f0e6f7 | 16 | #define NUMTHREADS (Config.cacheSwap.n_configured*16) |
cd748f27 | 17 | #endif |
18 | ||
55f0e6f7 | 19 | /* Queue limit where swapouts are deferred (load calculation) */ |
20 | #define MAGIC1 (NUMTHREADS*Config.cacheSwap.n_configured*5) | |
21 | /* Queue limit where swapins are deferred (open/create fails) */ | |
22 | #define MAGIC2 (NUMTHREADS*Config.cacheSwap.n_configured*20) | |
23 | ||
24 | /* Which operations to run async */ | |
25 | #define ASYNC_OPEN 1 | |
26 | #define ASYNC_CLOSE 0 | |
27 | #define ASYNC_CREATE 1 | |
28 | #define ASYNC_WRITE 0 | |
29 | #define ASYNC_READ 1 | |
cd748f27 | 30 | |
12e137b0 | 31 | enum _squidaio_request_type { |
32 | _AIO_OP_NONE = 0, | |
33 | _AIO_OP_OPEN, | |
34 | _AIO_OP_READ, | |
35 | _AIO_OP_WRITE, | |
36 | _AIO_OP_CLOSE, | |
37 | _AIO_OP_UNLINK, | |
12e137b0 | 38 | _AIO_OP_OPENDIR, |
39 | _AIO_OP_STAT | |
40 | }; | |
41 | typedef enum _squidaio_request_type squidaio_request_type; | |
42 | ||
b9ae18aa | 43 | typedef void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno); |
44 | ||
26ac0430 | 45 | struct squidaio_result_t { |
cd748f27 | 46 | int aio_return; |
47 | int aio_errno; | |
12e137b0 | 48 | enum _squidaio_request_type result_type; |
f0debecb | 49 | void *_data; /* Internal housekeeping */ |
50 | void *data; /* Available to the caller */ | |
cd748f27 | 51 | }; |
52 | ||
26ac0430 | 53 | struct squidaio_ctrl_t { |
cd748f27 | 54 | |
b9ae18aa | 55 | struct squidaio_ctrl_t *next; |
56 | int fd; | |
57 | int operation; | |
58 | AIOCB *done_handler; | |
59 | void *done_handler_data; | |
60 | squidaio_result_t result; | |
61 | int len; | |
62 | char *bufp; | |
63 | FREE *free_func; | |
64 | dlink_node node; | |
65 | }; | |
cd748f27 | 66 | |
d06925a4 | 67 | void squidaio_init(void); |
68 | void squidaio_shutdown(void); | |
c04d4f40 | 69 | int squidaio_cancel(squidaio_result_t *); |
70 | int squidaio_open(const char *, int, mode_t, squidaio_result_t *); | |
ee139403 | 71 | int squidaio_read(int, char *, size_t, off_t, int, squidaio_result_t *); |
72 | int squidaio_write(int, char *, size_t, off_t, int, squidaio_result_t *); | |
c04d4f40 | 73 | int squidaio_close(int, squidaio_result_t *); |
62e76326 | 74 | |
c04d4f40 | 75 | int squidaio_stat(const char *, struct stat *, squidaio_result_t *); |
76 | int squidaio_unlink(const char *, squidaio_result_t *); | |
c04d4f40 | 77 | int squidaio_opendir(const char *, squidaio_result_t *); |
78 | squidaio_result_t *squidaio_poll_done(void); | |
79 | int squidaio_operations_pending(void); | |
80 | int squidaio_sync(void); | |
81 | int squidaio_get_queue_len(void); | |
211f1d0b | 82 | void *squidaio_xmalloc(int size); |
83 | void squidaio_xfree(void *p, int size); | |
b0465494 | 84 | void squidaio_stats(StoreEntry *); |
cd748f27 | 85 | |
86 | void aioInit(void); | |
87 | void aioDone(void); | |
a4b8110e | 88 | void aioCancel(int); |
89 | void aioOpen(const char *, int, mode_t, AIOCB *, void *); | |
cd748f27 | 90 | void aioClose(int); |
ee139403 | 91 | void aioWrite(int, off_t offset, char *, size_t size, AIOCB *, void *, FREE *); |
92 | void aioRead(int, off_t offset, size_t size, AIOCB *, void *); | |
62e76326 | 93 | |
cd748f27 | 94 | void aioStat(char *, struct stat *, AIOCB *, void *); |
95 | void aioUnlink(const char *, AIOCB *, void *); | |
a4b8110e | 96 | int aioQueueSize(void); |
cd748f27 | 97 | |
b9ae18aa | 98 | #include "DiskIO/DiskFile.h" |
d3b3ab85 | 99 | |
b9ae18aa | 100 | class DiskThreadsIOStrategy; |
62e76326 | 101 | |
26ac0430 | 102 | struct AIOCounts { |
b9ae18aa | 103 | int open_start; |
104 | int open_finish; | |
105 | int close_start; | |
106 | int close_finish; | |
107 | int cancel; | |
108 | int write_start; | |
109 | int write_finish; | |
110 | int read_start; | |
111 | int read_finish; | |
112 | int stat_start; | |
113 | int stat_finish; | |
114 | int unlink_start; | |
115 | int unlink_finish; | |
116 | int check_callback; | |
d3b3ab85 | 117 | }; |
118 | ||
b9ae18aa | 119 | extern AIOCounts squidaio_counts; |
120 | extern dlink_list used_list; | |
cd748f27 | 121 | |
122 | #endif |