Skip to content

Commit d08c2a2

Browse files
ebblakekevmw
authored andcommittedJun 29, 2018
parallels: Switch to byte-based calls
We are gradually moving away from sector-based interfaces, towards byte-based. Make the change for the last few sector-based calls into the block layer from the parallels driver. Ideally, the parallels driver should switch to doing everything byte-based, but that's a more invasive change that requires a bit more auditing. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 parent c436e3d commit d08c2a2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎block/parallels.c

+10-6
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,15 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
227227
};
228228
qemu_iovec_init_external(&qiov, &iov, 1);
229229

230-
ret = bdrv_co_readv(bs->backing, idx * s->tracks, nb_cow_sectors,
231-
&qiov);
230+
ret = bdrv_co_preadv(bs->backing, idx * s->tracks * BDRV_SECTOR_SIZE,
231+
nb_cow_bytes, &qiov, 0);
232232
if (ret < 0) {
233233
qemu_vfree(iov.iov_base);
234234
return ret;
235235
}
236236

237-
ret = bdrv_co_writev(bs->file, s->data_end, nb_cow_sectors, &qiov);
237+
ret = bdrv_co_pwritev(bs->file, s->data_end * BDRV_SECTOR_SIZE,
238+
nb_cow_bytes, &qiov, 0);
238239
qemu_vfree(iov.iov_base);
239240
if (ret < 0) {
240241
return ret;
@@ -340,7 +341,8 @@ static coroutine_fn int parallels_co_writev(BlockDriverState *bs,
340341
qemu_iovec_reset(&hd_qiov);
341342
qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes);
342343

343-
ret = bdrv_co_writev(bs->file, position, n, &hd_qiov);
344+
ret = bdrv_co_pwritev(bs->file, position * BDRV_SECTOR_SIZE, nbytes,
345+
&hd_qiov, 0);
344346
if (ret < 0) {
345347
break;
346348
}
@@ -379,15 +381,17 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs,
379381

380382
if (position < 0) {
381383
if (bs->backing) {
382-
ret = bdrv_co_readv(bs->backing, sector_num, n, &hd_qiov);
384+
ret = bdrv_co_preadv(bs->backing, sector_num * BDRV_SECTOR_SIZE,
385+
nbytes, &hd_qiov, 0);
383386
if (ret < 0) {
384387
break;
385388
}
386389
} else {
387390
qemu_iovec_memset(&hd_qiov, 0, 0, nbytes);
388391
}
389392
} else {
390-
ret = bdrv_co_readv(bs->file, position, n, &hd_qiov);
393+
ret = bdrv_co_preadv(bs->file, position * BDRV_SECTOR_SIZE, nbytes,
394+
&hd_qiov, 0);
391395
if (ret < 0) {
392396
break;
393397
}

0 commit comments

Comments
 (0)
Please sign in to comment.