block/iscsi: fix rounding in iscsi_allocationmap_set
commit5634eb8ffb935045a6dd7e517eec5b838b6bc3e6
authorPeter Lieven <pl@kamp.de>
Mon, 18 Jul 2016 08:52:19 +0000 (18 10:52 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Fri, 5 Aug 2016 21:03:41 +0000 (5 16:03 -0500)
tree9c6401e41a147db4f54fe2c10f15581d3804a240
parentb6ece2c6f37926a994bc564a9e55ef3be6016d8f
block/iscsi: fix rounding in iscsi_allocationmap_set

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: qemu-stable@nongnu.org
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
Message-Id: <1468831940-15556-2-git-send-email-pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit eb36b953e0ebf4129b188a241fbc367062ac2e06)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/iscsi.c