[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 028/100] mirror: Switch mirror_do_zero_or_discard() t
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 028/100] mirror: Switch mirror_do_zero_or_discard() to byte-based |
Date: |
Fri, 7 Jul 2017 19:07:43 +0200 |
From: Eric Blake <address@hidden>
We are gradually converting to byte-based interfaces, as they are
easier to reason about than sector-based. Convert another internal
function (no semantic change).
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: John Snow <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/mirror.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 10f4e9b..60eefbd 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -305,8 +305,8 @@ static int mirror_do_read(MirrorBlockJob *s, int64_t
sector_num,
}
static void mirror_do_zero_or_discard(MirrorBlockJob *s,
- int64_t sector_num,
- int nb_sectors,
+ int64_t offset,
+ uint64_t bytes,
bool is_discard)
{
MirrorOp *op;
@@ -315,16 +315,16 @@ static void mirror_do_zero_or_discard(MirrorBlockJob *s,
* so the freeing in mirror_iteration_done is nop. */
op = g_new0(MirrorOp, 1);
op->s = s;
- op->offset = sector_num * BDRV_SECTOR_SIZE;
- op->bytes = nb_sectors * BDRV_SECTOR_SIZE;
+ op->offset = offset;
+ op->bytes = bytes;
s->in_flight++;
- s->bytes_in_flight += nb_sectors * BDRV_SECTOR_SIZE;
+ s->bytes_in_flight += bytes;
if (is_discard) {
- blk_aio_pdiscard(s->target, sector_num << BDRV_SECTOR_BITS,
+ blk_aio_pdiscard(s->target, offset,
op->bytes, mirror_write_complete, op);
} else {
- blk_aio_pwrite_zeroes(s->target, sector_num * BDRV_SECTOR_SIZE,
+ blk_aio_pwrite_zeroes(s->target, offset,
op->bytes, s->unmap ? BDRV_REQ_MAY_UNMAP : 0,
mirror_write_complete, op);
}
@@ -453,7 +453,8 @@ static uint64_t coroutine_fn
mirror_iteration(MirrorBlockJob *s)
break;
case MIRROR_METHOD_ZERO:
case MIRROR_METHOD_DISCARD:
- mirror_do_zero_or_discard(s, sector_num, io_sectors,
+ mirror_do_zero_or_discard(s, sector_num * BDRV_SECTOR_SIZE,
+ io_sectors * BDRV_SECTOR_SIZE,
mirror_method == MIRROR_METHOD_DISCARD);
if (write_zeroes_ok) {
io_bytes_acct = 0;
@@ -657,7 +658,8 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)
continue;
}
- mirror_do_zero_or_discard(s, sector_num, nb_sectors, false);
+ mirror_do_zero_or_discard(s, sector_num * BDRV_SECTOR_SIZE,
+ nb_sectors * BDRV_SECTOR_SIZE, false);
sector_num += nb_sectors;
}
--
1.8.3.1
- [Qemu-devel] [PULL 022/100] stream: Switch stream_populate() to byte-based, (continued)
- [Qemu-devel] [PULL 022/100] stream: Switch stream_populate() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 023/100] stream: Drop reached_end for stream_complete(), Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 021/100] trace: Show blockjob actions via bytes, not sectors, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 024/100] stream: Switch stream_run() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 029/100] mirror: Update signature of mirror_clip_sectors(), Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 025/100] commit: Switch commit_populate() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 026/100] commit: Switch commit_run() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 030/100] mirror: Switch mirror_cow_align() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 027/100] mirror: Switch MirrorBlockJob to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 006/100] vvfat: replace tabs by 8 spaces, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 028/100] mirror: Switch mirror_do_zero_or_discard() to byte-based,
Kevin Wolf <=
- [Qemu-devel] [PULL 031/100] mirror: Switch mirror_do_read() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 033/100] block: Drop unused bdrv_round_sectors_to_clusters(), Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 034/100] backup: Switch BackupBlockJob to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 037/100] backup: Switch backup_run() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 032/100] mirror: Switch mirror_iteration() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 035/100] backup: Switch block_backup.h to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 039/100] block: Minimize raw use of bds->total_sectors, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 036/100] backup: Switch backup_do_cow() to byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 040/100] block: Make bdrv_is_allocated_above() byte-based, Kevin Wolf, 2017/07/07
- [Qemu-devel] [PULL 044/100] qcow: require image size to be > 1 for new images, Kevin Wolf, 2017/07/07