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