block: Rename blk_write_zeroes()

Commit 983a1600 changed the semantics of blk_write_zeroes() to
be byte-based rather than sector-based, but did not change the
name, which is an open invitation for other code to misuse the
function.  Renaming to pwrite_zeroes() makes it more in line
with other byte-based interfaces, and will help make it easier
to track which remaining write_zeroes interfaces still need
conversion.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Eric Blake 2016-05-24 16:25:20 -06:00 committed by Kevin Wolf
parent 8a8e63ebdd
commit d004bd52aa
6 changed files with 30 additions and 30 deletions

View File

@ -855,8 +855,8 @@ int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf,
return ret; return ret;
} }
int blk_write_zeroes(BlockBackend *blk, int64_t offset, int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int count, BdrvRequestFlags flags) int count, BdrvRequestFlags flags)
{ {
return blk_prw(blk, offset, NULL, count, blk_write_entry, return blk_prw(blk, offset, NULL, count, blk_write_entry,
flags | BDRV_REQ_ZERO_WRITE); flags | BDRV_REQ_ZERO_WRITE);
@ -971,9 +971,9 @@ static void blk_aio_write_entry(void *opaque)
blk_aio_complete(acb); blk_aio_complete(acb);
} }
BlockAIOCB *blk_aio_write_zeroes(BlockBackend *blk, int64_t offset, BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int count, BdrvRequestFlags flags, int count, BdrvRequestFlags flags,
BlockCompletionFunc *cb, void *opaque) BlockCompletionFunc *cb, void *opaque)
{ {
return blk_aio_prwv(blk, offset, count, NULL, blk_aio_write_entry, return blk_aio_prwv(blk, offset, count, NULL, blk_aio_write_entry,
flags | BDRV_REQ_ZERO_WRITE, cb, opaque); flags | BDRV_REQ_ZERO_WRITE, cb, opaque);
@ -1462,8 +1462,8 @@ void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
return qemu_aio_get(aiocb_info, blk_bs(blk), cb, opaque); return qemu_aio_get(aiocb_info, blk_bs(blk), cb, opaque);
} }
int coroutine_fn blk_co_write_zeroes(BlockBackend *blk, int64_t offset, int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int count, BdrvRequestFlags flags) int count, BdrvRequestFlags flags)
{ {
return blk_co_pwritev(blk, offset, count, NULL, return blk_co_pwritev(blk, offset, count, NULL,
flags | BDRV_REQ_ZERO_WRITE); flags | BDRV_REQ_ZERO_WRITE);

View File

@ -517,8 +517,8 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp)
if (ret < 0) { if (ret < 0) {
goto exit; goto exit;
} }
ret = blk_write_zeroes(file, BDRV_SECTOR_SIZE, ret = blk_pwrite_zeroes(file, BDRV_SECTOR_SIZE,
(bat_sectors - 1) << BDRV_SECTOR_BITS, 0); (bat_sectors - 1) << BDRV_SECTOR_BITS, 0);
if (ret < 0) { if (ret < 0) {
goto exit; goto exit;
} }

View File

@ -1780,7 +1780,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
nb_sectors * s->qdev.blocksize, nb_sectors * s->qdev.blocksize,
BLOCK_ACCT_WRITE); BLOCK_ACCT_WRITE);
r->req.aiocb = blk_aio_write_zeroes(s->qdev.conf.blk, r->req.aiocb = blk_aio_pwrite_zeroes(s->qdev.conf.blk,
r->req.cmd.lba * s->qdev.blocksize, r->req.cmd.lba * s->qdev.blocksize,
nb_sectors * s->qdev.blocksize, nb_sectors * s->qdev.blocksize,
flags, scsi_aio_complete, r); flags, scsi_aio_complete, r);

View File

@ -113,11 +113,11 @@ void *blk_get_attached_dev(BlockBackend *blk);
void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque);
int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf, int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf,
int count); int count);
int blk_write_zeroes(BlockBackend *blk, int64_t offset, int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int count, BdrvRequestFlags flags); int count, BdrvRequestFlags flags);
BlockAIOCB *blk_aio_write_zeroes(BlockBackend *blk, int64_t offset, BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int count, BdrvRequestFlags flags, int count, BdrvRequestFlags flags,
BlockCompletionFunc *cb, void *opaque); BlockCompletionFunc *cb, void *opaque);
int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count); int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count);
int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count, int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count,
BdrvRequestFlags flags); BdrvRequestFlags flags);
@ -195,8 +195,8 @@ int blk_get_open_flags_from_root_state(BlockBackend *blk);
void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
BlockCompletionFunc *cb, void *opaque); BlockCompletionFunc *cb, void *opaque);
int coroutine_fn blk_co_write_zeroes(BlockBackend *blk, int64_t offset, int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int count, BdrvRequestFlags flags); int count, BdrvRequestFlags flags);
int blk_write_compressed(BlockBackend *blk, int64_t sector_num, int blk_write_compressed(BlockBackend *blk, int64_t sector_num,
const uint8_t *buf, int nb_sectors); const uint8_t *buf, int nb_sectors);
int blk_truncate(BlockBackend *blk, int64_t offset); int blk_truncate(BlockBackend *blk, int64_t offset);

View File

@ -1606,8 +1606,8 @@ static int convert_write(ImgConvertState *s, int64_t sector_num, int nb_sectors,
if (s->has_zero_init) { if (s->has_zero_init) {
break; break;
} }
ret = blk_write_zeroes(s->target, sector_num << BDRV_SECTOR_BITS, ret = blk_pwrite_zeroes(s->target, sector_num << BDRV_SECTOR_BITS,
n << BDRV_SECTOR_BITS, 0); n << BDRV_SECTOR_BITS, 0);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }

View File

@ -451,12 +451,12 @@ typedef struct {
bool done; bool done;
} CoWriteZeroes; } CoWriteZeroes;
static void coroutine_fn co_write_zeroes_entry(void *opaque) static void coroutine_fn co_pwrite_zeroes_entry(void *opaque)
{ {
CoWriteZeroes *data = opaque; CoWriteZeroes *data = opaque;
data->ret = blk_co_write_zeroes(data->blk, data->offset, data->count, data->ret = blk_co_pwrite_zeroes(data->blk, data->offset, data->count,
data->flags); data->flags);
data->done = true; data->done = true;
if (data->ret < 0) { if (data->ret < 0) {
*data->total = data->ret; *data->total = data->ret;
@ -466,8 +466,8 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque)
*data->total = data->count; *data->total = data->count;
} }
static int do_co_write_zeroes(BlockBackend *blk, int64_t offset, int64_t count, static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int flags, int64_t *total) int64_t count, int flags, int64_t *total)
{ {
Coroutine *co; Coroutine *co;
CoWriteZeroes data = { CoWriteZeroes data = {
@ -483,7 +483,7 @@ static int do_co_write_zeroes(BlockBackend *blk, int64_t offset, int64_t count,
return -ERANGE; return -ERANGE;
} }
co = qemu_coroutine_create(co_write_zeroes_entry); co = qemu_coroutine_create(co_pwrite_zeroes_entry);
qemu_coroutine_enter(co, &data); qemu_coroutine_enter(co, &data);
while (!data.done) { while (!data.done) {
aio_poll(blk_get_aio_context(blk), true); aio_poll(blk_get_aio_context(blk), true);
@ -901,7 +901,7 @@ static void write_help(void)
" -C, -- report statistics in a machine parsable format\n" " -C, -- report statistics in a machine parsable format\n"
" -q, -- quiet mode, do not show I/O statistics\n" " -q, -- quiet mode, do not show I/O statistics\n"
" -u, -- with -z, allow unmapping\n" " -u, -- with -z, allow unmapping\n"
" -z, -- write zeroes using blk_co_write_zeroes\n" " -z, -- write zeroes using blk_co_pwrite_zeroes\n"
"\n"); "\n");
} }
@ -1033,7 +1033,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
if (bflag) { if (bflag) {
cnt = do_save_vmstate(blk, buf, offset, count, &total); cnt = do_save_vmstate(blk, buf, offset, count, &total);
} else if (zflag) { } else if (zflag) {
cnt = do_co_write_zeroes(blk, offset, count, flags, &total); cnt = do_co_pwrite_zeroes(blk, offset, count, flags, &total);
} else if (cflag) { } else if (cflag) {
cnt = do_write_compressed(blk, buf, offset, count, &total); cnt = do_write_compressed(blk, buf, offset, count, &total);
} else { } else {
@ -1376,7 +1376,7 @@ static void aio_write_help(void)
" -i, -- treat request as invalid, for exercising stats\n" " -i, -- treat request as invalid, for exercising stats\n"
" -q, -- quiet mode, do not show I/O statistics\n" " -q, -- quiet mode, do not show I/O statistics\n"
" -u, -- with -z, allow unmapping\n" " -u, -- with -z, allow unmapping\n"
" -z, -- write zeroes using blk_aio_write_zeroes\n" " -z, -- write zeroes using blk_aio_pwrite_zeroes\n"
"\n"); "\n");
} }
@ -1475,8 +1475,8 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
} }
ctx->qiov.size = count; ctx->qiov.size = count;
blk_aio_write_zeroes(blk, ctx->offset, count, flags, aio_write_done, blk_aio_pwrite_zeroes(blk, ctx->offset, count, flags, aio_write_done,
ctx); ctx);
} else { } else {
nr_iov = argc - optind; nr_iov = argc - optind;
ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov,