From: Alex Rousskov Date: Thu, 12 May 2011 03:58:16 +0000 (-0600) Subject: Removed Rock-specific code from StoreController. X-Git-Tag: take07~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c973bebfe1d87d518fd2ac3ea9805e8192b1ede;p=thirdparty%2Fsquid.git Removed Rock-specific code from StoreController. Allow Store::dereference(e) to indicate whether the entry should be kept in the global index. Old SwapDirs keep it. Newer code that maintains entry tables dedicated to each cache_dir does not. --- diff --git a/src/MemStore.cc b/src/MemStore.cc index 1515436596..c9f77a86c4 100644 --- a/src/MemStore.cc +++ b/src/MemStore.cc @@ -113,9 +113,11 @@ MemStore::reference(StoreEntry &) { } -void +bool MemStore::dereference(StoreEntry &) { + // no need to keep e in the global store_table for us; we have our own map + return false; } int diff --git a/src/MemStore.h b/src/MemStore.h index 16710fd29c..7f803d7908 100644 --- a/src/MemStore.h +++ b/src/MemStore.h @@ -39,7 +39,7 @@ public: virtual void stat(StoreEntry &) const; virtual StoreSearch *search(String const url, HttpRequest *); virtual void reference(StoreEntry &); - virtual void dereference(StoreEntry &); + virtual bool dereference(StoreEntry &); virtual void maintain(); static int64_t EntryLimit(); diff --git a/src/Store.h b/src/Store.h index ccb50f8ab4..254e18cd65 100644 --- a/src/Store.h +++ b/src/Store.h @@ -328,7 +328,8 @@ public: /* pulled up from SwapDir for migration.... probably do not belong here */ virtual void reference(StoreEntry &) = 0; /* Reference this object */ - virtual void dereference(StoreEntry &) = 0; /* Unreference this object */ + /// Undo reference(), returning false iff idle e should be destroyed + virtual bool dereference(StoreEntry &e) = 0; virtual void maintain() = 0; /* perform regular maintenance should be private and self registered ... */ diff --git a/src/StoreHashIndex.h b/src/StoreHashIndex.h index f7b78a73a0..4ec269f429 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -77,7 +77,7 @@ public: virtual void reference(StoreEntry&); - virtual void dereference(StoreEntry&); + virtual bool dereference(StoreEntry&); virtual void maintain(); diff --git a/src/SwapDir.cc b/src/SwapDir.cc index 913c4e673d..cb0fcf3c60 100644 --- a/src/SwapDir.cc +++ b/src/SwapDir.cc @@ -103,8 +103,11 @@ SwapDir::minSize() const void SwapDir::reference(StoreEntry &) {} -void -SwapDir::dereference(StoreEntry &) {} +bool +SwapDir::dereference(StoreEntry &) +{ + return true; // keep in global store_table +} int SwapDir::callback() diff --git a/src/SwapDir.h b/src/SwapDir.h index a92f7079a0..4e5558491c 100644 --- a/src/SwapDir.h +++ b/src/SwapDir.h @@ -83,7 +83,7 @@ public: virtual void reference(StoreEntry &); /* Reference this object */ - virtual void dereference(StoreEntry &); /* Unreference this object */ + virtual bool dereference(StoreEntry &); /* Unreference this object */ /* the number of store dirs being rebuilt. */ static int store_dirs_rebuilding; @@ -199,7 +199,7 @@ public: virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const = 0; /* These two are notifications */ virtual void reference(StoreEntry &); /* Reference this object */ - virtual void dereference(StoreEntry &); /* Unreference this object */ + virtual bool dereference(StoreEntry &); /* Unreference this object */ virtual int callback(); /* Handle pending callbacks */ virtual void sync(); /* Sync the store prior to shutdown */ virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *) = 0; diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index bcafc17e2c..ddb3c11465 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -608,12 +608,15 @@ Rock::SwapDir::reference(StoreEntry &e) repl->Referenced(repl, &e, &e.repl); } -void +bool Rock::SwapDir::dereference(StoreEntry &e) { debugs(47, 5, HERE << &e << ' ' << e.swap_dirn << ' ' << e.swap_filen); if (repl && repl->Dereferenced) repl->Dereferenced(repl, &e, &e.repl); + + // no need to keep e in the global store_table for us; we have our own map + return false; } void diff --git a/src/fs/rock/RockSwapDir.h b/src/fs/rock/RockSwapDir.h index 04c21589e5..095dee5e12 100644 --- a/src/fs/rock/RockSwapDir.h +++ b/src/fs/rock/RockSwapDir.h @@ -48,7 +48,7 @@ protected: virtual void maintain(); virtual void diskFull(); virtual void reference(StoreEntry &e); - virtual void dereference(StoreEntry &e); + virtual bool dereference(StoreEntry &e); virtual void unlink(StoreEntry &e); virtual void statfs(StoreEntry &e) const; diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index da36b6396c..f1014300aa 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -424,13 +424,15 @@ UFSSwapDir::reference(StoreEntry &e) * This routine is called whenever the last reference to an object is * removed, to maintain replacement information within the storage fs. */ -void +bool UFSSwapDir::dereference(StoreEntry & e) { debugs(47, 3, "UFSSwapDir::dereference: referencing " << &e << " " << e.swap_dirn << "/" << e.swap_filen); if (repl->Dereferenced) repl->Dereferenced(repl, &e, &e.repl); + + return true; // keep e in the global store_table } StoreIOState::Pointer diff --git a/src/fs/ufs/ufscommon.h b/src/fs/ufs/ufscommon.h index 883c99f9d4..35fad81a08 100644 --- a/src/fs/ufs/ufscommon.h +++ b/src/fs/ufs/ufscommon.h @@ -64,7 +64,7 @@ public: virtual void maintain(); virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const; virtual void reference(StoreEntry &); - virtual void dereference(StoreEntry &); + virtual bool dereference(StoreEntry &); virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); virtual void openLog(); diff --git a/src/store_dir.cc b/src/store_dir.cc index 4f414b3183..699e9e35a3 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -665,7 +665,7 @@ StoreController::reference(StoreEntry &e) /* Notify the fs that we're referencing this object again */ if (e.swap_dirn > -1) - e.store()->reference(e); + swapDir->reference(e); // Notify the memory cache that we're referencing this object again if (memStore && e.mem_status == IN_MEMORY) @@ -678,23 +678,27 @@ StoreController::reference(StoreEntry &e) } } -void +bool StoreController::dereference(StoreEntry & e) { + bool keepInStoreTable = false; + /* Notify the fs that we're not referencing this object any more */ if (e.swap_filen > -1) - e.store()->dereference(e); + keepInStoreTable = swapDir->dereference(e) || keepInStoreTable; // Notify the memory cache that we're not referencing this object any more if (memStore && e.mem_status == IN_MEMORY) - memStore->dereference(e); + keepInStoreTable = memStore->dereference(e) || keepInStoreTable; // TODO: move this code to a non-shared memory cache class when we have it if (e.mem_obj) { if (mem_policy->Dereferenced) mem_policy->Dereferenced(mem_policy, &e, &e.mem_obj->repl); } + + return keepInStoreTable; } StoreEntry * @@ -758,11 +762,9 @@ StoreController::handleIdleEntry(StoreEntry &e) (mem_node::InUseCount() <= store_pages_max); } - dereference(e); - - // XXX: Rock store specific: Since each SwapDir controls its index, - // unlocked entries should not stay in the global store_table. - if (fileno >= 0) { + // An idle, unlocked entry that belongs to a SwapDir which controls + // its own index, should not stay in the global store_table. + if (!dereference(e)) { debugs(20, 5, HERE << "destroying unlocked entry: " << &e << ' ' << e); destroyStoreEntry(static_cast(&e)); return; @@ -972,12 +974,16 @@ StoreHashIndex::stat(StoreEntry & output) const } void -StoreHashIndex::reference(StoreEntry&) -{} +StoreHashIndex::reference(StoreEntry &e) +{ + e.store()->reference(e); +} -void -StoreHashIndex::dereference(StoreEntry&) -{} +bool +StoreHashIndex::dereference(StoreEntry &e) +{ + return e.store()->dereference(e); +} void StoreHashIndex::maintain() diff --git a/src/tests/testStore.h b/src/tests/testStore.h index 08ceebaeae..a0c65fa476 100644 --- a/src/tests/testStore.h +++ b/src/tests/testStore.h @@ -63,7 +63,7 @@ public: virtual void reference(StoreEntry &) {} /* Reference this object */ - virtual void dereference(StoreEntry &) {} /* Unreference this object */ + virtual bool dereference(StoreEntry &) { return true; } virtual StoreSearch *search(String const url, HttpRequest *); };