]> git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/coss/CossSwapDir.h
Moved CBDATA_CLASS declarations to the end of classes as per coding guidelines.
[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 bool unlinkdUseful() const;
39 virtual void unlink (StoreEntry &);
40 virtual void statfs (StoreEntry &)const;
41 virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const;
42 virtual int callback();
43 virtual void sync();
44 virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
45 virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
46 virtual void openLog();
47 virtual void closeLog();
48 virtual int writeCleanStart();
49 virtual void writeCleanDone();
50 virtual void logEntry(const StoreEntry & e, int op) const;
51 virtual void parse (int index, char *path);
52 virtual void reconfigure();
53 virtual void swappedOut(const StoreEntry &e);
54 virtual uint64_t currentSize() const { return cur_size; }
55 virtual uint64_t currentCount() const { return n_disk_objects; }
56 /* internals */
57 virtual off_t storeCossFilenoToDiskOffset(sfileno);
58 virtual sfileno storeCossDiskOffsetToFileno(off_t);
59 virtual CossMemBuf *storeCossFilenoToMembuf(sfileno f);
60 /* IORequestor routines */
61 virtual void ioCompletedNotification();
62 virtual void closeCompleted();
63 virtual void readCompleted(const char *buf, int len, int errflag, RefCount<ReadRequest>);
64 virtual void writeCompleted(int errflag, size_t len, RefCount<WriteRequest>);
65 //private:
66 int swaplog_fd;
67 int count;
68 dlink_list membufs;
69
70 CossMemBuf *current_membuf;
71 off_t current_offset; /* in Blocks */
72 int numcollisions;
73 dlink_list cossindex;
74 unsigned int blksz_bits;
75 unsigned int blksz_mask; /* just 1<<blksz_bits - 1*/
76 DiskIOStrategy *io;
77 RefCount<DiskFile> theFile;
78 char *storeCossMemPointerFromDiskOffset(off_t offset, CossMemBuf ** mb);
79 void storeCossMemBufUnlock(StoreIOState::Pointer);
80 CossMemBuf *createMemBuf(off_t start, sfileno curfn, int *collision);
81 sfileno allocate(const StoreEntry * e, int which);
82 void startMembuf();
83 StoreEntry *addDiskRestore(const cache_key *const key,
84 int file_number,
85 uint64_t swap_file_sz,
86 time_t expires,
87 time_t timestamp,
88 time_t lastref,
89 time_t lastmod,
90 uint32_t refcount,
91 uint16_t flags,
92 int clean);
93
94 private:
95 void changeIO(DiskIOModule *module);
96 bool optionIOParse(char const *option, const char *value, int reconfiguring);
97 void optionIODump(StoreEntry * e) const;
98 void optionBlockSizeDump(StoreEntry *) const;
99 bool optionBlockSizeParse(const char *, const char *, int);
100 char const *stripePath() const;
101 ConfigOption * getOptionTree() const;
102 const char *ioModule;
103 mutable ConfigOptionVector *currentIOOptions;
104 const char *stripe_path;
105 uint64_t cur_size; ///< currently used space in the storage area
106 uint64_t n_disk_objects; ///< total number of objects stored
107 };
108
109 /// \ingroup COSS
110 extern void storeCossAdd(CossSwapDir *, StoreEntry *);
111 /// \ingroup COSS
112 extern void storeCossRemove(CossSwapDir *, StoreEntry *);
113 /// \ingroup COSS
114 extern void storeCossStartMembuf(CossSwapDir * SD);
115
116
117 #include "StoreSearch.h"
118
119 /// \ingroup COSS
120 class StoreSearchCoss : public StoreSearch
121 {
122
123 public:
124 StoreSearchCoss(RefCount<CossSwapDir> sd);
125 StoreSearchCoss(StoreSearchCoss const &);
126 ~StoreSearchCoss();
127 /* Iterator API - garh, wrong place */
128 /* callback the client when a new StoreEntry is available
129 * or an error occurs
130 */
131 virtual void next(void (callback)(void *cbdata), void *cbdata);
132 /* return true if a new StoreEntry is immediately available */
133 virtual bool next();
134 virtual bool error() const;
135 virtual bool isDone() const;
136 virtual StoreEntry *currentItem();
137
138 private:
139 RefCount<CossSwapDir> sd;
140 void (*callback)(void *cbdata);
141 void *cbdata;
142 bool _done;
143 dlink_node * current;
144 dlink_node * next_;
145
146 CBDATA_CLASS2(StoreSearchCoss);
147 };
148
149 #endif