2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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.
12 * Internal declarations for the DiskThreads routines
15 #ifndef __DISKTHREADS_H__
16 #define __DISKTHREADS_H__
19 #include "mem/forward.h"
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) */
28 #define NUMTHREADS AUFS_IO_THREADS
30 #define NUMTHREADS (Config.cacheSwap.n_configured*16)
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)
38 /* Which operations to run async */
41 #define ASYNC_CREATE 1
45 enum _squidaio_request_type
{
55 typedef enum _squidaio_request_type squidaio_request_type
;
57 typedef void AIOCB(int fd
, void *cbdata
, const char *buf
, int aio_return
, int aio_errno
);
59 class squidaio_result_t
{
61 squidaio_result_t() : aio_return(0), aio_errno(0), result_type(_AIO_OP_NONE
), _data(nullptr), data(nullptr) {}
64 enum _squidaio_request_type result_type
;
65 void *_data
; /* Internal housekeeping */
66 void *data
; /* Available to the caller */
69 class squidaio_ctrl_t
{
70 MEMPROXY_CLASS(squidaio_ctrl_t
);
72 squidaio_ctrl_t() : next(nullptr), fd(0), operation(0), done_handler(nullptr), done_handler_data(nullptr), len(0), bufp(0), free_func(nullptr) {}
73 struct squidaio_ctrl_t
*next
;
77 void *done_handler_data
;
78 squidaio_result_t result
;
85 void squidaio_init(void);
86 void squidaio_shutdown(void);
87 int squidaio_cancel(squidaio_result_t
*);
88 int squidaio_open(const char *, int, mode_t
, squidaio_result_t
*);
89 int squidaio_read(int, char *, size_t, off_t
, int, squidaio_result_t
*);
90 int squidaio_write(int, char *, size_t, off_t
, int, squidaio_result_t
*);
91 int squidaio_close(int, squidaio_result_t
*);
93 int squidaio_stat(const char *, struct stat
*, squidaio_result_t
*);
94 int squidaio_unlink(const char *, squidaio_result_t
*);
95 int squidaio_opendir(const char *, squidaio_result_t
*);
96 squidaio_result_t
*squidaio_poll_done(void);
97 int squidaio_operations_pending(void);
98 int squidaio_sync(void);
99 int squidaio_get_queue_len(void);
100 void *squidaio_xmalloc(int size
);
101 void squidaio_xfree(void *p
, int size
);
102 void squidaio_stats(StoreEntry
*);
107 void aioOpen(const char *, int, mode_t
, AIOCB
*, void *);
109 void aioWrite(int, off_t offset
, char *, size_t size
, AIOCB
*, void *, FREE
*);
110 void aioRead(int, off_t offset
, size_t size
, AIOCB
*, void *);
112 void aioStat(char *, struct stat
*, AIOCB
*, void *);
113 void aioUnlink(const char *, AIOCB
*, void *);
114 int aioQueueSize(void);
116 #include "DiskIO/DiskFile.h"
118 class DiskThreadsIOStrategy
;
122 uint64_t open_finish
;
123 uint64_t close_start
;
124 uint64_t close_finish
;
126 uint64_t write_start
;
127 uint64_t write_finish
;
129 uint64_t read_finish
;
131 uint64_t stat_finish
;
132 uint64_t unlink_start
;
133 uint64_t unlink_finish
;
134 uint64_t check_callback
;
137 extern AIOCounts squidaio_counts
;
138 extern dlink_list used_list
;