• Nikolay Borisov's avatar
    btrfs: Separate space_info create/update · 2be12ef7
    Nikolay Borisov authored
    Currently the struct space_info creation code is intermixed in the
    udpate_space_info function. There are well-defined points at which the
    we actually want to create brand-new space_info structs (e.g. during
    mount of the filesystem as well as sometimes when adding/initialising
    new chunks). In such cases update_space_info is called with 0 as the
    bytes parameter. All of this makes for spaghetti code.
    
    Fix it by factoring out the creation code in a separate
    create_space_info structure. This also allows to simplify the internals.
    Also remove BUG_ON from do_alloc_chunk since the callers handle errors.
    Furthermore it will make the update_space_info function not fail,
    allowing us to remove error handling in callers. This will come in a
    follow up patch.
    Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
    Reviewed-by: default avatarJeff Mahoney <jeffm@suse.com>
    Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    2be12ef7
extent-tree.c 300 KB