aboutsummaryrefslogtreecommitdiff
path: root/block/vhdx.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-12-18 16:04:25 +0100
committerJeff Cody <jcody@redhat.com>2016-02-29 14:54:31 -0500
commit939901dcd2093a5d6b40420314d1af8b185ec43c (patch)
treede8fc5dce5d4a0b1615bd8972f0758c98127b31f /block/vhdx.c
parentb189346eb1784df95ed6fed610411dbf23d19e1f (diff)
vhdx: DIV_ROUND_UP() in vhdx_calc_bat_entries()
We have DIV_ROUND_UP(), so we can use it to produce more easily readable code. It may be slower than the bit shifting currently performed (because it actually performs a division), but since vhdx_calc_bat_entries() is never used in a hot path, this is completely fine. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-id: 1450451066-13335-2-git-send-email-mreitz@redhat.com Signed-off-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'block/vhdx.c')
-rw-r--r--block/vhdx.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/block/vhdx.c b/block/vhdx.c
index 72042e9082..1e7e03ebed 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -857,14 +857,8 @@ static void vhdx_calc_bat_entries(BDRVVHDXState *s)
{
uint32_t data_blocks_cnt, bitmap_blocks_cnt;
- data_blocks_cnt = s->virtual_disk_size >> s->block_size_bits;
- if (s->virtual_disk_size - (data_blocks_cnt << s->block_size_bits)) {
- data_blocks_cnt++;
- }
- bitmap_blocks_cnt = data_blocks_cnt >> s->chunk_ratio_bits;
- if (data_blocks_cnt - (bitmap_blocks_cnt << s->chunk_ratio_bits)) {
- bitmap_blocks_cnt++;
- }
+ data_blocks_cnt = DIV_ROUND_UP(s->virtual_disk_size, s->block_size);
+ bitmap_blocks_cnt = DIV_ROUND_UP(data_blocks_cnt, s->chunk_ratio);
if (s->parent_entries) {
s->bat_entries = bitmap_blocks_cnt * (s->chunk_ratio + 1);