]>
Commit | Line | Data |
---|---|---|
b9ae18aa | 1 | #ifndef __COSSSWAPDIR_H__ |
2 | #define __COSSSWAPDIR_H__ | |
3 | ||
e1f7507e AJ |
4 | class StoreEntry; |
5 | class CossSwapDir; | |
6 | class CossMemBuf; | |
7 | class DiskIOStrategy; | |
8 | class DiskIOModule; | |
9 | class ConfigOptionVector; | |
10 | class DiskFile; | |
11 | ||
b9ae18aa | 12 | #include "SwapDir.h" |
e1f7507e AJ |
13 | #include "DiskIO/IORequestor.h" |
14 | ||
b9ae18aa | 15 | #ifndef COSS_MEMBUF_SZ |
16 | #define COSS_MEMBUF_SZ 1048576 | |
17 | #endif | |
18 | ||
19 | /* Note that swap_filen in sio/e are actually disk offsets too! */ | |
20 | ||
21 | /* What we're doing in storeCossAllocate() */ | |
22 | #define COSS_ALLOC_ALLOCATE 1 | |
23 | #define COSS_ALLOC_REALLOC 2 | |
24 | ||
63be0a78 | 25 | /// \ingroup COSS |
b9ae18aa | 26 | class CossSwapDir : public SwapDir, public IORequestor |
27 | { | |
28 | ||
29 | public: | |
30 | CossSwapDir(); | |
31 | virtual void init(); | |
c8f4eac4 | 32 | virtual void create(); |
b9ae18aa | 33 | virtual void dump(StoreEntry &)const; |
34 | ~CossSwapDir(); | |
30abd221 | 35 | virtual StoreSearch *search(String const url, HttpRequest *); |
c521ad17 | 36 | virtual bool unlinkdUseful() const; |
b9ae18aa | 37 | virtual void unlink (StoreEntry &); |
38 | virtual void statfs (StoreEntry &)const; | |
aa1a691e | 39 | virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const; |
b9ae18aa | 40 | virtual int callback(); |
41 | virtual void sync(); | |
c6ee6676 | 42 | virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); |
43 | virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); | |
b9ae18aa | 44 | virtual void openLog(); |
45 | virtual void closeLog(); | |
46 | virtual int writeCleanStart(); | |
47 | virtual void writeCleanDone(); | |
48 | virtual void logEntry(const StoreEntry & e, int op) const; | |
49 | virtual void parse (int index, char *path); | |
c6059970 | 50 | virtual void reconfigure(); |
da9d3191 | 51 | virtual void swappedOut(const StoreEntry &e); |
a86ff82a DK |
52 | virtual uint64_t currentSize() const { return cur_size; } |
53 | virtual uint64_t currentCount() const { return n_disk_objects; } | |
b9ae18aa | 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(); | |
a86ff82a DK |
81 | StoreEntry *addDiskRestore(const cache_key *const key, |
82 | int file_number, | |
83 | uint64_t swap_file_sz, | |
84 | time_t expires, | |
85 | time_t timestamp, | |
86 | time_t lastref, | |
87 | time_t lastmod, | |
88 | uint32_t refcount, | |
89 | uint16_t flags, | |
90 | int clean); | |
b9ae18aa | 91 | |
92 | private: | |
93 | void changeIO(DiskIOModule *module); | |
94 | bool optionIOParse(char const *option, const char *value, int reconfiguring); | |
95 | void optionIODump(StoreEntry * e) const; | |
5c926411 | 96 | void optionBlockSizeDump(StoreEntry *) const; |
97 | bool optionBlockSizeParse(const char *, const char *, int); | |
c8f4eac4 | 98 | char const *stripePath() const; |
b9ae18aa | 99 | ConfigOption * getOptionTree() const; |
100 | const char *ioModule; | |
e2a8733e | 101 | mutable ConfigOptionVector *currentIOOptions; |
c8f4eac4 | 102 | const char *stripe_path; |
a86ff82a DK |
103 | uint64_t cur_size; ///< currently used space in the storage area |
104 | uint64_t n_disk_objects; ///< total number of objects stored | |
b9ae18aa | 105 | }; |
106 | ||
63be0a78 | 107 | /// \ingroup COSS |
b9ae18aa | 108 | extern void storeCossAdd(CossSwapDir *, StoreEntry *); |
63be0a78 | 109 | /// \ingroup COSS |
b9ae18aa | 110 | extern void storeCossRemove(CossSwapDir *, StoreEntry *); |
63be0a78 | 111 | /// \ingroup COSS |
b9ae18aa | 112 | extern void storeCossStartMembuf(CossSwapDir * SD); |
c8f4eac4 | 113 | |
e1f7507e AJ |
114 | #include "StoreSearch.h" |
115 | ||
63be0a78 | 116 | /// \ingroup COSS |
c8f4eac4 | 117 | class StoreSearchCoss : public StoreSearch |
118 | { | |
119 | ||
120 | public: | |
121 | StoreSearchCoss(RefCount<CossSwapDir> sd); | |
122 | StoreSearchCoss(StoreSearchCoss const &); | |
123 | ~StoreSearchCoss(); | |
124 | /* Iterator API - garh, wrong place */ | |
125 | /* callback the client when a new StoreEntry is available | |
26ac0430 | 126 | * or an error occurs |
c8f4eac4 | 127 | */ |
128 | virtual void next(void (callback)(void *cbdata), void *cbdata); | |
129 | /* return true if a new StoreEntry is immediately available */ | |
130 | virtual bool next(); | |
131 | virtual bool error() const; | |
132 | virtual bool isDone() const; | |
133 | virtual StoreEntry *currentItem(); | |
134 | ||
135 | private: | |
c8f4eac4 | 136 | RefCount<CossSwapDir> sd; |
137 | void (*callback)(void *cbdata); | |
138 | void *cbdata; | |
139 | bool _done; | |
140 | dlink_node * current; | |
141 | dlink_node * next_; | |
c7bf588b FC |
142 | |
143 | CBDATA_CLASS2(StoreSearchCoss); | |
c8f4eac4 | 144 | }; |
145 | ||
b9ae18aa | 146 | #endif |