]> git.ipfire.org Git - thirdparty/squid.git/blame - src/store/Disks.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / store / Disks.h
CommitLineData
2745fea5 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
2745fea5
AR
3 *
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.
7 */
8
9#ifndef SQUID_STORE_DISKS_H
10#define SQUID_STORE_DISKS_H
11
12#include "store/Controlled.h"
13#include "store/forward.h"
14
15namespace Store {
16
17/// summary view of all disk caches (cache_dirs) combined
18class Disks: public Controlled
19{
20public:
5ca027f0
AR
21 Disks();
22
2745fea5
AR
23 /* Storage API */
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;
abf396ec 37 virtual void updateHeaders(StoreEntry *) override;
2745fea5 38 virtual void maintain() override;
4310f8b0
EB
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;
2745fea5
AR
43 virtual int callback() override;
44
5ca027f0
AR
45 /// slowly calculate (and cache) hi/lo watermarks and similar limits
46 void updateLimits();
47
82bee387 48 /// Additional unknown-size entry bytes required by disks in order to
5ca027f0
AR
49 /// reduce the risk of selecting the wrong disk cache for the growing entry.
50 int64_t accumulateMore(const StoreEntry&) const;
daed75a9
EB
51 /// whether any disk cache is SMP-aware
52 static bool SmpAware();
4310f8b0
EB
53 /// whether any of disk caches has entry with e.key
54 bool hasReadableEntry(const StoreEntry &) const;
5ca027f0 55
2745fea5
AR
56private:
57 /* migration logic */
58 SwapDir *store(int const x) const;
daed75a9 59 static SwapDir &Dir(int const idx);
5ca027f0
AR
60
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()
2745fea5
AR
64};
65
66} // namespace Store
67
68/* Store::Disks globals that should be converted to use RegisteredRunner */
69void storeDirOpenSwapLogs(void);
70int storeDirWriteCleanLogs(int reopen);
71void storeDirCloseSwapLogs(void);
72
73/* Globals that should be converted to static Store::Disks methods */
74void allocate_new_swapdir(Store::DiskConfig *swap);
75void free_cachedir(Store::DiskConfig *swap);
76
77/* Globals that should be converted to Store::Disks private data members */
78typedef int STDIRSELECT(const StoreEntry *e);
79extern STDIRSELECT *storeDirSelectSwapDir;
80
81/* Globals that should be moved to some Store::UFS-specific logging module */
82void storeDirSwapLog(const StoreEntry *e, int op);
83
84#endif /* SQUID_STORE_DISKS_H */
7d84d4ca 85