sbin/hammer: Fix memory allocation for zone statistics
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 25 Jul 2015 16:01:33 +0000 (01:01 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 25 Jul 2015 19:51:20 +0000 (04:51 +0900)
commitfff0110a0b936812fc3f14008be83aa396551ce3
tree7015f7f2513357ebeefa03a8d80fbb827d832a8d
parent149299793f827f46e583a944e1732010317ac923
sbin/hammer: Fix memory allocation for zone statistics

- 2550036 allocates unnecessary amount of memory when the
  filesystem consists of >1 volumes and accounting actually
  reaches to the second volume. This commit fixes it by
  splitting bitmap into bitmaps[2^8] where 2^8 is the maximum
  number of volumes. Other than that it's basically the same.

  layer1/layer2 direct map:
      <------> Max 2^8 volumes
  zzzzvvvvvvvvoooo oooooooooooooooo oooooooooooooooo oooooooooooooooo
  ----111111111111 1111112222222222 222222222ooooooo oooooooooooooooo
              <----...
              Most environment doesn't use address space this
              far as the storage usually isn't as huge as 2^52,
              so hammer_extend_layer2_bits() allocating bitmaps
              for this region mostly ends up waste of memory.
              Having an array bitmaps[2^8] prevents this as the
              volume-bits-masked-laye1-index doesn't jump up by
              2^10 when v part gets ++.
sbin/hammer/misc.c