]>
Commit | Line | Data |
---|---|---|
cd748f27 | 1 | /* |
2 | * store_aufs.h | |
3 | * | |
4 | * Internal declarations for the aufs routines | |
5 | */ | |
6 | ||
7 | #ifndef __STORE_ASYNCUFS_H__ | |
8 | #define __STORE_ASYNCUFS_H__ | |
9 | ||
f85c88f3 | 10 | #ifdef AUFS_IO_THREADS |
11 | #define NUMTHREADS AUFS_IO_THREADS | |
cd748f27 | 12 | #else |
55f0e6f7 | 13 | #define NUMTHREADS (Config.cacheSwap.n_configured*16) |
cd748f27 | 14 | #endif |
15 | ||
55f0e6f7 | 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 | |
cd748f27 | 27 | |
c04d4f40 | 28 | struct _squidaio_result_t { |
cd748f27 | 29 | int aio_return; |
30 | int aio_errno; | |
f0debecb | 31 | void *_data; /* Internal housekeeping */ |
32 | void *data; /* Available to the caller */ | |
cd748f27 | 33 | }; |
34 | ||
c04d4f40 | 35 | typedef struct _squidaio_result_t squidaio_result_t; |
cd748f27 | 36 | |
37 | typedef void AIOCB(int fd, void *, int aio_return, int aio_errno); | |
38 | ||
c04d4f40 | 39 | int squidaio_cancel(squidaio_result_t *); |
40 | int squidaio_open(const char *, int, mode_t, squidaio_result_t *); | |
41 | int squidaio_read(int, char *, int, off_t, int, squidaio_result_t *); | |
42 | int squidaio_write(int, char *, int, off_t, int, squidaio_result_t *); | |
43 | int squidaio_close(int, squidaio_result_t *); | |
44 | int squidaio_stat(const char *, struct stat *, squidaio_result_t *); | |
45 | int squidaio_unlink(const char *, squidaio_result_t *); | |
46 | int squidaio_truncate(const char *, off_t length, squidaio_result_t *); | |
47 | int squidaio_opendir(const char *, squidaio_result_t *); | |
48 | squidaio_result_t *squidaio_poll_done(void); | |
49 | int squidaio_operations_pending(void); | |
50 | int squidaio_sync(void); | |
51 | int squidaio_get_queue_len(void); | |
cd748f27 | 52 | |
53 | void aioInit(void); | |
54 | void aioDone(void); | |
a4b8110e | 55 | void aioCancel(int); |
56 | void aioOpen(const char *, int, mode_t, AIOCB *, void *); | |
cd748f27 | 57 | void aioClose(int); |
58 | void aioWrite(int, int offset, char *, int size, AIOCB *, void *, FREE *); | |
59 | void aioRead(int, int offset, char *, int size, AIOCB *, void *); | |
60 | void aioStat(char *, struct stat *, AIOCB *, void *); | |
61 | void aioUnlink(const char *, AIOCB *, void *); | |
15a47d1d | 62 | void aioTruncate(const char *, off_t length, AIOCB *, void *); |
6a566b9c | 63 | int aioCheckCallbacks(SwapDir *); |
cd748f27 | 64 | void aioSync(SwapDir *); |
a4b8110e | 65 | int aioQueueSize(void); |
cd748f27 | 66 | |
c04d4f40 | 67 | struct _squidaioinfo_t { |
cd748f27 | 68 | int swaplog_fd; |
69 | int l1; | |
70 | int l2; | |
71 | fileMap *map; | |
72 | int suggest; | |
73 | }; | |
74 | ||
c04d4f40 | 75 | struct _squidaiostate_t { |
cd748f27 | 76 | int fd; |
77 | struct { | |
78 | unsigned int close_request:1; | |
79 | unsigned int reading:1; | |
80 | unsigned int writing:1; | |
81 | unsigned int opening:1; | |
55f0e6f7 | 82 | unsigned int write_kicking:1; |
83 | unsigned int read_kicking:1; | |
84 | unsigned int inreaddone:1; | |
cd748f27 | 85 | } flags; |
86 | const char *read_buf; | |
87 | link_list *pending_writes; | |
88 | link_list *pending_reads; | |
89 | }; | |
90 | ||
58cd5bbd | 91 | struct _queued_write { |
92 | char *buf; | |
93 | size_t size; | |
94 | off_t offset; | |
95 | FREE *free_func; | |
96 | }; | |
97 | ||
98 | struct _queued_read { | |
99 | char *buf; | |
100 | size_t size; | |
101 | off_t offset; | |
102 | STRCB *callback; | |
103 | void *callback_data; | |
104 | }; | |
105 | ||
c04d4f40 | 106 | typedef struct _squidaioinfo_t squidaioinfo_t; |
107 | typedef struct _squidaiostate_t squidaiostate_t; | |
cd748f27 | 108 | |
c04d4f40 | 109 | /* The squidaio_state memory pools */ |
110 | extern MemPool *squidaio_state_pool; | |
111 | extern MemPool *aufs_qread_pool; | |
112 | extern MemPool *aufs_qwrite_pool; | |
cd748f27 | 113 | |
114 | extern void storeAufsDirMapBitReset(SwapDir *, sfileno); | |
115 | extern int storeAufsDirMapBitAllocate(SwapDir *); | |
116 | ||
a4b8110e | 117 | extern char *storeAufsDirFullPath(SwapDir * SD, sfileno filn, char *fullpath); |
cd748f27 | 118 | extern void storeAufsDirUnlinkFile(SwapDir *, sfileno); |
a4b8110e | 119 | extern void storeAufsDirReplAdd(SwapDir * SD, StoreEntry *); |
cd748f27 | 120 | extern void storeAufsDirReplRemove(StoreEntry *); |
121 | ||
122 | /* | |
123 | * Store IO stuff | |
124 | */ | |
125 | extern STOBJCREATE storeAufsCreate; | |
126 | extern STOBJOPEN storeAufsOpen; | |
127 | extern STOBJCLOSE storeAufsClose; | |
128 | extern STOBJREAD storeAufsRead; | |
129 | extern STOBJWRITE storeAufsWrite; | |
130 | extern STOBJUNLINK storeAufsUnlink; | |
131 | ||
132 | #endif |