]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove updateSize() from Store and make it protected in SwapDir.
authorDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Wed, 27 Apr 2011 20:30:31 +0000 (00:30 +0400)
committerDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Wed, 27 Apr 2011 20:30:31 +0000 (00:30 +0400)
A new SwapDir public method swappedOut() added. It is called from
storeSwapOutFileClosed() to notify SwapDir that an object was swapped
out.

17 files changed:
src/MemStore.cc
src/MemStore.h
src/Store.h
src/StoreHashIndex.h
src/SwapDir.h
src/fs/coss/CossSwapDir.h
src/fs/coss/store_dir_coss.cc
src/fs/coss/store_io_coss.cc
src/fs/rock/RockSwapDir.cc
src/fs/rock/RockSwapDir.h
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/ufscommon.h
src/store.cc
src/store_dir.cc
src/store_rebuild.cc
src/store_swapout.cc
src/tests/testStore.h

index fe744d95c2bb419a7b7f4044090ee26611574605..dba2d1cc708f54916a4b856b7a51396e9e82d32e 100644 (file)
@@ -109,13 +109,6 @@ MemStore::maxObjectSize() const
     return Ipc::Mem::PageSize();
 }
 
-void
-MemStore::updateSize(int64_t eSize, int sign)
-{
-    // XXX: irrelevant, but Store parent forces us to implement this
-    fatal("MemStore::updateSize should not be called");
-}
-
 void
 MemStore::reference(StoreEntry &)
 {
index 393f6a2e3dad439d5a880a579a3bbc1a5e3387c2..16710fd29c887915b8cff22c7f1d9b65efba89a7 100644 (file)
@@ -41,7 +41,6 @@ public:
     virtual void reference(StoreEntry &);
     virtual void dereference(StoreEntry &);
     virtual void maintain();
-    virtual void updateSize(int64_t size, int sign);
 
     static int64_t EntryLimit();
 
index de48b5187ba2b8e82312bfc3b54f143972e5b8e2..22d0615fac58020a88317a44af2925fdf4c38864 100644 (file)
@@ -336,9 +336,6 @@ public:
     /// called when the entry is no longer needed by any transaction
     virtual void handleIdleEntry(StoreEntry &e) {}
 
-    /* These should really be private */
-    virtual void updateSize(int64_t size, int sign) = 0;
-
 private:
     static RefCount<Store> CurrentRoot;
 };
index b3badea2adfdfbdfe147bb41701589956aea2567..f7b78a73a0cefa5e6b7bbb0b11d6237c853df1c1 100644 (file)
@@ -81,8 +81,6 @@ public:
 
     virtual void maintain();
 
-    virtual void updateSize(int64_t, int);
-
     virtual StoreSearch *search(String const url, HttpRequest *);
 
 private:
index 16c1000fc313c1ee67fe565a69b3bf350ccdd3d1..be9c58273f4130c5219e6609ac57631198a5bb3b 100644 (file)
@@ -85,8 +85,6 @@ public:
 
     virtual void dereference(StoreEntry &);    /* Unreference this object */
 
-    virtual void updateSize(int64_t size, int sign);
-
     /* the number of store dirs being rebuilt. */
     static int store_dirs_rebuilding;
 
@@ -163,6 +161,9 @@ public:
     /// called when the entry is about to forget its association with cache_dir
     virtual void disconnect(StoreEntry &) {}
 
+    /// called when entry swap out is complete
+    virtual void swappedOut(const StoreEntry &e) = 0;
+
 protected:
     void parseOptions(int reconfiguring);
     void dumpOptions(StoreEntry * e) const;
index 07bc9c0496e81dbb6f67d441f68cc55cb19ce3d7..5e6b89018448ac28afb496aec46474c0d3685df7 100644 (file)
@@ -49,6 +49,7 @@ public:
     virtual void logEntry(const StoreEntry & e, int op) const;
     virtual void parse (int index, char *path);
     virtual void reconfigure (int, char *);
+    virtual void swappedOut(const StoreEntry &e);
     /* internals */
     virtual off_t storeCossFilenoToDiskOffset(sfileno);
     virtual sfileno storeCossDiskOffsetToFileno(off_t);
index 90b5c22a3087603fd763c404bdac257666b4942d..4297ba95c77c79b42fa9768cf5b3058958beb4d7 100644 (file)
@@ -539,6 +539,7 @@ storeCossAddDiskRestore(CossSwapDir * SD, const cache_key * key,
     EBIT_CLR(e->flags, KEY_PRIVATE);
     e->ping_status = PING_NONE;
     EBIT_CLR(e->flags, ENTRY_VALIDATED);
+    SD->updateSize(e->swap_file_sz, 1);
     e->hashInsert(key);        /* do it after we clear KEY_PRIVATE */
     storeCossAdd(SD, e);
     assert(e->swap_filen >= 0);
@@ -1079,6 +1080,12 @@ CossSwapDir::reconfigure(int index, char *path)
         fatal("COSS requires max-size to be set to something other than -1!\n");
 }
 
+void
+CossSwapDir::swappedOut(const StoreEntry &e)
+{
+    updateSize(e.swap_file_sz, 1);
+}
+
 void
 CossSwapDir::dump(StoreEntry &entry)const
 {
index d0c2cf7af93e5e106d13eeb5172f59de83208a17..36d3429634e9bbcecc21d856be1d7b2b9605a78a 100644 (file)
@@ -134,6 +134,8 @@ void
 CossSwapDir::unlink(StoreEntry & e)
 {
     debugs(79, 3, "storeCossUnlink: offset " << e.swap_filen);
+    if (e.swap_status == SWAPOUT_DONE && EBIT_TEST(e.flags, ENTRY_VALIDATED))
+        updateSize(e.swap_file_sz, -1);
     StoreFScoss::GetInstance().stats.unlink.ops++;
     StoreFScoss::GetInstance().stats.unlink.success++;
     storeCossRemove(this, &e);
index 5e2abdfabcebc1161d0cfbe361ffc0801801ad31..e8f6e33745078caa9730c34ec6e53806bb796e90 100644 (file)
@@ -117,6 +117,12 @@ Rock::SwapDir::doReportStat() const
     return ::SwapDir::doReportStat() && (!UsingSmp() || IamDiskProcess());
 }
 
+void
+Rock::SwapDir::swappedOut(const StoreEntry &)
+{
+    // stats are not stored but computed when needed
+}
+
 int64_t
 Rock::SwapDir::entryLimitAllowed() const
 {
@@ -535,12 +541,6 @@ Rock::SwapDir::full() const
     return map && map->full();
 }
 
-void
-Rock::SwapDir::updateSize(int64_t size, int sign)
-{
-    // stats are not stored but computed when needed
-}
-
 // storeSwapOutFileClosed calls this nethod on DISK_NO_SPACE_LEFT,
 // but it should not happen for us
 void
index 17ed2156dc3ac5e267e863b53936f34b70db9a98..e43945d7bff66779a7d1508962241785244afdb2 100644 (file)
@@ -30,6 +30,7 @@ public:
     virtual uint64_t currentSize() const;
     virtual uint64_t currentCount() const;
     virtual bool doReportStat() const;
+    virtual void swappedOut(const StoreEntry &e);
 
     int64_t entryLimitHigh() const { return 0xFFFFFF; } /// Core sfileno maximum
     int64_t entryLimitAllowed() const;
@@ -48,7 +49,6 @@ protected:
     virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
     virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
     virtual void maintain();
-    virtual void updateSize(int64_t size, int sign);
     virtual void diskFull();
     virtual void reference(StoreEntry &e);
     virtual void dereference(StoreEntry &e);
index 7d4f8d80de8144200e42847ab7e4b9927db224de..a1e5845d18b7b448418af699348a6c7b90d376f7 100644 (file)
@@ -718,6 +718,7 @@ UFSSwapDir::addDiskRestore(const cache_key * key,
     e->ping_status = PING_NONE;
     EBIT_CLR(e->flags, ENTRY_VALIDATED);
     mapBitSet(e->swap_filen);
+    updateSize(e->swap_file_sz, 1);
     e->hashInsert(key);        /* do it after we clear KEY_PRIVATE */
     replacementAdd (e);
     return e;
@@ -1289,6 +1290,8 @@ UFSSwapDir::unlink(StoreEntry & e)
 {
     debugs(79, 3, "storeUfsUnlink: dirno " << index  << ", fileno "<<
            std::setfill('0') << std::hex << std::uppercase << std::setw(8) << e.swap_filen);
+    if (e.swap_status == SWAPOUT_DONE && EBIT_TEST(e.flags, ENTRY_VALIDATED))
+        updateSize(e.swap_file_sz, -1);
     replacementRemove(&e);
     mapBitReset(e.swap_filen);
     UFSSwapDir::unlinkFile(e.swap_filen);
@@ -1364,6 +1367,12 @@ UFSSwapDir::sync()
     IO->sync();
 }
 
+void
+UFSSwapDir::swappedOut(const StoreEntry &e)
+{
+    updateSize(e.swap_file_sz, 1);
+}
+
 StoreSearch *
 UFSSwapDir::search(String const url, HttpRequest *request)
 {
index 0c6c0c365741d2ff4f042e52b9337c276b29b25c..dfa9235c81b327629799df06496734f0037c4592 100644 (file)
@@ -76,6 +76,7 @@ public:
     virtual void reconfigure(int, char *);
     virtual int callback();
     virtual void sync();
+    virtual void swappedOut(const StoreEntry &e);
 
     void unlinkFile(sfileno f);
     // move down when unlink is a virtual method
index 37ab844696dc8135f3721d431166b44410a25100..ebb15d1efc6239aee53d4b0f10a20839a8c6b3e4 100644 (file)
@@ -1288,13 +1288,6 @@ StoreEntry::release()
     storeLog(STORE_LOG_RELEASE, this);
 
     if (swap_filen > -1) {
-
-        // update size before unlink() below clears swap_status
-        // TODO: the store/SwapDir::unlink should update the size!
-        if (swap_status == SWAPOUT_DONE)
-            if (EBIT_TEST(flags, ENTRY_VALIDATED))
-                store()->updateSize(swap_file_sz, -1);
-
         // log before unlink() below clears swap_filen
         if (!EBIT_TEST(flags, KEY_PRIVATE))
             storeDirSwapLog(this, SWAP_LOG_DEL);
index 95c9995a273af1ec50e888cb0b6d09585d5da152..dbbaecd1fb6f18a29310a3dfde0e973990b608da 100644 (file)
@@ -323,12 +323,6 @@ storeDirSwapLog(const StoreEntry * e, int op)
     dynamic_cast<SwapDir *>(INDEXSD(e->swap_dirn))->logEntry(*e, op);
 }
 
-void
-StoreController::updateSize(int64_t size, int sign)
-{
-    fatal("StoreController has no independent size\n");
-}
-
 void
 SwapDir::updateSize(int64_t size, int sign)
 {
@@ -1014,10 +1008,6 @@ StoreHashIndex::maintain()
     }
 }
 
-void
-StoreHashIndex::updateSize(int64_t, int)
-{}
-
 void
 StoreHashIndex::sync()
 {
index 038c53716805b70ef7c7b240812f0a25f4ddfcfc..09676644912745652bbd19c0496e1616018be999 100644 (file)
@@ -99,10 +99,6 @@ storeCleanup(void *datanotused)
          * otherwise, set it in the validation procedure
          */
 
-
-        if (e->swap_status == SWAPOUT_DONE)
-            e->store()->updateSize(e->swap_file_sz, 1);
-
         if ((++validated & 0x3FFFF) == 0)
             /* TODO format the int with with a stream operator */
             debugs(20, 1, "  " << validated << " Entries Validated so far.");
index a2d613bf9eaa20757a7b5022c013411b0effee2d..3fac1bde6a4c6b1c69da82a8984a1702e300f462 100644 (file)
@@ -354,7 +354,7 @@ storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self)
         assert(e->objectLen() >= 0); // we checked that above
         e->swap_file_sz = e->objectLen() + mem->swap_hdr_sz;
         e->swap_status = SWAPOUT_DONE;
-        e->store()->updateSize(e->swap_file_sz, 1);
+        e->store()->swappedOut(*e);
 
         // XXX: For some Stores, it is pointless to re-check cachability here
         // and it leads to double counts in store_check_cachable_hist. We need
index fbdf7e0b4106b0e7742c2c61776b55c91ea7f4db..08ceebaeaef37bef147dd9b9e35f5764d625c5bc 100644 (file)
@@ -65,8 +65,6 @@ public:
 
     virtual void dereference(StoreEntry &) {}  /* Unreference this object */
 
-    virtual void updateSize(int64_t size, int sign) {}
-
     virtual StoreSearch *search(String const url, HttpRequest *);
 };