]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskThreads/DiskThreads.h
Added per thread usage info in cachemgr Async IO Function Counters.
[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 #ifdef AUFS_IO_THREADS
11 #define NUMTHREADS AUFS_IO_THREADS
12 #else
13 #define NUMTHREADS (Config.cacheSwap.n_configured*16)
14 #endif
15
16 /* Queue limit where swapouts are deferred (load calculation) */
17 #define MAGIC1 (NUMTHREADS*Config.cacheSwap.n_configured*5)
18 /* Queue limit where swapins are deferred (open/create fails) */
19 #define MAGIC2 (NUMTHREADS*Config.cacheSwap.n_configured*20)
20
21 /* Which operations to run async */
22 #define ASYNC_OPEN 1
23 #define ASYNC_CLOSE 0
24 #define ASYNC_CREATE 1
25 #define ASYNC_WRITE 0
26 #define ASYNC_READ 1
27
28 enum _squidaio_request_type {
29 _AIO_OP_NONE = 0,
30 _AIO_OP_OPEN,
31 _AIO_OP_READ,
32 _AIO_OP_WRITE,
33 _AIO_OP_CLOSE,
34 _AIO_OP_UNLINK,
35 _AIO_OP_TRUNCATE,
36 _AIO_OP_OPENDIR,
37 _AIO_OP_STAT
38 };
39 typedef enum _squidaio_request_type squidaio_request_type;
40
41 typedef void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno);
42
43 struct squidaio_result_t
44 {
45 int aio_return;
46 int aio_errno;
47 enum _squidaio_request_type result_type;
48 void *_data; /* Internal housekeeping */
49 void *data; /* Available to the caller */
50 };
51
52 struct squidaio_ctrl_t
53 {
54
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 };
66
67 void squidaio_init(void);
68 void squidaio_shutdown(void);
69 int squidaio_cancel(squidaio_result_t *);
70 int squidaio_open(const char *, int, mode_t, squidaio_result_t *);
71 int squidaio_read(int, char *, int, off_t, int, squidaio_result_t *);
72 int squidaio_write(int, char *, int, off_t, int, squidaio_result_t *);
73 int squidaio_close(int, squidaio_result_t *);
74
75 int squidaio_stat(const char *, struct stat *, squidaio_result_t *);
76 int squidaio_unlink(const char *, squidaio_result_t *);
77 int squidaio_truncate(const char *, off_t length, 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, int offset, char *, int size, AIOCB *, void *, FREE *);
93 void aioRead(int, int offset, int size, AIOCB *, void *);
94
95 void aioStat(char *, struct stat *, AIOCB *, void *);
96 void aioUnlink(const char *, AIOCB *, void *);
97 void aioTruncate(const char *, off_t length, AIOCB *, void *);
98 int aioQueueSize(void);
99
100 #include "DiskIO/DiskFile.h"
101
102 class DiskThreadsIOStrategy;
103
104 struct AIOCounts
105 {
106 int open_start;
107 int open_finish;
108 int close_start;
109 int close_finish;
110 int cancel;
111 int write_start;
112 int write_finish;
113 int read_start;
114 int read_finish;
115 int stat_start;
116 int stat_finish;
117 int unlink_start;
118 int unlink_finish;
119 int check_callback;
120 };
121
122 extern AIOCounts squidaio_counts;
123 extern dlink_list used_list;
124
125
126 #endif