From: Dmitry Kurochkin Date: Wed, 27 Apr 2011 20:30:31 +0000 (+0400) Subject: Remove updateSize() from Store and make it protected in SwapDir. X-Git-Tag: take07~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da9d3191b043c07215fbb771c69acc4a835d7b96;p=thirdparty%2Fsquid.git Remove updateSize() from Store and make it protected in SwapDir. A new SwapDir public method swappedOut() added. It is called from storeSwapOutFileClosed() to notify SwapDir that an object was swapped out. --- diff --git a/src/MemStore.cc b/src/MemStore.cc index fe744d95c2..dba2d1cc70 100644 --- a/src/MemStore.cc +++ b/src/MemStore.cc @@ -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 &) { diff --git a/src/MemStore.h b/src/MemStore.h index 393f6a2e3d..16710fd29c 100644 --- a/src/MemStore.h +++ b/src/MemStore.h @@ -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(); diff --git a/src/Store.h b/src/Store.h index de48b5187b..22d0615fac 100644 --- a/src/Store.h +++ b/src/Store.h @@ -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 CurrentRoot; }; diff --git a/src/StoreHashIndex.h b/src/StoreHashIndex.h index b3badea2ad..f7b78a73a0 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -81,8 +81,6 @@ public: virtual void maintain(); - virtual void updateSize(int64_t, int); - virtual StoreSearch *search(String const url, HttpRequest *); private: diff --git a/src/SwapDir.h b/src/SwapDir.h index 16c1000fc3..be9c58273f 100644 --- a/src/SwapDir.h +++ b/src/SwapDir.h @@ -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; diff --git a/src/fs/coss/CossSwapDir.h b/src/fs/coss/CossSwapDir.h index 07bc9c0496..5e6b890184 100644 --- a/src/fs/coss/CossSwapDir.h +++ b/src/fs/coss/CossSwapDir.h @@ -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); diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 90b5c22a30..4297ba95c7 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -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 { diff --git a/src/fs/coss/store_io_coss.cc b/src/fs/coss/store_io_coss.cc index d0c2cf7af9..36d3429634 100644 --- a/src/fs/coss/store_io_coss.cc +++ b/src/fs/coss/store_io_coss.cc @@ -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); diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 5e2abdfabc..e8f6e33745 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -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 diff --git a/src/fs/rock/RockSwapDir.h b/src/fs/rock/RockSwapDir.h index 17ed2156dc..e43945d7bf 100644 --- a/src/fs/rock/RockSwapDir.h +++ b/src/fs/rock/RockSwapDir.h @@ -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); diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 7d4f8d80de..a1e5845d18 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -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) { diff --git a/src/fs/ufs/ufscommon.h b/src/fs/ufs/ufscommon.h index 0c6c0c3657..dfa9235c81 100644 --- a/src/fs/ufs/ufscommon.h +++ b/src/fs/ufs/ufscommon.h @@ -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 diff --git a/src/store.cc b/src/store.cc index 37ab844696..ebb15d1efc 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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); diff --git a/src/store_dir.cc b/src/store_dir.cc index 95c9995a27..dbbaecd1fb 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -323,12 +323,6 @@ storeDirSwapLog(const StoreEntry * e, int op) dynamic_cast(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() { diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 038c537168..0967664491 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -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."); diff --git a/src/store_swapout.cc b/src/store_swapout.cc index a2d613bf9e..3fac1bde6a 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -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 diff --git a/src/tests/testStore.h b/src/tests/testStore.h index fbdf7e0b41..08ceebaeae 100644 --- a/src/tests/testStore.h +++ b/src/tests/testStore.h @@ -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 *); };