]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fs/rock/RockSwapDir.h
Expose the underlying integer type to AtomicWord users.
[thirdparty/squid.git] / src / fs / rock / RockSwapDir.h
CommitLineData
e2851fe7
AR
1#ifndef SQUID_FS_ROCK_SWAP_DIR_H
2#define SQUID_FS_ROCK_SWAP_DIR_H
3
4#include "SwapDir.h"
43ebbac3 5#include "DiskIO/DiskFile.h"
e2851fe7 6#include "DiskIO/IORequestor.h"
fcd789da 7#include "fs/rock/RockDbCell.h"
68353d5a 8#include "ipc/StoreMap.h"
e2851fe7
AR
9
10class DiskIOStrategy;
e2851fe7
AR
11class ReadRequest;
12class WriteRequest;
13
9199139f
AR
14namespace Rock
15{
e2851fe7
AR
16
17class Rebuild;
18
19/// \ingroup Rock
20class SwapDir: public ::SwapDir, public IORequestor
21{
22public:
23 SwapDir();
24 virtual ~SwapDir();
25
26 /* public ::SwapDir API */
27 virtual void reconfigure(int, char *);
28 virtual StoreSearch *search(String const url, HttpRequest *);
44def0f9 29 virtual StoreEntry *get(const cache_key *key);
f58bb2f4 30 virtual void disconnect(StoreEntry &e);
39c1e1d9
DK
31 virtual uint64_t currentSize() const;
32 virtual uint64_t currentCount() const;
33 virtual bool doReportStat() const;
da9d3191 34 virtual void swappedOut(const StoreEntry &e);
6d8d05b5 35
051dedf9 36 int64_t entryLimitHigh() const { return SwapFilenMax; } ///< Core limit
b3165da6
DK
37 int64_t entryLimitAllowed() const;
38
902df398
DK
39 typedef Ipc::StoreMapWithExtras<DbCellHeader> DirMap;
40
e2851fe7
AR
41protected:
42 /* protected ::SwapDir API */
14911a4e 43 virtual bool needsDiskStrand() const;
e2851fe7
AR
44 virtual void create();
45 virtual void init();
43ebbac3 46 virtual ConfigOption *getOptionTree() const;
c728b6f9 47 virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const;
e2851fe7
AR
48 virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
49 virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
50 virtual void maintain();
e2851fe7
AR
51 virtual void diskFull();
52 virtual void reference(StoreEntry &e);
4c973beb 53 virtual bool dereference(StoreEntry &e);
e2851fe7
AR
54 virtual void unlink(StoreEntry &e);
55 virtual void statfs(StoreEntry &e) const;
56
57 /* IORequestor API */
58 virtual void ioCompletedNotification();
59 virtual void closeCompleted();
60 virtual void readCompleted(const char *buf, int len, int errflag, RefCount< ::ReadRequest>);
61 virtual void writeCompleted(int errflag, size_t len, RefCount< ::WriteRequest>);
62
63 virtual void parse(int index, char *path);
64 void parseSize(); ///< parses anonymous cache_dir size option
65 void validateOptions(); ///< warns of configuration problems; may quit
43ebbac3
AR
66 bool parseTimeOption(char const *option, const char *value, int reconfiguring);
67 void dumpTimeOption(StoreEntry * e) const;
e2851fe7
AR
68
69 void rebuild(); ///< starts loading and validating stored entry metadata
e2851fe7 70 ///< used to add entries successfully loaded during rebuild
c728b6f9 71 bool addEntry(const int fileno, const DbCellHeader &header, const StoreEntry &from);
e2851fe7
AR
72
73 bool full() const; ///< no more entries can be stored without purging
74 void trackReferences(StoreEntry &e); ///< add to replacement policy scope
75 void ignoreReferences(StoreEntry &e); ///< delete from repl policy scope
76
e2851fe7
AR
77 int64_t diskOffset(int filen) const;
78 int64_t diskOffsetLimit() const;
f1eaa254 79 int entryLimit() const { return map->entryLimit(); }
e2851fe7
AR
80
81 friend class Rebuild;
82 const char *filePath; ///< location of cache storage file inside path/
83
84private:
85 DiskIOStrategy *io;
86 RefCount<DiskFile> theFile; ///< cache storage for this cache_dir
f1eaa254 87 DirMap *map;
b3165da6 88
43ebbac3
AR
89 /* configurable options */
90 DiskFile::Config fileConfig; ///< file-level configuration options
91
b3165da6 92 static const int64_t HeaderSize; ///< on-disk db header size
e2851fe7
AR
93};
94
95} // namespace Rock
96
97#endif /* SQUID_FS_ROCK_SWAP_DIR_H */