]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Warn if MemStore cannot support the configured maximum disk-cache entry size.
authorDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Mon, 18 Apr 2011 11:53:16 +0000 (15:53 +0400)
committerDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Mon, 18 Apr 2011 11:53:16 +0000 (15:53 +0400)
src/MemStore.cc
src/MemStore.h
src/Store.h
src/StoreHashIndex.h
src/SwapDir.h
src/store_dir.cc

index 517a495143db7bd9ec7895b040c8902b0533e561..fe6680036bf45526b0879a15585e37f4865edb3c 100644 (file)
@@ -44,6 +44,19 @@ MemStore::init() {
     if (entryLimit <= 0)
         return; // no memory cache configured or a misconfiguration
 
+    if (IamWorkerProcess()) { // XXX: coordinator should not create MemStore
+        const int64_t max_size = Store::Root().maxObjectSize();
+        if (max_size == -1) {
+            debugs(20, DBG_IMPORTANT, "WARNING: disk-cache maximum object size "
+                   "is unlimited but mem-cache maximum object size is " <<
+                   Ipc::Mem::PageSize());
+        } else if (max_size > maxObjectSize()) {
+            debugs(20, DBG_IMPORTANT, "WARNING: disk-cache maximum object size "
+                   "is too large for mem-cache: " <<
+                   Store::Root().maxObjectSize() << " > " << maxObjectSize());
+        }
+    }
+
     map = new MemStoreMap(ShmLabel);
     map->cleaner = this;
 }
@@ -100,6 +113,12 @@ MemStore::currentCount() const
     return map ? map->entryCount() : 0;
 }
 
+int64_t
+MemStore::maxObjectSize() const
+{
+    return Ipc::Mem::PageSize();
+}
+
 void
 MemStore::updateSize(int64_t eSize, int sign)
 {
@@ -332,7 +351,6 @@ MemStore::EntryLimit()
     if (!Config.memMaxSize)
         return 0; // no memory cache configured
 
-    // TODO: warn if we cannot support the configured maximum entry size
     const int64_t entrySize = Ipc::Mem::PageSize(); // for now
     const int64_t entryLimit = Config.memMaxSize / entrySize;
     // TODO: warn if we cannot cache at least one item (misconfiguration)
index b628e25898a9a85cd02d897b6ec792737c2bcc36..ca5e60cea3691b07460e20a6cfe0741ee3513b8b 100644 (file)
@@ -27,6 +27,7 @@ public:
     virtual uint64_t minSize() const;
     virtual uint64_t currentSize() const;
     virtual uint64_t currentCount() const;
+    virtual int64_t maxObjectSize() const;
     virtual void stat(StoreEntry &) const;
     virtual StoreSearch *search(String const url, HttpRequest *);
     virtual void reference(StoreEntry &);
index d12d1ffccfd0b2c3a6d5e2c6a45c16caac4bada4..4b731be01c8d7db7dadb398ec05253caf53befa1 100644 (file)
@@ -306,6 +306,9 @@ public:
     /** the total number of objects stored */
     virtual uint64_t currentCount() const = 0;
 
+    /** the maximum object size that can be stored, -1 if unlimited */
+    virtual int64_t maxObjectSize() const = 0;
+
     /**
      * Output stats to the provided store entry.
      \todo make these calls asynchronous
index 8ed0c009919d849a22499addd331305daba865d9..b3badea2adfdfbdfe147bb41701589956aea2567 100644 (file)
@@ -71,6 +71,8 @@ public:
 
     virtual uint64_t currentCount() const;
 
+    virtual int64_t maxObjectSize() const;
+
     virtual void stat(StoreEntry&) const;
 
     virtual void reference(StoreEntry&);
index df0648f8a5c8c18cedad32fe5e785d779843d6ae..53dde7126c0048917a2fa52f67154207a9213f4e 100644 (file)
@@ -73,6 +73,8 @@ public:
 
     virtual uint64_t currentCount() const;
 
+    virtual int64_t maxObjectSize() const;
+
     virtual void stat(StoreEntry &) const;
 
     virtual void sync();       /* Sync the store prior to shutdown */
@@ -146,6 +148,8 @@ public:
 
     virtual uint64_t currentCount() const { return n_disk_objects; }
 
+    virtual int64_t maxObjectSize() const { return max_objsize; }
+
     virtual void stat (StoreEntry &anEntry) const;
     virtual StoreSearch *search(String const url, HttpRequest *) = 0;
 
index 4d64c018e5a8035b935eea7d438aa3580ecad2e3..922bb7d786edc0ba1bcbc1bcc357df86a3ef3179 100644 (file)
@@ -389,6 +389,12 @@ StoreController::currentCount() const
     return swapDir->currentCount();
 }
 
+int64_t
+StoreController::maxObjectSize() const
+{
+    return swapDir->maxObjectSize();
+}
+
 void
 SwapDir::diskFull()
 {
@@ -958,6 +964,19 @@ StoreHashIndex::currentCount() const
     return result;
 }
 
+int64_t
+StoreHashIndex::maxObjectSize() const
+{
+    int64_t result = -1;
+
+    for (int i = 0; i < Config.cacheSwap.n_configured; i++) {
+        if (dir(i).active() && store(i)->maxObjectSize() > result)
+            result = store(i)->maxObjectSize();
+    }
+
+    return result;
+}
+
 void
 StoreHashIndex::stat(StoreEntry & output) const
 {