]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/store/Disks.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / store / Disks.h
index 49def690529a14e50bca1296fef9c87718c3ffbd..9c82df4e4274545f78f4d28b4b3c0c51d514d167 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -18,6 +18,8 @@ namespace Store {
 class Disks: public Controlled
 {
 public:
+    Disks();
+
     /* Storage API */
     virtual void create() override;
     virtual void init() override;
@@ -32,17 +34,38 @@ public:
     virtual void sync() override;
     virtual void reference(StoreEntry &) override;
     virtual bool dereference(StoreEntry &e) override;
+    virtual void updateHeaders(StoreEntry *) override;
     virtual void maintain() override;
-    virtual bool anchorCollapsed(StoreEntry &e, bool &inSync) override;
-    virtual bool updateCollapsed(StoreEntry &e) override;
-    virtual void markForUnlink(StoreEntry &) override;
-    virtual void unlink(StoreEntry &) override;
+    virtual bool anchorToCache(StoreEntry &e, bool &inSync) override;
+    virtual bool updateAnchored(StoreEntry &) override;
+    virtual void evictCached(StoreEntry &) override;
+    virtual void evictIfFound(const cache_key *) override;
     virtual int callback() override;
 
+    /// update configuration, including limits (re)calculation
+    void configure();
+    /// parses a single cache_dir configuration line
+    static void Parse(DiskConfig &);
+    /// prints the configuration into the provided StoreEntry
+    static void Dump(const DiskConfig &, StoreEntry &, const char *name);
+
+    /// Additional unknown-size entry bytes required by disks in order to
+    /// reduce the risk of selecting the wrong disk cache for the growing entry.
+    int64_t accumulateMore(const StoreEntry&) const;
+    /// whether any disk cache is SMP-aware
+    static bool SmpAware();
+    static SwapDir *SelectSwapDir(const StoreEntry *);
+    /// whether any of disk caches has entry with e.key
+    bool hasReadableEntry(const StoreEntry &) const;
+
 private:
     /* migration logic */
     SwapDir *store(int const x) const;
-    SwapDir &dir(int const idx) const;
+    static SwapDir &Dir(int const idx);
+
+    int64_t largestMinimumObjectSize; ///< maximum of all Disk::minObjectSize()s
+    int64_t largestMaximumObjectSize; ///< maximum of all Disk::maxObjectSize()s
+    int64_t secondLargestMaximumObjectSize; ///< the second-biggest Disk::maxObjectSize()
 };
 
 } // namespace Store
@@ -53,13 +76,9 @@ int storeDirWriteCleanLogs(int reopen);
 void storeDirCloseSwapLogs(void);
 
 /* Globals that should be converted to static Store::Disks methods */
-void allocate_new_swapdir(Store::DiskConfig *swap);
+void allocate_new_swapdir(Store::DiskConfig &swap);
 void free_cachedir(Store::DiskConfig *swap);
 
-/* Globals that should be converted to Store::Disks private data members */
-typedef int STDIRSELECT(const StoreEntry *e);
-extern STDIRSELECT *storeDirSelectSwapDir;
-
 /* Globals that should be moved to some Store::UFS-specific logging module */
 void storeDirSwapLog(const StoreEntry *e, int op);