git: sbin/hammer: Fix wrong free big-blocks counter

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Fri Jul 17 09:50:05 PDT 2015


commit 042505d78e02ba5179ed11b7b1ae4de14cc0a2f6
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Fri Jul 17 00:50:05 2015 +0900

    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
      ==========

Summary of changes:
 sbin/hammer/ondisk.c             |  1 +
 sbin/newfs_hammer/newfs_hammer.c | 18 +++++++++++++++++-
 sys/vfs/hammer/hammer_disk.h     |  4 +++-
 3 files changed, 21 insertions(+), 2 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/042505d78e02ba5179ed11b7b1ae4de14cc0a2f6


-- 
DragonFly BSD source repository



More information about the Commits mailing list