• Nikolay Borisov's avatar
    btrfs: simplify checks when adding excluded ranges · 96f9b0f2
    Nikolay Borisov authored
    Adresses held in 'logical' array are always guaranteed to fall within
    the boundaries of the block group. That is, 'start' can never be
    smaller than cache->start. This invariant follows from the way the
    address are calculated in btrfs_rmap_block:
    
        stripe_nr = physical - map->stripes[i].physical;
        stripe_nr = div64_u64(stripe_nr, map->stripe_len);
        bytenr = chunk_start + stripe_nr * io_stripe_size;
    
    I.e it's always some IO stripe within the given chunk.
    
    Exploit this invariant to simplify the body of the loop by removing the
    unnecessary 'if' since its 'else' part is the one always executed.
    Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    96f9b0f2
block-group.c 97.1 KB