diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 18:33:20 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 18:33:20 +0000 |
commit | eea0a9fcf4ed6ef41577672a16af65f495850323 (patch) | |
tree | 47f6c976a2de5af52a47030e90c1a6fdd221ba71 /net/disk_cache | |
parent | 9ef35dfb1f9c1d63a851123a38add59e8846bade (diff) | |
download | chromium_src-eea0a9fcf4ed6ef41577672a16af65f495850323.zip chromium_src-eea0a9fcf4ed6ef41577672a16af65f495850323.tar.gz chromium_src-eea0a9fcf4ed6ef41577672a16af65f495850323.tar.bz2 |
Disk Cache: Add a histogram to track list head corruption.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10561012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/rankings.cc | 46 | ||||
-rw-r--r-- | net/disk_cache/rankings.h | 4 |
2 files changed, 49 insertions, 1 deletions
diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc index a14a37a..99ed927 100644 --- a/net/disk_cache/rankings.cc +++ b/net/disk_cache/rankings.cc @@ -492,6 +492,8 @@ int Rankings::SelfCheck() { total += partial; } CACHE_UMA(AGE_MS, "ListSelfCheckTime", 0, start); + + QuickListCheck(); return total; } @@ -785,7 +787,7 @@ int Rankings::CheckList(List list) { int head_items; int rv = CheckListSection(list, last1, last2, true, // Head to tail. &last1, &last2, &head_items); - if (rv == 0) + if (rv == ERR_NO_ERROR) return head_items; Addr last3, last4; @@ -896,6 +898,48 @@ int Rankings::CheckListSection(List list, Addr end1, Addr end2, bool forward, return ERR_NO_ERROR; } +// TODO(rvargas): remove when we figure why we have corrupt heads. +void Rankings::QuickListCheck() { + for (int i = 0; i < LAST_ELEMENT; i++) { + int rv = CheckHeadAndTail(static_cast<List>(i)); + CACHE_UMA(CACHE_ERROR, "QuickListCheck", 0, rv); + } +} + +int Rankings::CheckHeadAndTail(List list) { + Addr head_addr = heads_[list]; + Addr tail_addr = tails_[list]; + + if (!head_addr.is_initialized() && !tail_addr.is_initialized()) + return ERR_NO_ERROR; + + if (!head_addr.SanityCheckForRankings()) + return ERR_INVALID_HEAD; + + if (!tail_addr.SanityCheckForRankings()) + return ERR_INVALID_TAIL; + + scoped_ptr<CacheRankingsBlock> head; + head.reset(new CacheRankingsBlock(backend_->File(head_addr), head_addr)); + head->Load(); + if (!SanityCheck(head.get(), true)) // From list. + return ERR_INVALID_ENTRY; + + scoped_ptr<CacheRankingsBlock> tail; + tail.reset(new CacheRankingsBlock(backend_->File(tail_addr), tail_addr)); + tail->Load(); + if (!SanityCheck(tail.get(), true)) // From list. + return ERR_INVALID_ENTRY; + + if (head->Data()->prev != head_addr.value()) + return ERR_INVALID_PREV; + + if (tail->Data()->next != tail_addr.value()) + return ERR_INVALID_NEXT; + + return ERR_NO_ERROR; +} + bool Rankings::IsHead(CacheAddr addr, List* list) const { for (int i = 0; i < LAST_ELEMENT; i++) { if (addr == heads_[i].value()) { diff --git a/net/disk_cache/rankings.h b/net/disk_cache/rankings.h index b20e3f1..0886e0c 100644 --- a/net/disk_cache/rankings.h +++ b/net/disk_cache/rankings.h @@ -181,6 +181,10 @@ class Rankings { // and the addresses of the last nodes visited. int CheckListSection(List list, Addr end1, Addr end2, bool forward, Addr* last, Addr* second_last, int* num_items); + void QuickListCheck(); + + // Returns an error code as appropriate. + int CheckHeadAndTail(List list); // Returns true if addr is the head or tail of any list. When there is a // match |list| will contain the list number for |addr|. |