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