[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/5] block: Tighter assertions on bdrv_aligned_pread
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH 1/5] block: Tighter assertions on bdrv_aligned_preadv() |
Date: |
Fri, 3 Jun 2016 11:03:04 -0600 |
Make sure everything is aligned to the passed-in alignment,
not just sectors. Also makes sure that the computation of
max_nb_sectors later in the function will not divide by
zero, by guaranteeing align is at least a sector.
Signed-off-by: Eric Blake <address@hidden>
---
block/io.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index dff4384..81618b9 100644
--- a/block/io.c
+++ b/block/io.c
@@ -947,8 +947,9 @@ static int coroutine_fn
bdrv_aligned_preadv(BlockDriverState *bs,
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
+ assert(align / BDRV_SECTOR_SIZE);
+ assert((offset & (align - 1)) == 0);
+ assert((bytes & (align - 1)) == 0);
assert(!qiov || bytes == qiov->size);
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
--
2.5.5
- Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, (continued)
- Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, Kevin Wolf, 2016/06/07
- Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, Eric Blake, 2016/06/14
- Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, Kevin Wolf, 2016/06/14
- Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, Eric Blake, 2016/06/14
- Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, Kevin Wolf, 2016/06/14
Re: [Qemu-devel] [PATCH 5/5] block: Move request_alignment into BlockLimit, Kevin Wolf, 2016/06/07
[Qemu-devel] [PATCH 3/5] block: Switch transfer length bounds to byte-based, Eric Blake, 2016/06/03
[Qemu-devel] [PATCH 1/5] block: Tighter assertions on bdrv_aligned_preadv(),
Eric Blake <=
[Qemu-devel] [PATCH 2/5] block: Honor flags during bdrv_aligned_preadv(), Eric Blake, 2016/06/03
[Qemu-devel] [PATCH 6/5] block: Fix harmless off-by-one in bdrv_aligned_preadv(), Eric Blake, 2016/06/03
[Qemu-devel] [PATCH 7/5] block: Refactor zero_beyond_eof hack in bdrv_aligned_preadv(), Eric Blake, 2016/06/03