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