OSDN Git Service

block/iscsi: fix rounding in iscsi_allocationmap_set
authorPeter Lieven <pl@kamp.de>
Mon, 18 Jul 2016 08:52:19 +0000 (10:52 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 19 Jul 2016 06:34:53 +0000 (08:34 +0200)
commiteb36b953e0ebf4129b188a241fbc367062ac2e06
tree9a01fb374bfcccd725e6478f1000f2ee149d386c
parente5dfc5e8e715c572aea44ac4d96c43941d4741c7
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>
block/iscsi.c