mirror of https://github.com/xemu-project/xemu.git
block: Use blk_co_pwritev() in blk_write_zeroes()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5bd5119667
commit
fc1453cdfc
|
@ -744,7 +744,8 @@ static void blk_write_entry(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blk_rw(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
static int blk_rw(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
||||||
int nb_sectors, CoroutineEntry co_entry)
|
int nb_sectors, CoroutineEntry co_entry,
|
||||||
|
BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
AioContext *aio_context;
|
AioContext *aio_context;
|
||||||
QEMUIOVector qiov;
|
QEMUIOVector qiov;
|
||||||
|
@ -766,6 +767,7 @@ static int blk_rw(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
||||||
.blk = blk,
|
.blk = blk,
|
||||||
.offset = sector_num << BDRV_SECTOR_BITS,
|
.offset = sector_num << BDRV_SECTOR_BITS,
|
||||||
.qiov = &qiov,
|
.qiov = &qiov,
|
||||||
|
.flags = flags,
|
||||||
.ret = NOT_DONE,
|
.ret = NOT_DONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -783,7 +785,7 @@ static int blk_rw(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
||||||
int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
||||||
int nb_sectors)
|
int nb_sectors)
|
||||||
{
|
{
|
||||||
return blk_rw(blk, sector_num, buf, nb_sectors, blk_read_entry);
|
return blk_rw(blk, sector_num, buf, nb_sectors, blk_read_entry, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int blk_read_unthrottled(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
int blk_read_unthrottled(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
||||||
|
@ -808,18 +810,15 @@ int blk_read_unthrottled(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
|
||||||
int blk_write(BlockBackend *blk, int64_t sector_num, const uint8_t *buf,
|
int blk_write(BlockBackend *blk, int64_t sector_num, const uint8_t *buf,
|
||||||
int nb_sectors)
|
int nb_sectors)
|
||||||
{
|
{
|
||||||
return blk_rw(blk, sector_num, (uint8_t*) buf, nb_sectors, blk_write_entry);
|
return blk_rw(blk, sector_num, (uint8_t*) buf, nb_sectors,
|
||||||
|
blk_write_entry, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int blk_write_zeroes(BlockBackend *blk, int64_t sector_num,
|
int blk_write_zeroes(BlockBackend *blk, int64_t sector_num,
|
||||||
int nb_sectors, BdrvRequestFlags flags)
|
int nb_sectors, BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
int ret = blk_check_request(blk, sector_num, nb_sectors);
|
return blk_rw(blk, sector_num, NULL, nb_sectors, blk_write_entry,
|
||||||
if (ret < 0) {
|
BDRV_REQ_ZERO_WRITE);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bdrv_write_zeroes(blk_bs(blk), sector_num, nb_sectors, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback_bh(void *opaque)
|
static void error_callback_bh(void *opaque)
|
||||||
|
|
Loading…
Reference in New Issue