git: sbin/hammer: Add __blockmap_xlate_to_zone2() to refactor get_buffer()

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Wed Dec 14 09:37:53 PST 2016


commit 6acc1a36afff48ecfa1b8bbb5f57036541cc044b
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Wed Dec 14 02:52:57 2016 +0900

    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 */

Summary of changes:
 sbin/hammer/ondisk.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/6acc1a36afff48ecfa1b8bbb5f57036541cc044b


-- 
DragonFly BSD source repository


More information about the Commits mailing list