]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 3441: Part 3: Replace corrupted v1 swap.state with new v2 format.
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 10 Apr 2012 04:26:14 +0000 (22:26 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 10 Apr 2012 04:26:14 +0000 (22:26 -0600)
commit786f65163ad3078f7d1152a43eb5825ec79440de
tree57caf65163f68600240e4ad943f6d5e8cbdb0d5a
parent6874cf4494fac168eb79ebf29f68e2362d8967a6
Bug 3441: Part 3: Replace corrupted v1 swap.state with new v2 format.

A fix for bug 3408 changed the offset at which we start writing dirty
swap.state entries from StoreSwapLogHeader::record_size to StoreSwapLogHeader
size.  However, the log-reading code still read the entries starting from the
old offset (which is required to remain compatible with how a clean swap.state
is written).

Wrong starting offset essentially means that the vast majority of read
swap.state entries were bogus. They could only match some real entry when 64*n
is divisible by 12 and perhaps when their random data just happened to match a
real entry. Part 2 of this bug fix (trunk r11995) started to pad the [dirty]
swap.state header to start entry writing at StoreSwapLogHeader::record_size
boundary.

Changes specific to Part 3:

Unfortunately, since old v1 logs could contain completely bogus entries as the
result of being read (at some point) from the wrong offset, we should not load
v1 logs any more (neither dirty nor clean because what looks clean now could
be based on a previously dirty and, hence, corrupted log). This forced us to
raise the swap.state format version from 1 to 2.

After this change, if a v1 swap log is detected, Squid ignores it and does a
from-directory rebuild as if no swap.state files were found.

Since we had to change swap.state format version, we also made log entry size
and composition the same across virtually all platforms; added checksums so
that a similar bug would not go unnoticed for so long (and would not result in
log corruption); and increased the size of time-related entries to avoid the
"year 2038" problem.

The swap log entries are still written to disk in host byte order.

We now also zero the [dirty] swap.state header padding to prevent random and
potentially sensitive garbage in logs.

Cache index rebuild kinds are now reported using the following three labels:

* Rebuild using a swap log created by Squid during clean shutdown: "clean log"
* Rebuild using a swap log accumulated by a running Squid: "dirty log"
* Rebuild using directory scan: "no log"

The first kind used to be reported as CLEAN and the other two as DIRTY rebuild.
src/StoreSwapLogData.cc
src/StoreSwapLogData.h
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/ufscommon.cc