]> git.hungrycats.org Git - linux/commit
btrfs: volumes: Use more straightforward way to calculate map length
authorQu Wenruo <wqu@suse.com>
Wed, 23 Oct 2019 13:57:26 +0000 (21:57 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 11:47:07 +0000 (12:47 +0100)
commit54addfb13fd2c0d1432b5d15fede9514a2fb81ef
tree595ab89f587002600b0fc87cfe1bdf6222197b1a
parentc6284083756a84be3e521b2fa87d07e8444a2274
btrfs: volumes: Use more straightforward way to calculate map length

The old code goes:

  offset = logical - em->start;
length = min_t(u64, em->len - offset, length);

Where @length calculation is dependent on offset, it can take reader
several more seconds to find it's just the same code as:

  offset = logical - em->start;
length = min_t(u64, em->start + em->len - logical, length);

Use above code to make the length calculate independent from other
variable, thus slightly increase the readability.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c