From: Qu Wenruo Date: Wed, 23 Oct 2019 13:57:26 +0000 (+0800) Subject: btrfs: volumes: Use more straightforward way to calculate map length X-Git-Tag: microblaze-v5.6-rc1~202^2~25 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=2d974619a77f106f3d1341686dea95c0eaad601f;p=linux-2.6-microblaze.git 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 Reviewed-by: Josef Bacik Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f534a6a5553e..6a0288d17b7d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -5412,7 +5412,7 @@ static int __btrfs_map_block_for_discard(struct btrfs_fs_info *fs_info, } offset = logical - em->start; - length = min_t(u64, em->len - offset, length); + length = min_t(u64, em->start + em->len - logical, length); stripe_len = map->stripe_len; /*