Disks.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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_SRC_STORE_DISKS_H
10 #define SQUID_SRC_STORE_DISKS_H
11 
12 #include "store/Controlled.h"
13 #include "store/forward.h"
14 
15 namespace Store {
16 
18 class Disks: public Controlled
19 {
20 public:
21  Disks();
22 
23  /* Storage API */
24  void create() override;
25  void init() override;
26  StoreEntry *get(const cache_key *) override;
27  uint64_t maxSize() const override;
28  uint64_t minSize() const override;
29  uint64_t currentSize() const override;
30  uint64_t currentCount() const override;
31  int64_t maxObjectSize() const override;
32  void getStats(StoreInfoStats &stats) const override;
33  void stat(StoreEntry &) const override;
34  void sync() override;
35  void reference(StoreEntry &) override;
36  bool dereference(StoreEntry &e) override;
37  void updateHeaders(StoreEntry *) override;
38  void maintain() override;
39  bool anchorToCache(StoreEntry &) override;
40  bool updateAnchored(StoreEntry &) override;
41  void evictCached(StoreEntry &) override;
42  void evictIfFound(const cache_key *) override;
43  int callback() override;
44 
46  void configure();
48  static void Parse(DiskConfig &);
50  static void Dump(const DiskConfig &, StoreEntry &, const char *name);
51 
54  int64_t accumulateMore(const StoreEntry&) const;
56  static bool SmpAware();
57  static SwapDir *SelectSwapDir(const StoreEntry *);
59  bool hasReadableEntry(const StoreEntry &) const;
60 
61 private:
62  /* migration logic */
63  SwapDir *store(int const x) const;
64  static SwapDir &Dir(int const idx);
65 
69 };
70 
71 } // namespace Store
72 
73 /* Store::Disks globals that should be converted to use RegisteredRunner */
74 void storeDirOpenSwapLogs(void);
75 int storeDirWriteCleanLogs(int reopen);
76 void storeDirCloseSwapLogs(void);
77 
78 /* Globals that should be converted to static Store::Disks methods */
81 
82 /* Globals that should be moved to some Store::UFS-specific logging module */
83 void storeDirSwapLog(const StoreEntry *e, int op);
84 
85 #endif /* SQUID_SRC_STORE_DISKS_H */
86 
int64_t accumulateMore(const StoreEntry &) const
Definition: Disks.cc:480
SwapDir * store(int const x) const
Definition: Disks.cc:177
uint64_t maxSize() const override
Definition: Disks.cc:323
void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Disks.cc:517
manages a single cache_dir
Definition: Disk.h:21
unsigned char cache_key
Store key.
Definition: forward.h:29
void init() override
Definition: Disks.cc:260
void sync() override
prepare for shutdown
Definition: Disks.cc:580
static bool SmpAware()
whether any disk cache is SMP-aware
Definition: Disks.cc:649
static SwapDir & Dir(int const idx)
Definition: Disks.cc:183
void evictIfFound(const cache_key *) override
Definition: Disks.cc:604
void storeDirCloseSwapLogs(void)
Definition: Disks.cc:684
void create() override
create system resources needed for this store to operate in the future
Definition: Disks.cc:221
void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Disks.cc:565
void evictCached(StoreEntry &) override
Definition: Disks.cc:587
static SwapDir * SelectSwapDir(const StoreEntry *)
Definition: Disks.cc:662
void storeDirOpenSwapLogs(void)
Definition: Disks.cc:677
void reference(StoreEntry &) override
somebody needs this entry (many cache replacement policies need to know)
Definition: Disks.cc:546
void storeDirSwapLog(const StoreEntry *e, int op)
Definition: Disks.cc:839
int callback() override
called once every main loop iteration; TODO: Move to UFS code.
Definition: Disks.cc:189
void updateHeaders(StoreEntry *) override
make stored metadata and HTTP headers the same as in the given entry
Definition: Disks.cc:558
int64_t largestMaximumObjectSize
maximum of all Disk::maxObjectSize()s
Definition: Disks.h:67
int64_t largestMinimumObjectSize
maximum of all Disk::minObjectSize()s
Definition: Disks.h:66
summary view of all disk caches (cache_dirs) combined
Definition: Disks.h:18
static void Parse(DiskConfig &)
parses a single cache_dir configuration line
Definition: Disks.cc:416
static void Dump(const DiskConfig &, StoreEntry &, const char *name)
prints the configuration into the provided StoreEntry
Definition: Disks.cc:469
int64_t secondLargestMaximumObjectSize
the second-biggest Disk::maxObjectSize()
Definition: Disks.h:68
void configure()
update configuration, including limits (re)calculation
Definition: Disks.cc:381
bool hasReadableEntry(const StoreEntry &) const
whether any of disk caches has entry with e.key
Definition: Disks.cc:668
void allocate_new_swapdir(Store::DiskConfig &swap)
Definition: Disks.cc:787
uint64_t currentCount() const override
the total number of objects stored right now
Definition: Disks.cc:362
uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Disks.cc:336
bool anchorToCache(StoreEntry &) override
Definition: Disks.cc:613
int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Disks.cc:375
int storeDirWriteCleanLogs(int reopen)
Definition: Disks.cc:700
void free_cachedir(Store::DiskConfig *swap)
Definition: Disks.cc:806
StoreEntry * get(const cache_key *) override
Definition: Disks.cc:234
bool dereference(StoreEntry &e) override
Definition: Disks.cc:552
bool updateAnchored(StoreEntry &) override
Definition: Disks.cc:642
uint64_t currentSize() const override
current size
Definition: Disks.cc:349
void stat(StoreEntry &) const override
Definition: Disks.cc:533
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13

 

Introduction

Documentation

Support

Miscellaneous