[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/39] block: Prepare bdrv_aligned_pwritev() for byte
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 15/39] block: Prepare bdrv_aligned_pwritev() for byte-aligned requests |
Date: |
Thu, 16 Jun 2016 16:08:04 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/io.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/block/io.c b/block/io.c
index e75bce2..b261cc6 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1249,11 +1249,9 @@ static int coroutine_fn
bdrv_aligned_pwritev(BlockDriverState *bs,
bool waited;
int ret;
- int64_t sector_num = offset >> BDRV_SECTOR_BITS;
- unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
+ int64_t start_sector = offset >> BDRV_SECTOR_BITS;
+ int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert(!qiov || bytes == qiov->size);
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
assert(!(flags & ~BDRV_REQ_MASK));
@@ -1278,22 +1276,21 @@ static int coroutine_fn
bdrv_aligned_pwritev(BlockDriverState *bs,
/* Do nothing, write notifier decided to fail this request */
} else if (flags & BDRV_REQ_ZERO_WRITE) {
bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO);
- ret = bdrv_co_do_pwrite_zeroes(bs, sector_num << BDRV_SECTOR_BITS,
- nb_sectors << BDRV_SECTOR_BITS, flags);
+ ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags);
} else {
bdrv_debug_event(bs, BLKDBG_PWRITEV);
ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, flags);
}
bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE);
- bdrv_set_dirty(bs, sector_num, nb_sectors);
+ bdrv_set_dirty(bs, start_sector, end_sector - start_sector);
if (bs->wr_highest_offset < offset + bytes) {
bs->wr_highest_offset = offset + bytes;
}
if (ret >= 0) {
- bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
+ bs->total_sectors = MAX(bs->total_sectors, end_sector);
}
return ret;
--
1.8.3.1
- [Qemu-devel] [PULL 00/39] Block layer patches, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 04/39] qcow2: Use bytes instead of sectors for QCowL2Meta, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 01/39] qcow2: Work with bytes in qcow2_get_cluster_offset(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 02/39] qcow2: Implement .bdrv_co_preadv(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 06/39] blockdev: clarify error on attempt to open locked tray, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 05/39] qcow2: Implement .bdrv_co_pwritev(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 07/39] hmp: acquire aio_context in hmp_qemu_io, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 14/39] block: Prepare bdrv_aligned_preadv() for byte-aligned requests, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 03/39] qcow2: Make copy_sectors() byte based, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 11/39] block: Assert that flags are in range, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 15/39] block: Prepare bdrv_aligned_pwritev() for byte-aligned requests,
Kevin Wolf <=
- [Qemu-devel] [PULL 12/39] block: drop support for using qcow[2] encryption with system emulators, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 08/39] m25p80: fix test on blk_pread() return value, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 09/39] qemu-img bench: Fix uninitialised writethrough mode, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 10/39] block: Avoid bogus flags during mirroring, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 13/39] block: Byte-based bdrv_co_do_copy_on_readv(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 19/39] linux-aio: Cancel BH if not needed, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 20/39] doc: Fix mailing list address in tests/qemu-iotests/README, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 16/39] raw-posix: Switch to bdrv_co_* interfaces, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 18/39] block: Don't enforce 512 byte minimum alignment, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 21/39] block: Introduce bdrv_preadv(), Kevin Wolf, 2016/06/16