• David Sterba's avatar
    btrfs: precalculate checksums per leaf once · fe5ecbe8
    David Sterba authored
    btrfs_csum_bytes_to_leaves shows up in system profiles, which makes it a
    candidate for optimizations. After the 64bit division has been replaced
    by shift, there's still a calculation done each time the function is
    called: checksums per leaf.
    
    As this is a constant value for the entire filesystem lifetime, we
    can calculate it once at mount time and reuse. This also allows to
    reduce the division to 64bit/32bit as we know the constant will always
    fit the 32bit type.
    
    Replace the open-coded rounding up with a macro that internally handles
    the 64bit division and as it's now a short function, make it static
    inline (slight code increase, slight stack usage reduction).
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    fe5ecbe8
ctree.h 122 KB