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