]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fs/coss/CossSwapDir.h
Author: wessels & Christos Tsantilas
[thirdparty/squid.git] / src / fs / coss / CossSwapDir.h
CommitLineData
b9ae18aa 1#ifndef __COSSSWAPDIR_H__
2#define __COSSSWAPDIR_H__
3
4#include "SwapDir.h"
c8f4eac4 5#include "StoreSearch.h"
b9ae18aa 6
7#ifndef COSS_MEMBUF_SZ
8#define COSS_MEMBUF_SZ 1048576
9#endif
10
11/* Note that swap_filen in sio/e are actually disk offsets too! */
12
13/* What we're doing in storeCossAllocate() */
14#define COSS_ALLOC_ALLOCATE 1
15#define COSS_ALLOC_REALLOC 2
16
17class CossSwapDir;
18
19
20class CossMemBuf;
21
22class DiskIOStrategy;
23
24class DiskIOModule;
25
26class ConfigOptionVector;
27#include "DiskIO/DiskFile.h"
28#include "DiskIO/IORequestor.h"
29
30class CossSwapDir : public SwapDir, public IORequestor
31{
32
33public:
34 CossSwapDir();
35 virtual void init();
c8f4eac4 36 virtual void create();
b9ae18aa 37 virtual void dump(StoreEntry &)const;
38 ~CossSwapDir();
30abd221 39 virtual StoreSearch *search(String const url, HttpRequest *);
b9ae18aa 40 virtual void unlink (StoreEntry &);
41 virtual void statfs (StoreEntry &)const;
42 virtual int canStore(StoreEntry const &)const;
43 virtual int callback();
44 virtual void sync();
c6ee6676 45 virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
46 virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
b9ae18aa 47 virtual void openLog();
48 virtual void closeLog();
49 virtual int writeCleanStart();
50 virtual void writeCleanDone();
51 virtual void logEntry(const StoreEntry & e, int op) const;
52 virtual void parse (int index, char *path);
53 virtual void reconfigure (int, char *);
54 /* internals */
55 virtual off_t storeCossFilenoToDiskOffset(sfileno);
56 virtual sfileno storeCossDiskOffsetToFileno(off_t);
57 virtual CossMemBuf *storeCossFilenoToMembuf(sfileno f);
58 /* IORequestor routines */
59 virtual void ioCompletedNotification();
60 virtual void closeCompleted();
61 virtual void readCompleted(const char *buf, int len, int errflag, RefCount<ReadRequest>);
62 virtual void writeCompleted(int errflag, size_t len, RefCount<WriteRequest>);
63 //private:
64 int swaplog_fd;
65 int count;
66 dlink_list membufs;
67
68 CossMemBuf *current_membuf;
47f6e231 69 off_t current_offset; /* in Blocks */
b9ae18aa 70 int numcollisions;
71 dlink_list cossindex;
72 unsigned int blksz_bits;
73 unsigned int blksz_mask; /* just 1<<blksz_bits - 1*/
74 DiskIOStrategy *io;
75 RefCount<DiskFile> theFile;
47f6e231 76 char *storeCossMemPointerFromDiskOffset(off_t offset, CossMemBuf ** mb);
e877aaac 77 void storeCossMemBufUnlock(StoreIOState::Pointer);
47f6e231 78 CossMemBuf *createMemBuf(off_t start, sfileno curfn, int *collision);
b9ae18aa 79 sfileno allocate(const StoreEntry * e, int which);
80 void startMembuf();
81
82private:
83 void changeIO(DiskIOModule *module);
84 bool optionIOParse(char const *option, const char *value, int reconfiguring);
85 void optionIODump(StoreEntry * e) const;
5c926411 86 void optionBlockSizeDump(StoreEntry *) const;
87 bool optionBlockSizeParse(const char *, const char *, int);
c8f4eac4 88 char const *stripePath() const;
b9ae18aa 89 ConfigOption * getOptionTree() const;
90 const char *ioModule;
e2a8733e 91 mutable ConfigOptionVector *currentIOOptions;
c8f4eac4 92 const char *stripe_path;
b9ae18aa 93};
94
95extern void storeCossAdd(CossSwapDir *, StoreEntry *);
96extern void storeCossRemove(CossSwapDir *, StoreEntry *);
97extern void storeCossStartMembuf(CossSwapDir * SD);
c8f4eac4 98
99class StoreSearchCoss : public StoreSearch
100{
101
102public:
103 StoreSearchCoss(RefCount<CossSwapDir> sd);
104 StoreSearchCoss(StoreSearchCoss const &);
105 ~StoreSearchCoss();
106 /* Iterator API - garh, wrong place */
107 /* callback the client when a new StoreEntry is available
108 * or an error occurs
109 */
110 virtual void next(void (callback)(void *cbdata), void *cbdata);
111 /* return true if a new StoreEntry is immediately available */
112 virtual bool next();
113 virtual bool error() const;
114 virtual bool isDone() const;
115 virtual StoreEntry *currentItem();
116
117private:
118 CBDATA_CLASS2(StoreSearchCoss);
119 RefCount<CossSwapDir> sd;
120 void (*callback)(void *cbdata);
121 void *cbdata;
122 bool _done;
123 dlink_node * current;
124 dlink_node * next_;
125};
126
b9ae18aa 127#endif