Welcome


The front page shows all the recent posts. To see a more organized view use the tabs above.


The Hash Cache

Posted by Alex at 10:25 PM

In build 11 of WhsDbCheck I introduced the new /keephashcache option to preserve the hash cache from run to run in order to save the reading and hashing time done the first time. I think this option deserves a little more explanation. But before we do that, let’s start with what the hash cache actually is.

When the windows home server stores data, it sores a hash of each cluster along with the actual data. A hash is a small number that can be used to absolutely verify the integrity of a much larger data chunk, any size in fact, for those who don’t know. In the home server each hash is typically used to verify a 4096 byte chunk of data, although this can be variable. I use this hash in a level 4 check to make sure that every single byte that exists is the backup database is the same exact byte that was written at backup time.

I don’t suggest anyone try this, but I did :) You can change a single byte in a data file and see the level 4 check detect the fault. Very cool stuff. Oh, and I mean it, don’t try this unless you have a backup of the database!

So here’s the problem though. In order for the check to be anywhere near reasonably fast, we’re talking hours instead of days or weeks here, we need to load the hashes into memory.

Let’s do some math:

  • If you have a 300 Gigabyte database.
  • 4096 bytes per cluster (this is typical for NTFS).
  • That means you have 78,643,200 hashes.
  • At 16 bytes per hash that would require 1.17 Gigabytes of RAM.

The first generation HP MediaSmart server comes with only 512 MB of RAM. So clearly, this is not going to work if you just load everything into RAM.

After much experimentation, in order to make a level 4 check possible I came up with a clever technique of perform this check in a reasonable amount of time. I call this the hash cache.

Essentially, the hash cache has one important quality, it avoids hard drive seek times at all costs. It turns out that drives and file systems are pretty good at reading a sequential stream, as long as it stays sequential. This is what the hash cache does, and it works well.

So this is where the /hashcache switch comes in. By default, the hash cache uses 256 MB of memory, but you can change that by specifying a new size with /hashcache=(size in MB). E.g. /hashcache=1000. To make the hash cache ~1Gb. This will make a level 4 check faster if you have the RAM. Specifying 0 will turn off the hash cache (not recommended), and specifying a value more than your RAM will be really bad for performance. Specifying a value more than a couple of gigabytes will slow things down too.

Now that I’ve explained what the hash cache is, in the next post I will talk about the new /keephashcache switch and how and when to use it.

WhsDbCheck - 1.0.0 Build 12 BETA

Posted by Alex at 11:19 PM

Notes:

Fixed crash in Level 1, 2 and 3 introduced in last build.

Changes:
  • Fixed crash introduced in last build in Levels 1, 2 and 3 checks.

Download 1.0.0.12 BETA

WhsDbCheck - 1.0.0 Build 11 BETA

Posted by Alex at 8:32 PM

Notes:

Fixed a critical issue that was causing Level 2 checks and above to fail incorrectly on large databases. This was due to the Windows Home Server incorrectly setting the DataSize header to less than the actual data size. We now ignore that header and use the actual file size when reading from a data file. This reduces the effectiveness of a level 2 and a level 3 check somewhat. The level 4 check is not affected. A Level 4 check will still guarantee that every single byte is the same from the day that it was written.

Changes:
  • Changed the index check to use the actual file size instead of the, apparently sometimes incorrect, data size from the header.
  • Fixed GlobalClusterLatest check failure on level 4 with more than 1 pass.
  • Added /keephashcache. Preserves a copy of the hash cache, per index file, for a future run.
  • Hash cache will now allocate only once, preventing out of memory errors.

Download 1.0.0.11 BETA

WhsDbCheck - 1.0.0 Build 10 BETA

Posted by Alex at 9:28 PM

Notes:

Fixed some false positives that were showing up on checking a database with canceled backups. By false positives I mean good databases that were being flagged as bad, not the other way around.

Changes:
  • Fixed BackupSet.Status <> Volume.Status false positive. Just because a backup set has failed does not mean that ALL volume backups part of the set failed. Some could have succeeded.
  • Changed the level 1 Control.NextIndex check to be less aggressive and created a new more comprehensive level 2+ check. The old level 1 check was giving false positives in certain cases.

Download

WhsDbCheck - 1.0.0 Build 9 BETA

Posted by Alex at 11:01 PM

Notes:

A new optimization was added in this build called the hash cache. This is strictly targeted at the level 4 check, and in fact, it's not active on any other check level. The level 4 check on the previous build was VERY slow on machines with small amounts of RAM free or on large databases. The hash cache solves this by explicitly allocating a specific amount of RAM for the second part of the level 4 check, the verification stage. It allocates 256 MB by default but if you have plenty of RAM (gigabytes) and would prefer windows to handle the file caching, you can do that with /hashcache=0.

The more RAM assigned to the hash cache the less passes you have to perform per file verification. With the hash cache off everything is accomplished with one pass but your disk seeks heavily, unless windows caches the hashes into RAM using the built-in OS file system cache.

Also, if you are in the middle of a level 4 verification check with the last build, and it's not moving very fast, you can Ctrl-C it to abort and resume with this new build. Just move the Index.NNNN.dat.md5 file from the temp folder that was created by the tool (WhsDbCheck_Temp) up one level to where the database files are. Then start a level 4 check with this new version and it will find the md5 file, and simulate the read check taking you directly into the verification stage using the new hash cache. Pretty neat.

Changes:
  • Significantly optimized the verification stage of a level 4 check for large databases or systems with a small amount of RAM.
  • Added /hashcache argument to specify how many MB to use for the hash cache.
  • Hash cache can be disabled with /hashcache=0.

Download

WhsDbCheck - 1.0.0 Build 8 ALPHA

Posted by Alex at 5:23 PM

Notes:

This is a fairly big update that includes the all important level 4 test. This test is a complete top to bottom WHS DB verification test. It will rehash ALL the data and verify that it's correct. Also, this version contains a slew of optimizations that are targeted at different test levels. This build is very much untested, so expect bugs. I expect the next build to be a BETA, meaning that this build is very close to feature complete.

Changes:
  • Fixed Volume check on backup failure record.
  • Changed volume check success criteria to Status.
  • Added additional check to make sure backups Status (error condition) is consistent.
  • Added preliminary level 2, 3 and 4 checks. Still not complete.
  • Optimized cluster based file reading.
  • Completed level 2, 3 and 4 checks.
  • Added test elapsed time display.

Download

WhsDbCheck - 1.0.0 Build 3 ALPHA

Posted by Alex at 6:56 PM

Changes:

  • Initial build.
  • Fixed a false positive.
  • Added Index based Data file check to basic consistency check.

Download