[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/23] block/iscsi: fix rounding in iscsi_allocationm
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 22/23] block/iscsi: fix rounding in iscsi_allocationmap_set |
Date: |
Mon, 18 Jul 2016 11:27:54 +0200 |
From: Peter Lieven <address@hidden>
when setting clusters as alloacted the boundaries have
to be expanded. As Paolo pointed out the calculation of
the number of clusters is wrong:
Suppose cluster_sectors is 2, sector_num = 1, nb_sectors = 6:
In the "mark allocated" case, you want to set 0..8, i.e.
cluster_num=0, nb_clusters=4.
0--.--2--.--4--.--6--.--8
<--|_________________|--> (<--> = expanded)
Instead you are setting nb_clusters=3, so that 6..8 is not marked.
0--.--2--.--4--.--6--.--8
<--|______________|!!! (! = wrong)
Cc: address@hidden
Reported-by: Paolo Bonzini <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/iscsi.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index cf1e9e7..22330e1 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -432,12 +432,14 @@ static unsigned long *iscsi_allocationmap_init(IscsiLun
*iscsilun)
static void iscsi_allocationmap_set(IscsiLun *iscsilun, int64_t sector_num,
int nb_sectors)
{
+ int64_t cluster_num, nb_clusters;
if (iscsilun->allocationmap == NULL) {
return;
}
- bitmap_set(iscsilun->allocationmap,
- sector_num / iscsilun->cluster_sectors,
- DIV_ROUND_UP(nb_sectors, iscsilun->cluster_sectors));
+ cluster_num = sector_num / iscsilun->cluster_sectors;
+ nb_clusters = DIV_ROUND_UP(sector_num + nb_sectors,
+ iscsilun->cluster_sectors) - cluster_num;
+ bitmap_set(iscsilun->allocationmap, cluster_num, nb_clusters);
}
static void iscsi_allocationmap_clear(IscsiLun *iscsilun, int64_t sector_num,
--
2.7.4
- [Qemu-devel] [PULL 12/23] tcg: Prepare safe access to tb_flushed out of tb_lock, (continued)
- [Qemu-devel] [PULL 12/23] tcg: Prepare safe access to tb_flushed out of tb_lock, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 11/23] tcg: Prepare safe tb_jmp_cache lookup out of tb_lock, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 13/23] target-i386: Remove redundant HF_SOFTMMU_MASK, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 16/23] tcg: set up tb->page_addr before insertion, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 14/23] tcg: Introduce tb_mark_invalid() and tb_is_invalid(), Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 15/23] tcg: Prepare TB invalidation for lockless TB lookup, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 17/23] tcg: cpu-exec: remove tb_lock from the hot-path, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 18/23] tcg: Avoid bouncing tb_lock between tb_gen_code() and tb_add_jump(), Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 20/23] tcg: rename tb_find_physical(), Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 21/23] Move README to markdown, Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 22/23] block/iscsi: fix rounding in iscsi_allocationmap_set,
Paolo Bonzini <=
- [Qemu-devel] [PULL 19/23] tcg: Merge tb_find_slow() and tb_find_fast(), Paolo Bonzini, 2016/07/18
- [Qemu-devel] [PULL 23/23] block/iscsi: allow caching of the allocation map, Paolo Bonzini, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Peter Maydell, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Paolo Bonzini, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Peter Maydell, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Paolo Bonzini, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Peter Maydell, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Paolo Bonzini, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Peter Maydell, 2016/07/18
- Re: [Qemu-devel] [PULL 00/23] TCG and misc patches for 2.7 hard freeze from 2016-07-18, Paolo Bonzini, 2016/07/18