]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/rock/RockSwapDir.h
1 #ifndef SQUID_FS_ROCK_SWAP_DIR_H
2 #define SQUID_FS_ROCK_SWAP_DIR_H
4 #include "DiskIO/DiskFile.h"
5 #include "DiskIO/IORequestor.h"
6 #include "fs/rock/RockDbCell.h"
7 #include "ipc/StoreMap.h"
20 class SwapDir
: public ::SwapDir
, public IORequestor
26 /* public ::SwapDir API */
27 virtual void reconfigure();
28 virtual StoreSearch
*search(String
const url
, HttpRequest
*);
29 virtual StoreEntry
*get(const cache_key
*key
);
30 virtual void get(String
const, STOREGETCLIENT
, void * cbdata
);
31 virtual void disconnect(StoreEntry
&e
);
32 virtual uint64_t currentSize() const;
33 virtual uint64_t currentCount() const;
34 virtual bool doReportStat() const;
35 virtual void swappedOut(const StoreEntry
&e
);
36 virtual void create();
37 virtual void parse(int index
, char *path
);
39 int64_t entryLimitHigh() const { return SwapFilenMax
; } ///< Core limit
40 int64_t entryLimitAllowed() const;
42 typedef Ipc::StoreMapWithExtras
<DbCellHeader
> DirMap
;
45 /* protected ::SwapDir API */
46 virtual bool needsDiskStrand() const;
48 virtual ConfigOption
*getOptionTree() const;
49 virtual bool allowOptionReconfigure(const char *const option
) const;
50 virtual bool canStore(const StoreEntry
&e
, int64_t diskSpaceNeeded
, int &load
) const;
51 virtual StoreIOState::Pointer
createStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
52 virtual StoreIOState::Pointer
openStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
53 virtual void maintain();
54 virtual void diskFull();
55 virtual void reference(StoreEntry
&e
);
56 virtual bool dereference(StoreEntry
&e
, bool);
57 virtual bool unlinkdUseful() const;
58 virtual void unlink(StoreEntry
&e
);
59 virtual void statfs(StoreEntry
&e
) const;
62 virtual void ioCompletedNotification();
63 virtual void closeCompleted();
64 virtual void readCompleted(const char *buf
, int len
, int errflag
, RefCount
< ::ReadRequest
>);
65 virtual void writeCompleted(int errflag
, size_t len
, RefCount
< ::WriteRequest
>);
67 void parseSize(const bool reconfiguring
); ///< parses anonymous cache_dir size option
68 void validateOptions(); ///< warns of configuration problems; may quit
69 bool parseTimeOption(char const *option
, const char *value
, int reconfiguring
);
70 void dumpTimeOption(StoreEntry
* e
) const;
71 bool parseRateOption(char const *option
, const char *value
, int reconfiguring
);
72 void dumpRateOption(StoreEntry
* e
) const;
74 void rebuild(); ///< starts loading and validating stored entry metadata
75 ///< used to add entries successfully loaded during rebuild
76 bool addEntry(const int fileno
, const DbCellHeader
&header
, const StoreEntry
&from
);
78 bool full() const; ///< no more entries can be stored without purging
79 void trackReferences(StoreEntry
&e
); ///< add to replacement policy scope
80 void ignoreReferences(StoreEntry
&e
); ///< delete from repl policy scope
82 int64_t diskOffset(int filen
) const;
83 int64_t diskOffsetLimit() const;
84 int entryLimit() const { return map
->entryLimit(); }
87 const char *filePath
; ///< location of cache storage file inside path/
91 RefCount
<DiskFile
> theFile
; ///< cache storage for this cache_dir
94 /* configurable options */
95 DiskFile::Config fileConfig
; ///< file-level configuration options
97 static const int64_t HeaderSize
; ///< on-disk db header size
100 /// initializes shared memory segments used by Rock::SwapDir
101 class SwapDirRr
: public Ipc::Mem::RegisteredRunner
104 /* ::RegisteredRunner API */
105 virtual ~SwapDirRr();
108 /* Ipc::Mem::RegisteredRunner API */
109 virtual void create(const RunnerRegistry
&);
112 Vector
<SwapDir::DirMap::Owner
*> owners
;
117 #endif /* SQUID_FS_ROCK_SWAP_DIR_H */