[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <b15e98a7c6129f8b5f0a7748061e93865bb944e1.1599750901.git.anand.jain@oracle.com>
Date: Thu, 8 Oct 2020 18:59:51 +0800
From: Anand Jain <anand.jain@...cle.com>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: wqu@...e.com, fdmanana@...e.com, dsterba@...e.com,
linux-btrfs@...r.kernel.org
Subject: [PATCH stable-5.4 3/6] btrfs: volumes: Use more straightforward way to calculate map length
From: Qu Wenruo <wqu@...e.com>
commit 2d974619a77f106f3d1341686dea95c0eaad601f upstream.
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@...e.de>
Reviewed-by: Josef Bacik <josef@...icpanda.com>
Signed-off-by: Qu Wenruo <wqu@...e.com>
Reviewed-by: David Sterba <dsterba@...e.com>
Signed-off-by: David Sterba <dsterba@...e.com>
Signed-off-by: Anand Jain <anand.jain@...cle.com>
---
fs/btrfs/volumes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 196ddbcd2936..1dba45d43485 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5712,7 +5712,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;
/*
--
2.25.1
Powered by blists - more mailing lists