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