]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: simplify checks when adding excluded ranges
authorNikolay Borisov <nborisov@suse.com>
Fri, 3 Apr 2020 13:40:35 +0000 (16:40 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 27 Jul 2020 10:55:20 +0000 (12:55 +0200)
commit44e63727adc3ba1d911da068e9722b173ee522b4
tree44dba05f021d54fbd265c61611e801ecc81f3b80
parent0d76e982022601fb8c701ae55176e6335ea7fd45
btrfs: simplify checks when adding excluded ranges

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: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c