]> git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/coss/store_coss.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / fs / coss / store_coss.h
1 #ifndef __COSS_H__
2 #define __COSS_H__
3
4 #include "SwapDir.h"
5
6 #ifndef COSS_MEMBUF_SZ
7 #define COSS_MEMBUF_SZ 1048576
8 #endif
9
10 /** \note swap_filen in sio/e are actually disk offsets too! */
11
12 /** What we're doing in storeCossAllocate() */
13 #define COSS_ALLOC_NOTIFY 0
14
15 /** What we're doing in storeCossAllocate() */
16 #define COSS_ALLOC_ALLOCATE 1
17
18 /** What we're doing in storeCossAllocate() */
19 #define COSS_ALLOC_REALLOC 2
20
21 class CossSwapDir;
22
23 /// \ingroup COSS
24 class CossMemBuf
25 {
26
27 public:
28 void describe(int level, int line);
29 void maybeWrite(CossSwapDir * SD);
30 void write(CossSwapDir * SD);
31 dlink_node node;
32 off_t diskstart; /* in blocks */
33 off_t diskend; /* in blocks */
34 CossSwapDir *SD;
35 int lockcount;
36 char buffer[COSS_MEMBUF_SZ];
37
38 struct _cossmembuf_flags {
39 unsigned int full:1;
40 unsigned int writing:1;
41 } flags;
42 };
43
44 /// \ingroup COSS
45 struct _cossindex {
46 /**
47 \note The dlink_node MUST be the first member of the structure.
48 * This member is later pointer typecasted to coss_index_node *.
49 */
50 dlink_node node;
51 };
52
53 /**
54 \ingroup COSS
55 * Per-storeiostate info
56 */
57 class CossState : public StoreIOState
58 {
59
60 public:
61 MEMPROXY_CLASS(CossState);
62 CossState(CossSwapDir *);
63 ~CossState();
64
65 char *readbuffer;
66 char *requestbuf;
67 size_t requestlen;
68 size_t requestoffset; /* in blocks */
69 int64_t reqdiskoffset; /* in blocks */
70
71 struct {
72 unsigned int reading:1;
73 unsigned int writing:1;
74 } flags;
75
76 CossMemBuf *locked_membuf;
77 off_t st_size;
78 void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data);
79 void write(char const *buf, size_t size, off_t offset, FREE * free_func);
80 virtual void close(int);
81 void doCallback(int errflag);
82 void lockMemBuf();
83
84 CossSwapDir *SD;
85 };
86
87 MEMPROXY_CLASS_INLINE(CossState);
88
89 /// \ingroup COSS
90 typedef struct _cossindex CossIndexNode;
91
92 /**
93 \ingroup COSS
94 * Whether the coss system has been setup or not
95 */
96 extern int coss_initialised;
97 /// \ingroup COSS
98 extern MemAllocator *coss_membuf_pool;
99 /// \ingroup COSS
100 extern MemAllocator *coss_index_pool;
101
102 #include "DiskIO/ReadRequest.h"
103
104 /// \ingroup COSS
105 class CossRead : public ReadRequest
106 {
107
108 public:
109 void * operator new (size_t);
110 void operator delete (void *);
111 CossRead(ReadRequest const &base, StoreIOState::Pointer anSio) : ReadRequest(base) , sio(anSio) {}
112
113 StoreIOState::Pointer sio;
114
115 private:
116 CBDATA_CLASS(CossRead);
117 };
118
119 #include "DiskIO/WriteRequest.h"
120
121 /// \ingroup COSS
122 class CossWrite : public WriteRequest
123 {
124
125 public:
126 void * operator new (size_t);
127 void operator delete (void *);
128 CossWrite(WriteRequest const &base, CossMemBuf *aBuf) : WriteRequest(base) , membuf(aBuf) {}
129
130 CossMemBuf *membuf;
131
132 private:
133 CBDATA_CLASS(CossWrite);
134 };
135
136 #endif