]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Make Store::currentSize() return size in bytes.
authorDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Wed, 27 Apr 2011 13:26:03 +0000 (17:26 +0400)
committerDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Wed, 27 Apr 2011 13:26:03 +0000 (17:26 +0400)
src/MemStore.cc
src/Store.h
src/SwapDir.h
src/fs/rock/RockSwapDir.cc
src/snmp_agent.cc
src/stat.cc
src/store_digest.cc
src/store_dir.cc
src/store_rebuild.cc

index d0cb698671232b74189c58f9557d25d83b13ff49..fe744d95c2bb419a7b7f4044090ee26611574605 100644 (file)
@@ -94,7 +94,7 @@ MemStore::maxSize() const
 uint64_t
 MemStore::currentSize() const
 {
-    return theCurrentSize >> 10;
+    return theCurrentSize;
 }
 
 uint64_t
index 4b731be01c8d7db7dadb398ec05253caf53befa1..5a0075e2506bc8d4c1022cc73144e093877892cf 100644 (file)
@@ -300,8 +300,8 @@ public:
     /** The minimum size the store will shrink to via normal housekeeping */
     virtual uint64_t minSize() const = 0;
 
-    /** current store size in kiloBytes */
-    virtual uint64_t currentSize() const = 0; // TODO: return size in bytes
+    /** current store size */
+    virtual uint64_t currentSize() const = 0;
 
     /** the total number of objects stored */
     virtual uint64_t currentCount() const = 0;
index 53dde7126c0048917a2fa52f67154207a9213f4e..f1bffe320f52c6ee708049466d867b1c331c9e35 100644 (file)
@@ -144,7 +144,7 @@ public:
 
     virtual uint64_t minSize() const;
 
-    virtual uint64_t currentSize() const { return cur_size; }
+    virtual uint64_t currentSize() const { return cur_size << 10; }
 
     virtual uint64_t currentCount() const { return n_disk_objects; }
 
index 0c7712030686703d64d60cc73ebecf90c0b651e5..710c810f258c4541bbbf54258b9b18e67a693e19 100644 (file)
@@ -8,6 +8,7 @@
 #include "Parsing.h"
 #include <iomanip>
 #include "MemObject.h"
+#include "SquidMath.h"
 #include "base/RunnersRegistry.h"
 #include "DiskIO/DiskIOModule.h"
 #include "DiskIO/DiskIOStrategy.h"
@@ -99,7 +100,7 @@ void Rock::SwapDir::disconnect(StoreEntry &e)
 uint64_t
 Rock::SwapDir::currentSize() const
 {
-    return (HeaderSize + max_objsize * currentCount()) >> 10;
+    return HeaderSize + max_objsize * currentCount();
 }
 
 uint64_t
@@ -571,7 +572,7 @@ Rock::SwapDir::maintain()
         return;
 
     debugs(47,3, HERE << "cache_dir[" << index << "] state: " << map->full() <<
-           ' ' << (currentSize() << 10) << " < " << diskOffsetLimit());
+           ' ' << currentSize() << " < " << diskOffsetLimit());
 
     // Hopefully, we find a removable entry much sooner (TODO: use time?)
     const int maxProbed = 10000;
@@ -644,10 +645,12 @@ Rock::SwapDir::ignoreReferences(StoreEntry &e)
 void
 Rock::SwapDir::statfs(StoreEntry &e) const
 {
+    const double currentSizeInKB = currentSize() / 1024.0;
     storeAppendPrintf(&e, "\n");
     storeAppendPrintf(&e, "Maximum Size: %"PRIu64" KB\n", max_size);
-    storeAppendPrintf(&e, "Current Size: %"PRIu64" KB %.2f%%\n",
-                      currentSize(), 100.0 * currentSize() / max_size);
+    storeAppendPrintf(&e, "Current Size: %.2f KB %.2f%%\n",
+                      currentSizeInKB,
+                      Math::doublePercent(currentSizeInKB, max_size));
 
     if (map) {
         const int limit = map->entryLimit();
index 9948c45b70cafe036796f2147018affa9dd3976e..45a639bf26af3d435ff56c642430107072a4c0f6 100644 (file)
@@ -67,7 +67,7 @@ snmp_sysFn(variable_list * Var, snint * ErrP)
 
     case SYSSTOR:
         Answer = snmp_var_new_integer(Var->name, Var->name_length,
-                                      Store::Root().currentSize(),
+                                      Store::Root().currentSize() >> 10,
                                       ASN_INTEGER);
         break;
 
@@ -531,7 +531,7 @@ snmp_prfProtoFn(variable_list * Var, snint * ErrP)
 
         case PERF_PROTOSTAT_AGGR_CURSWAP:
             Answer = snmp_var_new_integer(Var->name, Var->name_length,
-                                          (snint) Store::Root().currentSize(),
+                                          (snint) Store::Root().currentSize() >> 10,
                                           SMI_GAUGE32);
             break;
 
index 6b0a88c3a798b49159dd74ee94b30f8134446894..8a76dde26e68b73f26f2d26c4ad393139fd9c9d3 100644 (file)
@@ -546,7 +546,7 @@ GetInfo(Mgr::InfoActionData& stats)
     stats.request_hit_disk_ratio5 = statRequestHitDiskRatio(5);
     stats.request_hit_disk_ratio60 = statRequestHitDiskRatio(60);
 
-    stats.store_swap_size = Store::Root().currentSize();
+    stats.store_swap_size = Store::Root().currentSize() / 1024.0;
     stats.store_swap_max_size = Store::Root().maxSize();
 
     stats.store_mem_size = mem_node::StoreMemSize();
@@ -555,7 +555,7 @@ GetInfo(Mgr::InfoActionData& stats)
 
     stats.n_disk_objects = Store::Root().currentCount();
     stats.objects_size = stats.n_disk_objects > 0 ?
-        (double)Store::Root().currentSize() / stats.n_disk_objects : 0.0;
+        stats.store_swap_size / stats.n_disk_objects : 0.0;
 
     stats.unlink_requests = statCounter.unlink.requests;
 
index 14649ab5f1c858fc2bc83cc459f1bfa99733ab85..2960193aa0990e1a0559e9d47aba4dc1f1d450e5 100644 (file)
@@ -507,7 +507,7 @@ storeDigestCalcCap(void)
      * number of _entries_ we want to pre-allocate for.
      */
     const int hi_cap = Store::Root().maxSize() / Config.Store.avgObjectSize;
-    const int lo_cap = 1 + Store::Root().currentSize() / Config.Store.avgObjectSize;
+    const int lo_cap = 1 + (Store::Root().currentSize() >> 10) / Config.Store.avgObjectSize;
     const int e_count = StoreEntry::inUseCount();
     int cap = e_count ? e_count :hi_cap;
     debugs(71, 2, "storeDigestCalcCap: have: " << e_count << ", want " << cap <<
index 11ff8c6b47a97c89c5d1221a7a87fdd1d36e9366..5386d02f1363af7d9926eaac19f87874e812574b 100644 (file)
@@ -345,16 +345,17 @@ SwapDir::updateSize(int64_t size, int sign)
 void
 StoreController::stat(StoreEntry &output) const
 {
+    const double currentSizeInKB = currentSize() / 1024.0;
     storeAppendPrintf(&output, "Store Directory Statistics:\n");
     storeAppendPrintf(&output, "Store Entries          : %lu\n",
                       (unsigned long int)StoreEntry::inUseCount());
     storeAppendPrintf(&output, "Maximum Swap Size      : %"PRIu64" KB\n",
                       maxSize());
-    storeAppendPrintf(&output, "Current Store Swap Size: %"PRIu64" KB\n",
-                      currentSize());
-    storeAppendPrintf(&output, "Current Capacity       : %"PRId64"%% used, %"PRId64"%% free\n",
-                      Math::int64Percent(currentSize(), maxSize()),
-                      Math::int64Percent((maxSize() - currentSize()), maxSize()));
+    storeAppendPrintf(&output, "Current Store Swap Size: %.2f KB\n",
+                      currentSizeInKB);
+    storeAppendPrintf(&output, "Current Capacity       : %.2f%% used, %.2f%% free\n",
+                      Math::doublePercent(currentSizeInKB, maxSize()),
+                      Math::doublePercent((maxSize() - currentSizeInKB), maxSize()));
 
     if (memStore)
         memStore->stat(output);
index 1c3edea5f6e356af4b1c94e1e886a2c43dacc2c7..038c53716805b70ef7c7b240812f0a25f4ddfcfc 100644 (file)
@@ -111,7 +111,7 @@ storeCleanup(void *datanotused)
     if (currentSearch->isDone()) {
         debugs(20, 1, "  Completed Validation Procedure");
         debugs(20, 1, "  Validated " << validated << " Entries");
-        debugs(20, 1, "  store_swap_size = " << Store::Root().currentSize());
+        debugs(20, 1, "  store_swap_size = " << Store::Root().currentSize() / 1024.0 << " KB");
         StoreController::store_dirs_rebuilding--;
         assert(0 == StoreController::store_dirs_rebuilding);