sbin/hammer: Assert simplified blockmap allocator
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Fri, 17 Jul 2015 11:36:07 +0000 (20:36 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Fri, 17 Jul 2015 16:36:10 +0000 (01:36 +0900)
commit0d1f608583649369f4bdd520c29f342b2d3806d8
tree0b269f98792bc8d13e829ebfc015441c96e68b6e
parent042505d78e02ba5179ed11b7b1ae4de14cc0a2f6
sbin/hammer: Assert simplified blockmap allocator

- alloc_blockmap() is a simplified blockmap allocator of
  kernel function hammer_blockmap_alloc() as the comment says.
  alloc_blockmap() is not aware of layer1 boundary since it
  lacks layer1 boundary check and zone wrap check. This still
  works for newfs_hammer because it's guaranteed that the newfs
  never hits layer1 boundary even in the worst case[*] when
  there are 2^8 volumes and each volume is 2^52 bytes storage.

- This commit adds assertions to ensure it's safe to use the
  simplified allocator. If a caller hits the assertions then
  the program does more than what this allocator supports.

  --
  [*] In the worst case each volume has 2^(18-8) big-blocks
  for layer2 metadata which totals (8[MB] * 1024) = 8[GB].
  Other than layer2 metadata, the root volume has 1 big-block
  for layer1 metadata, less than 128 big-blocks for undo fifo,
  and 1 big-block for btree and meta zone each. These add up
  to somewhere between 8-10[GB] but it's still far less than
  a single layer1 capacity of 4[TB]. Non-root volumes consume
  a bit less than the root volume since it only has layer2
  metadata initially which also fits in a single layer1.
  The blockmaps for the root and non-root volumes would look
  something like the following.

  volume#0
   zone  big-blocks   note
  ==============================================================
      4           1   2^18 * layer1 = 2^(18+5) = 8[MB]
      4        1024   2^19 * layer2 * 1024 = 2^(19+4+10) = 8[GB]
      3           n   undo zone for undo fifo (n <= 128)
      8           1   btree zone for root btree node
      9           1   meta zone for root inode and pfs0

  volume#N (0<N<256)
   zone  big-blocks   note
  ==============================================================
      4        1024   2^19 * layer2 * 1024 = 2^(19+4+10) = 8[GB]
sbin/hammer/ondisk.c