]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 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 | 18 | #include "dlink.h" |
6f5dc9e4 | 19 | #include "mem/forward.h" |
02529124 | 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 | ||
3e1ef80e AJ |
59 | class squidaio_result_t |
60 | { | |
91ea1911 | 61 | public: |
3e1ef80e AJ |
62 | int aio_return = 0; |
63 | int aio_errno = 0; | |
64 | enum _squidaio_request_type result_type = _AIO_OP_NONE; | |
65 | void *_data = nullptr; /* Internal housekeeping */ | |
66 | void *data = nullptr; /* Available to the caller */ | |
cd748f27 | 67 | }; |
68 | ||
3e1ef80e AJ |
69 | class squidaio_ctrl_t |
70 | { | |
91ea1911 FC |
71 | MEMPROXY_CLASS(squidaio_ctrl_t); |
72 | public: | |
4f541701 AJ |
73 | squidaio_ctrl_t() : done_handler(NULL), free_func(NULL) {} |
74 | ||
3e1ef80e AJ |
75 | squidaio_ctrl_t *next = nullptr; |
76 | int fd = 0; | |
77 | int operation = 0; | |
4f541701 | 78 | AIOCB *done_handler; |
3e1ef80e | 79 | void *done_handler_data = nullptr; |
b9ae18aa | 80 | squidaio_result_t result; |
3e1ef80e AJ |
81 | int len = 0; |
82 | char *bufp = nullptr; | |
4f541701 | 83 | FREE *free_func; |
b9ae18aa | 84 | dlink_node node; |
85 | }; | |
cd748f27 | 86 | |
d06925a4 | 87 | void squidaio_init(void); |
88 | void squidaio_shutdown(void); | |
c04d4f40 | 89 | int squidaio_cancel(squidaio_result_t *); |
90 | int squidaio_open(const char *, int, mode_t, squidaio_result_t *); | |
ee139403 | 91 | int squidaio_read(int, char *, size_t, off_t, int, squidaio_result_t *); |
92 | int squidaio_write(int, char *, size_t, off_t, int, squidaio_result_t *); | |
c04d4f40 | 93 | int squidaio_close(int, squidaio_result_t *); |
62e76326 | 94 | |
c04d4f40 | 95 | int squidaio_stat(const char *, struct stat *, squidaio_result_t *); |
96 | int squidaio_unlink(const char *, squidaio_result_t *); | |
c04d4f40 | 97 | int squidaio_opendir(const char *, squidaio_result_t *); |
98 | squidaio_result_t *squidaio_poll_done(void); | |
99 | int squidaio_operations_pending(void); | |
100 | int squidaio_sync(void); | |
101 | int squidaio_get_queue_len(void); | |
211f1d0b | 102 | void *squidaio_xmalloc(int size); |
103 | void squidaio_xfree(void *p, int size); | |
b0465494 | 104 | void squidaio_stats(StoreEntry *); |
cd748f27 | 105 | |
106 | void aioInit(void); | |
107 | void aioDone(void); | |
a4b8110e | 108 | void aioCancel(int); |
109 | void aioOpen(const char *, int, mode_t, AIOCB *, void *); | |
cd748f27 | 110 | void aioClose(int); |
ee139403 | 111 | void aioWrite(int, off_t offset, char *, size_t size, AIOCB *, void *, FREE *); |
112 | void aioRead(int, off_t offset, size_t size, AIOCB *, void *); | |
62e76326 | 113 | |
cd748f27 | 114 | void aioStat(char *, struct stat *, AIOCB *, void *); |
115 | void aioUnlink(const char *, AIOCB *, void *); | |
a4b8110e | 116 | int aioQueueSize(void); |
cd748f27 | 117 | |
b9ae18aa | 118 | #include "DiskIO/DiskFile.h" |
d3b3ab85 | 119 | |
b9ae18aa | 120 | class DiskThreadsIOStrategy; |
62e76326 | 121 | |
3e1ef80e AJ |
122 | class AIOCounts |
123 | { | |
124 | public: | |
125 | uint64_t open_start = 0; | |
126 | uint64_t open_finish = 0; | |
127 | uint64_t close_start = 0; | |
128 | uint64_t close_finish = 0; | |
129 | uint64_t cancel = 0; | |
130 | uint64_t write_start = 0; | |
131 | uint64_t write_finish = 0; | |
132 | uint64_t read_start = 0; | |
133 | uint64_t read_finish = 0; | |
134 | uint64_t stat_start = 0; | |
135 | uint64_t stat_finish = 0; | |
136 | uint64_t unlink_start = 0; | |
137 | uint64_t unlink_finish = 0; | |
138 | uint64_t check_callback = 0; | |
d3b3ab85 | 139 | }; |
140 | ||
b9ae18aa | 141 | extern AIOCounts squidaio_counts; |
142 | extern dlink_list used_list; | |
cd748f27 | 143 | |
144 | #endif | |
f53969cc | 145 |