2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_STORE_DISKS_H
10 #define SQUID_STORE_DISKS_H
12 #include "store/Controlled.h"
13 #include "store/forward.h"
17 /// summary view of all disk caches (cache_dirs) combined
18 class Disks
: public Controlled
24 virtual void create() override
;
25 virtual void init() override
;
26 virtual StoreEntry
*get(const cache_key
*) override
;
27 virtual uint64_t maxSize() const override
;
28 virtual uint64_t minSize() const override
;
29 virtual uint64_t currentSize() const override
;
30 virtual uint64_t currentCount() const override
;
31 virtual int64_t maxObjectSize() const override
;
32 virtual void getStats(StoreInfoStats
&stats
) const override
;
33 virtual void stat(StoreEntry
&) const override
;
34 virtual void sync() override
;
35 virtual void reference(StoreEntry
&) override
;
36 virtual bool dereference(StoreEntry
&e
) override
;
37 virtual void updateHeaders(StoreEntry
*) override
;
38 virtual void maintain() override
;
39 virtual bool anchorToCache(StoreEntry
&e
, bool &inSync
) override
;
40 virtual bool updateAnchored(StoreEntry
&) override
;
41 virtual void evictCached(StoreEntry
&) override
;
42 virtual void evictIfFound(const cache_key
*) override
;
43 virtual int callback() override
;
45 /// slowly calculate (and cache) hi/lo watermarks and similar limits
48 /// Additional unknown-size entry bytes required by disks in order to
49 /// reduce the risk of selecting the wrong disk cache for the growing entry.
50 int64_t accumulateMore(const StoreEntry
&) const;
51 /// whether any disk cache is SMP-aware
52 static bool SmpAware();
53 /// whether any of disk caches has entry with e.key
54 bool hasReadableEntry(const StoreEntry
&) const;
58 SwapDir
*store(int const x
) const;
59 static SwapDir
&Dir(int const idx
);
61 int64_t largestMinimumObjectSize
; ///< maximum of all Disk::minObjectSize()s
62 int64_t largestMaximumObjectSize
; ///< maximum of all Disk::maxObjectSize()s
63 int64_t secondLargestMaximumObjectSize
; ///< the second-biggest Disk::maxObjectSize()
68 /* Store::Disks globals that should be converted to use RegisteredRunner */
69 void storeDirOpenSwapLogs(void);
70 int storeDirWriteCleanLogs(int reopen
);
71 void storeDirCloseSwapLogs(void);
73 /* Globals that should be converted to static Store::Disks methods */
74 void allocate_new_swapdir(Store::DiskConfig
*swap
);
75 void free_cachedir(Store::DiskConfig
*swap
);
77 /* Globals that should be converted to Store::Disks private data members */
78 typedef int STDIRSELECT(const StoreEntry
*e
);
79 extern STDIRSELECT
*storeDirSelectSwapDir
;
81 /* Globals that should be moved to some Store::UFS-specific logging module */
82 void storeDirSwapLog(const StoreEntry
*e
, int op
);
84 #endif /* SQUID_STORE_DISKS_H */