On 11/30/2017 05:26 AM, Vladimir Sementsov-Ogievskiy wrote:
12.10.2017 21:59, Eric Blake wrote:
We are gradually moving away from sector-based interfaces, towards
byte-based.  Update the vdi driver accordingly.  Note that the
TODO is already covered (the block layer guarantees bounds of its
requests), and that we can remove the now-unused s->block_sectors.

Signed-off-by: Eric Blake <ebl...@redhat.com>


      BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
-    size_t bmap_index = sector_num / s->block_sectors;
-    size_t sector_in_block = sector_num % s->block_sectors;
-    int n_sectors = s->block_sectors - sector_in_block;
+    size_t bmap_index = offset / s->block_size;
+    size_t index_in_block = offset % s->block_size;
      uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]);
-    uint64_t offset;
      int result;

-    logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum);
-    if (n_sectors > nb_sectors) {
-        n_sectors = nb_sectors;
-    }
-    *pnum = n_sectors;
+    logout("%p, %" PRId64 ", %" PRId64 ", %p\n", bs, offset, bytes, pnum);

may be not bad to update message, as you changed numbers, like

logout("%p, offset %" PRId64 ", bytes %" PRId64 ", %p\n", bs, offset, bytes, pnum);

but for me it is ok as is too.

Debugging messages can be looked up in context when you enable debugging. I'm not bothering to change that.


+    *pnum = MIN(s->block_size, bytes);

looks like it should be MIN(s->block_size - index_in_block, bytes);

Oh, good catch. You are right.


with that:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>

Thanks again for a careful review throughout this series.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to