raw-posix: Convert to bdrv_co_pwrite_zeroes()
Another step on our continuing quest to switch to byte-based interfaces. Signed-off-by: Eric Blake <eblake@redhat.com> [ kwolf: Fixed up trace_paio_submit_co() call for qiov == NULL ] Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
49a2e48348
commit
2ffa76c2bf
@ -1252,8 +1252,8 @@ static int aio_worker(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int paio_submit_co(BlockDriverState *bs, int fd,
|
static int paio_submit_co(BlockDriverState *bs, int fd,
|
||||||
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
|
int64_t offset, QEMUIOVector *qiov,
|
||||||
int type)
|
int count, int type)
|
||||||
{
|
{
|
||||||
RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
|
RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
|
||||||
ThreadPool *pool;
|
ThreadPool *pool;
|
||||||
@ -1262,16 +1262,16 @@ static int paio_submit_co(BlockDriverState *bs, int fd,
|
|||||||
acb->aio_type = type;
|
acb->aio_type = type;
|
||||||
acb->aio_fildes = fd;
|
acb->aio_fildes = fd;
|
||||||
|
|
||||||
acb->aio_nbytes = nb_sectors * BDRV_SECTOR_SIZE;
|
acb->aio_nbytes = count;
|
||||||
acb->aio_offset = sector_num * BDRV_SECTOR_SIZE;
|
acb->aio_offset = offset;
|
||||||
|
|
||||||
if (qiov) {
|
if (qiov) {
|
||||||
acb->aio_iov = qiov->iov;
|
acb->aio_iov = qiov->iov;
|
||||||
acb->aio_niov = qiov->niov;
|
acb->aio_niov = qiov->niov;
|
||||||
assert(qiov->size == acb->aio_nbytes);
|
assert(qiov->size == count);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_paio_submit_co(sector_num, nb_sectors, type);
|
trace_paio_submit_co(offset, count, type);
|
||||||
pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
|
pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
|
||||||
return thread_pool_submit_co(pool, aio_worker, acb);
|
return thread_pool_submit_co(pool, aio_worker, acb);
|
||||||
}
|
}
|
||||||
@ -1868,17 +1868,17 @@ static coroutine_fn BlockAIOCB *raw_aio_discard(BlockDriverState *bs,
|
|||||||
cb, opaque, QEMU_AIO_DISCARD);
|
cb, opaque, QEMU_AIO_DISCARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn raw_co_write_zeroes(
|
static int coroutine_fn raw_co_pwrite_zeroes(
|
||||||
BlockDriverState *bs, int64_t sector_num,
|
BlockDriverState *bs, int64_t offset,
|
||||||
int nb_sectors, BdrvRequestFlags flags)
|
int count, BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
BDRVRawState *s = bs->opaque;
|
BDRVRawState *s = bs->opaque;
|
||||||
|
|
||||||
if (!(flags & BDRV_REQ_MAY_UNMAP)) {
|
if (!(flags & BDRV_REQ_MAY_UNMAP)) {
|
||||||
return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
|
return paio_submit_co(bs, s->fd, offset, NULL, count,
|
||||||
QEMU_AIO_WRITE_ZEROES);
|
QEMU_AIO_WRITE_ZEROES);
|
||||||
} else if (s->discard_zeroes) {
|
} else if (s->discard_zeroes) {
|
||||||
return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
|
return paio_submit_co(bs, s->fd, offset, NULL, count,
|
||||||
QEMU_AIO_DISCARD);
|
QEMU_AIO_DISCARD);
|
||||||
}
|
}
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
@ -1931,7 +1931,7 @@ BlockDriver bdrv_file = {
|
|||||||
.bdrv_create = raw_create,
|
.bdrv_create = raw_create,
|
||||||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||||
.bdrv_co_get_block_status = raw_co_get_block_status,
|
.bdrv_co_get_block_status = raw_co_get_block_status,
|
||||||
.bdrv_co_write_zeroes = raw_co_write_zeroes,
|
.bdrv_co_pwrite_zeroes = raw_co_pwrite_zeroes,
|
||||||
|
|
||||||
.bdrv_aio_readv = raw_aio_readv,
|
.bdrv_aio_readv = raw_aio_readv,
|
||||||
.bdrv_aio_writev = raw_aio_writev,
|
.bdrv_aio_writev = raw_aio_writev,
|
||||||
@ -2293,8 +2293,8 @@ static coroutine_fn BlockAIOCB *hdev_aio_discard(BlockDriverState *bs,
|
|||||||
cb, opaque, QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
|
cb, opaque, QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
static coroutine_fn int hdev_co_write_zeroes(BlockDriverState *bs,
|
static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs,
|
||||||
int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
|
int64_t offset, int count, BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
BDRVRawState *s = bs->opaque;
|
BDRVRawState *s = bs->opaque;
|
||||||
int rc;
|
int rc;
|
||||||
@ -2304,10 +2304,10 @@ static coroutine_fn int hdev_co_write_zeroes(BlockDriverState *bs,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
if (!(flags & BDRV_REQ_MAY_UNMAP)) {
|
if (!(flags & BDRV_REQ_MAY_UNMAP)) {
|
||||||
return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
|
return paio_submit_co(bs, s->fd, offset, NULL, count,
|
||||||
QEMU_AIO_WRITE_ZEROES|QEMU_AIO_BLKDEV);
|
QEMU_AIO_WRITE_ZEROES|QEMU_AIO_BLKDEV);
|
||||||
} else if (s->discard_zeroes) {
|
} else if (s->discard_zeroes) {
|
||||||
return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
|
return paio_submit_co(bs, s->fd, offset, NULL, count,
|
||||||
QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
|
QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
|
||||||
}
|
}
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
@ -2379,7 +2379,7 @@ static BlockDriver bdrv_host_device = {
|
|||||||
.bdrv_reopen_abort = raw_reopen_abort,
|
.bdrv_reopen_abort = raw_reopen_abort,
|
||||||
.bdrv_create = hdev_create,
|
.bdrv_create = hdev_create,
|
||||||
.create_opts = &raw_create_opts,
|
.create_opts = &raw_create_opts,
|
||||||
.bdrv_co_write_zeroes = hdev_co_write_zeroes,
|
.bdrv_co_pwrite_zeroes = hdev_co_pwrite_zeroes,
|
||||||
|
|
||||||
.bdrv_aio_readv = raw_aio_readv,
|
.bdrv_aio_readv = raw_aio_readv,
|
||||||
.bdrv_aio_writev = raw_aio_writev,
|
.bdrv_aio_writev = raw_aio_writev,
|
||||||
|
@ -131,7 +131,7 @@ thread_pool_cancel(void *req, void *opaque) "req %p opaque %p"
|
|||||||
|
|
||||||
# block/raw-win32.c
|
# block/raw-win32.c
|
||||||
# block/raw-posix.c
|
# block/raw-posix.c
|
||||||
paio_submit_co(int64_t sector_num, int nb_sectors, int type) "sector_num %"PRId64" nb_sectors %d type %d"
|
paio_submit_co(int64_t offset, int count, int type) "offset %"PRId64" count %d type %d"
|
||||||
paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int type) "acb %p opaque %p sector_num %"PRId64" nb_sectors %d type %d"
|
paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int type) "acb %p opaque %p sector_num %"PRId64" nb_sectors %d type %d"
|
||||||
|
|
||||||
# ioport.c
|
# ioport.c
|
||||||
|
Loading…
Reference in New Issue
Block a user