From: Alex Rousskov Date: Thu, 15 Aug 2013 22:26:40 +0000 (-0600) Subject: Fixed swap_file_sz calculation when loading rock entries. Polished debugging. X-Git-Tag: SQUID_3_5_0_1~444^2~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ce44c1eab14b97a2fc9fbacc830f9224e675d49f;p=thirdparty%2Fsquid.git Fixed swap_file_sz calculation when loading rock entries. Polished debugging. Supply storeRebuildParseEntry() with known "swap file size" so that it can adjust swap_file_sz after loading store entry meta info. Entries are often stored with swap_file_sz in the meta header missing the swap_hdr_len component. storeRebuildParseEntry() adds swap_hdr_len when needed, using known entry size to detect that need. --- diff --git a/src/fs/rock/RockRebuild.cc b/src/fs/rock/RockRebuild.cc index 586a0a10eb..454bf00652 100644 --- a/src/fs/rock/RockRebuild.cc +++ b/src/fs/rock/RockRebuild.cc @@ -244,7 +244,8 @@ Rock::Rebuild::loadOneSlot() DbCellHeader header; if (buf.contentSize() < static_cast(sizeof(header))) { debugs(47, DBG_IMPORTANT, "WARNING: cache_dir[" << sd->index << "]: " << - "Ignoring truncated cache entry meta data at " << dbOffset); + "Ignoring truncated " << buf.contentSize() << "-byte " << + "cache entry meta data at " << dbOffset); freeSlotIfIdle(slotId, true); return; } @@ -271,16 +272,15 @@ Rock::Rebuild::importEntry(Ipc::StoreMapAnchor &anchor, const sfileno fileno, co { cache_key key[SQUID_MD5_DIGEST_LENGTH]; StoreEntry loadedE; - if (!storeRebuildParseEntry(buf, loadedE, key, counts, 0)) - return false; - const uint64_t knownSize = header.entrySize > 0 ? header.entrySize : anchor.basics.swap_file_sz.get(); - if (!loadedE.swap_file_sz && knownSize) - loadedE.swap_file_sz = knownSize; + if (!storeRebuildParseEntry(buf, loadedE, key, counts, knownSize)) + return false; + // the entry size may still be unknown at this time - debugs(47, 8, "importing entry basics for " << fileno); + debugs(47, 8, "importing basics for entry " << fileno << + " swap_file_sz: " << loadedE.swap_file_sz); anchor.set(loadedE); // we have not validated whether all db cells for this entry were loaded @@ -478,6 +478,7 @@ Rock::Rebuild::addSlotToEntry(const sfileno fileno, const SlotId slotId, const D } // set total entry size and/or check it for consistency + debugs(47, 8, "header.entrySize: " << header.entrySize << " swap_file_sz: " << anchor.basics.swap_file_sz); uint64_t totalSize = header.entrySize; assert(totalSize != static_cast(-1)); if (!totalSize && anchor.basics.swap_file_sz) { @@ -498,6 +499,7 @@ Rock::Rebuild::addSlotToEntry(const sfileno fileno, const SlotId slotId, const D le.size += header.payloadSize; if (totalSize > 0 && le.size > totalSize) { // overflow + debugs(47, 8, "overflow: " << le.size << " > " << totalSize); le.state = LoadingEntry::leCorrupted; freeBadEntry(fileno, "overflowing"); return;