From: Alex Rousskov Date: Mon, 7 Jan 2013 18:01:37 +0000 (-0700) Subject: Do not reject size-less entries in storeRebuildParseEntry(). Deal with X-Git-Tag: SQUID_3_5_0_1~444^2~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52dce2fe603880a58207179dd8ee2abf76b24834;p=thirdparty%2Fsquid.git Do not reject size-less entries in storeRebuildParseEntry(). Deal with entry size in the caller. Some callers can handle entries that had unknown (at swapout start time) sizes. Added rebuild debugging. --- diff --git a/src/fs/ufs/RebuildState.cc b/src/fs/ufs/RebuildState.cc index eeb3d086e4..6f9d279e13 100644 --- a/src/fs/ufs/RebuildState.cc +++ b/src/fs/ufs/RebuildState.cc @@ -191,15 +191,25 @@ Fs::Ufs::RebuildState::rebuildFromDirectory() if (!storeRebuildLoadEntry(fd, sd->index, buf, counts)) return; + const uint64_t expectedSize = sb.st_size > 0 ? + static_cast(sb.st_size) : 0; + StoreEntry tmpe; - const bool loaded = storeRebuildParseEntry(buf, tmpe, key, counts, - (int64_t)sb.st_size); + const bool parsed = storeRebuildParseEntry(buf, tmpe, key, counts, + expectedSize); file_close(fd); --store_open_disk_fd; fd = -1; - if (!loaded) { + bool accepted = parsed && tmpe.swap_file_sz > 0; + if (parsed && !accepted) { + debugs(47, DBG_IMPORTANT, "WARNING: Ignoring ufs cache entry with " << + "unknown size: " << tmpe); + accepted = false; + } + + if (!accepted) { // XXX: shouldn't this be a call to commonUfsUnlink? sd->unlinkFile(filn); // should we unlink in all failure cases? return; diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index a601b06e6c..aea90f2dfa 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -74,6 +74,7 @@ storeCleanup(void *datanotused) static int store_errors = 0; static StoreSearchPointer currentSearch; static int validated = 0; + static int seen = 0; if (currentSearch == NULL || currentSearch->isDone()) currentSearch = Store::Root().search(NULL, NULL); @@ -86,6 +87,8 @@ storeCleanup(void *datanotused) e = currentSearch->currentItem(); + ++seen; + if (EBIT_TEST(e->flags, ENTRY_VALIDATED)) continue; @@ -113,6 +116,7 @@ storeCleanup(void *datanotused) } if (currentSearch->isDone()) { + debugs(20, 2, "Seen: " << seen << " entries"); debugs(20, DBG_IMPORTANT, " Completed Validation Procedure"); debugs(20, DBG_IMPORTANT, " Validated " << validated << " Entries"); debugs(20, DBG_IMPORTANT, " store_swap_size = " << Store::Root().currentSize() / 1024.0 << " KB"); @@ -368,9 +372,8 @@ storeRebuildParseEntry(MemBuf &buf, StoreEntry &tmpe, cache_key *key, return false; } } else if (tmpe.swap_file_sz <= 0) { - debugs(47, DBG_IMPORTANT, "WARNING: Ignoring cache entry with " << - "unknown size: " << tmpe); - return false; + // if caller cannot handle unknown sizes, it must check after the call. + debugs(47, 7, "unknown size: " << tmpe); } if (EBIT_TEST(tmpe.flags, KEY_PRIVATE)) {