]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not reject size-less entries in storeRebuildParseEntry(). Deal with
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 7 Jan 2013 18:01:37 +0000 (11:01 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 7 Jan 2013 18:01:37 +0000 (11:01 -0700)
entry size in the caller.

Some callers can handle entries that had unknown (at swapout start time) sizes.

Added rebuild debugging.

src/fs/ufs/RebuildState.cc
src/store_rebuild.cc

index eeb3d086e4abe7c4818ce32a2d0ca6f5b5a39046..6f9d279e1384f49b4136fa5f042688717182f1ab 100644 (file)
@@ -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<uint64_t>(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;
index a601b06e6c2a7b9d6398e2a50b2ac6d36abcffc9..aea90f2dfa62d41bab52cf50ad74da5f0d4c9edb 100644 (file)
@@ -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)) {