Commit d004bd52 authored by Eric Blake's avatar Eric Blake Committed by Kevin Wolf
Browse files

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: default avatarKevin Wolf <kwolf@redhat.com>
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
parent 8a8e63eb
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -855,7 +855,7 @@ int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf,
    return ret;
}

int blk_write_zeroes(BlockBackend *blk, int64_t offset,
int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
                      int count, BdrvRequestFlags flags)
{
    return blk_prw(blk, offset, NULL, count, blk_write_entry,
@@ -971,7 +971,7 @@ static void blk_aio_write_entry(void *opaque)
    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,
                                  BlockCompletionFunc *cb, void *opaque)
{
@@ -1462,7 +1462,7 @@ void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
    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)
{
    return blk_co_pwritev(blk, offset, count, NULL,
+2 −2
Original line number Diff line number Diff line
@@ -517,7 +517,7 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp)
    if (ret < 0) {
        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);
    if (ret < 0) {
        goto exit;
+1 −1
Original line number Diff line number Diff line
@@ -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,
                         nb_sectors * s->qdev.blocksize,
                        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,
                                nb_sectors * s->qdev.blocksize,
                                flags, scsi_aio_complete, r);
+7 −7
Original line number Diff line number Diff line
@@ -113,9 +113,9 @@ void *blk_get_attached_dev(BlockBackend *blk);
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 count);
int blk_write_zeroes(BlockBackend *blk, int64_t offset,
int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
                      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,
                                  BlockCompletionFunc *cb, void *opaque);
int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count);
@@ -195,7 +195,7 @@ int blk_get_open_flags_from_root_state(BlockBackend *blk);

void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
                  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 blk_write_compressed(BlockBackend *blk, int64_t sector_num,
                         const uint8_t *buf, int nb_sectors);
+2 −2
Original line number Diff line number Diff line
@@ -1606,7 +1606,7 @@ static int convert_write(ImgConvertState *s, int64_t sector_num, int nb_sectors,
            if (s->has_zero_init) {
                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);
            if (ret < 0) {
                return ret;
Loading