sbin/hammer: Add __blockmap_xlate_to_zone2() to refactor get_buffer()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 13 Dec 2016 17:52:57 +0000 (02:52 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 14 Dec 2016 16:51:21 +0000 (01:51 +0900)
commit6acc1a36afff48ecfa1b8bbb5f57036541cc044b
tree5e5c88be2a2351e133acf898459c4149b6693755
parenta8abc07e106c931dcb1f2a1ef09ce80b6843107d
sbin/hammer: Add __blockmap_xlate_to_zone2() to refactor get_buffer()

No functional difference, but this should make more sense than
how it was implemented before. The only thing this part really
does is convert zone offset to zone-2.

If error is set by blockmap_lookup(), there's nothing it can do
to recover, but get_buffer() mustn't call exit(1) here. A command
like hammer recover (which could possibly pass invalid offsets)
expects get_buffer() to return NULL for invalid offsets.

The reason for not calling blockmap_lookup() via get_buffer()
when zone_offset is in zone-2 is because zone_offset could be
0 when newfs_hammer calls get_buffer_data() on bootstrap when
layer1/2 entries aren't even created. It's ok to directly call
it with zone-2 offset like hammer show and blockmap do.

  format_freemap()
    -> get_buffer_data()
      -> get_buffer()
        -> blockmap_lookup()
          -> get_buffer_data(0)
            -> get_buffer(0)
              -> blockmap_lookup(0) /* XXX */
sbin/hammer/ondisk.c