mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
block: Fix blk_aio_write_zeroes()
Commit 57d6a428
broke blk_aio_write_zeroes() because in some write
functions in the call path don't have an explicit length argument but
reuse qiov->size instead. Which is great, except that write_zeroes
doesn't have a qiov, which this commit interprets as 0 bytes.
Consequently, blk_aio_write_zeroes() didn't effectively do anything.
This patch introduces an explicit acb->bytes in BlkAioEmAIOCB and uses
that instead of acb->rwco.size.
The synchronous version of the function is okay because it does pass a
qiov (with the right size and a NULL pointer as its base).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
5ceb77652e
commit
7fa84cd8d4
3 changed files with 100 additions and 10 deletions
|
@ -852,6 +852,7 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,
|
|||
typedef struct BlkAioEmAIOCB {
|
||||
BlockAIOCB common;
|
||||
BlkRwCo rwco;
|
||||
int bytes;
|
||||
bool has_returned;
|
||||
QEMUBH* bh;
|
||||
} BlkAioEmAIOCB;
|
||||
|
@ -877,7 +878,7 @@ static void blk_aio_complete_bh(void *opaque)
|
|||
blk_aio_complete(opaque);
|
||||
}
|
||||
|
||||
static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset,
|
||||
static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
|
||||
QEMUIOVector *qiov, CoroutineEntry co_entry,
|
||||
BdrvRequestFlags flags,
|
||||
BlockCompletionFunc *cb, void *opaque)
|
||||
|
@ -893,6 +894,7 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset,
|
|||
.flags = flags,
|
||||
.ret = NOT_DONE,
|
||||
};
|
||||
acb->bytes = bytes;
|
||||
acb->bh = NULL;
|
||||
acb->has_returned = false;
|
||||
|
||||
|
@ -913,7 +915,8 @@ static void blk_aio_read_entry(void *opaque)
|
|||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
|
||||
rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, rwco->qiov->size,
|
||||
assert(rwco->qiov->size == acb->bytes);
|
||||
rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, acb->bytes,
|
||||
rwco->qiov, rwco->flags);
|
||||
blk_aio_complete(acb);
|
||||
}
|
||||
|
@ -923,8 +926,8 @@ static void blk_aio_write_entry(void *opaque)
|
|||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
|
||||
rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset,
|
||||
rwco->qiov ? rwco->qiov->size : 0,
|
||||
assert(!rwco->qiov || rwco->qiov->size == acb->bytes);
|
||||
rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, acb->bytes,
|
||||
rwco->qiov, rwco->flags);
|
||||
blk_aio_complete(acb);
|
||||
}
|
||||
|
@ -937,7 +940,8 @@ BlockAIOCB *blk_aio_write_zeroes(BlockBackend *blk, int64_t sector_num,
|
|||
return blk_abort_aio_request(blk, cb, opaque, -EINVAL);
|
||||
}
|
||||
|
||||
return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, NULL,
|
||||
return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS,
|
||||
nb_sectors << BDRV_SECTOR_BITS, NULL,
|
||||
blk_aio_write_entry, BDRV_REQ_ZERO_WRITE, cb, opaque);
|
||||
}
|
||||
|
||||
|
@ -994,7 +998,8 @@ BlockAIOCB *blk_aio_readv(BlockBackend *blk, int64_t sector_num,
|
|||
return blk_abort_aio_request(blk, cb, opaque, -EINVAL);
|
||||
}
|
||||
|
||||
return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov,
|
||||
assert(nb_sectors << BDRV_SECTOR_BITS == iov->size);
|
||||
return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov->size, iov,
|
||||
blk_aio_read_entry, 0, cb, opaque);
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1011,8 @@ BlockAIOCB *blk_aio_writev(BlockBackend *blk, int64_t sector_num,
|
|||
return blk_abort_aio_request(blk, cb, opaque, -EINVAL);
|
||||
}
|
||||
|
||||
return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov,
|
||||
assert(nb_sectors << BDRV_SECTOR_BITS == iov->size);
|
||||
return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov->size, iov,
|
||||
blk_aio_write_entry, 0, cb, opaque);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue