sbin/hammer: Fix wrong free big-blocks counter
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 16 Jul 2015 15:50:05 +0000 (00:50 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Fri, 17 Jul 2015 16:36:09 +0000 (01:36 +0900)
commit042505d78e02ba5179ed11b7b1ae4de14cc0a2f6
tree5fb1b47886e19a25096f45cefbf39708d161bd9b
parente6b88827fa5a12956398eebd9a708d92e24e9e7e
sbin/hammer: Fix wrong free big-blocks counter

- newfs_hammer needs to decrement extra 2 big-blocks from
  vol0_stat_freebigblocks for zone 8 and 9.

- newfs_hammer has following three lines that allocate the root
  inode, root btree node, and pfs0 metadata for zone 8 and 9,
  however because alloc_blockmap() doesn't decrement vol0_stat
  _freebigblocks when a blockmap first meets a new layer2,
  the volume header shows vol0_stat_freebigblocks 2 more than
  it actually is.

  bnode = alloc_btree_element(&btree_off, &data_buffer0);
  idata = alloc_meta_element(&data_off, sizeof(*idata), &data_buffer1);
  pfsd = alloc_meta_element(&pfsd_off, sizeof(*pfsd), &data_buffer2);

- This also means vol0_stat_bigblocks and vol0_stat_freebigblocks
  are not equal initially. This commit makes vol0_stat_bigblocks
  equal (vol0_stat_freebigblocks + 2), while these two were equal
  until this commit. This should make sense than decrementing
  vol0_stat_bigblocks by 2 to make these two look the same,
  because inodes and btree nodes allocated by regular filesystem
  operations do decrement vol0_stat_freebigblocks whenever a new
  big-block is allocated and those are counted as used big-blocks.
  The initial inode, btree node and pfs shouldn't be an exception.
  The diff of hammer info command right after newfs_hammer would
  look like this.

  ==========
  # diff -aNur ./before ./after
  --- ./before 2015-07-17 03:17:10.999193000 +0900
  +++ ./after 2015-07-17 03:17:14.649193000 +0900
  @@ -1,17 +1,17 @@
  <snip>
   Big-block information
    Total          178376
  - Used                0 (0.00%)
  + Used                2 (0.00%)  /* inode/btree/pfs0 */
    Reserved           45 (0.03%)
  - Free           178331 (99.97%)
  + Free           178329 (99.97%) /* 2 less than before */
   Space information
    No. Inodes          1
    Total size       1.4T (1496326340608 bytes)
  - Used               0B (0.00%)
  + Used              16M (0.00%)  /* 2x8[MB] more than before */
    Reserved         360M (0.03%)
    Free             1.4T (99.97%)
   PFS information
  ==========
sbin/hammer/ondisk.c
sbin/newfs_hammer/newfs_hammer.c
sys/vfs/hammer/hammer_disk.h