• Qu Wenruo's avatar
    btrfs: Refactor check_leaf function for later expansion · c3267bba
    Qu Wenruo authored
    Current check_leaf() function does a good job checking key order and
    item offset/size.
    
    However it only checks from slot 0 to the last but one slot, this is
    good but makes later expansion hard.
    
    So this refactoring iterates from slot 0 to the last slot.
    For key comparison, it uses a key with all 0 as initial key, so all
    valid keys should be larger than that.
    
    And for item size/offset checks, it compares current item end with
    previous item offset.
    For slot 0, use leaf end as a special case.
    
    This makes later item/key offset checks and item size checks easier to
    be implemented.
    
    Also, makes check_leaf() to return -EUCLEAN other than -EIO to indicate
    error.
    Signed-off-by: default avatarQu Wenruo <quwenruo.btrfs@gmx.com>
    Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    c3267bba
disk-io.c 125 KB