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