]> git.proxmox.com Git - mirror_qemu.git/commit - block/vdi.c
block: use int64_t instead of uint64_t in driver read handlers
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 3 Sep 2021 10:27:59 +0000 (13:27 +0300)
committerEric Blake <eblake@redhat.com>
Wed, 29 Sep 2021 18:46:31 +0000 (13:46 -0500)
commitf7ef38dd1310d7d9db76d0aa16899cbc5744f36d
treedf57567b3a0b38e6a81181ebfdbc3bc82fe0e5ff
parent558902cc3dc61231930001b82dcd95d20d58b417
block: use int64_t instead of uint64_t in driver read handlers

We are generally moving to int64_t for both offset and bytes parameters
on all io paths.

Main motivation is realization of 64-bit write_zeroes operation for
fast zeroing large disk chunks, up to the whole disk.

We chose signed type, to be consistent with off_t (which is signed) and
with possibility for signed return type (where negative value means
error).

So, convert driver read handlers parameters which are already 64bit to
signed type.

While being here, convert also flags parameter to be BdrvRequestFlags.

Now let's consider all callers. Simple

  git grep '\->bdrv_\(aio\|co\)_preadv\(_part\)\?'

shows that's there three callers of driver function:

 bdrv_driver_preadv() in block/io.c, passes int64_t, checked by
   bdrv_check_qiov_request() to be non-negative.

 qcow2_load_vmstate() does bdrv_check_qiov_request().

 do_perform_cow_read() has uint64_t argument. And a lot of things in
 qcow2 driver are uint64_t, so converting it is big job. But we must
 not work with requests that don't satisfy bdrv_check_qiov_request(),
 so let's just assert it here.

Still, the functions may be called directly, not only by drv->...
Let's check:

git grep '\.bdrv_\(aio\|co\)_preadv\(_part\)\?\s*=' | \
awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \
while read func; do git grep "$func(" | \
grep -v "$func(BlockDriverState"; done

The only one such caller:

    QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, &data, 1);
    ...
    ret = bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0);

in tests/unit/test-bdrv-drain.c, and it's OK obviously.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210903102807.27127-4-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: fix typos]
Signed-off-by: Eric Blake <eblake@redhat.com>
35 files changed:
block/blkdebug.c
block/blklogwrites.c
block/blkreplay.c
block/blkverify.c
block/bochs.c
block/cloop.c
block/commit.c
block/copy-before-write.c
block/copy-on-read.c
block/crypto.c
block/curl.c
block/dmg.c
block/file-posix.c
block/file-win32.c
block/filter-compress.c
block/mirror.c
block/nbd.c
block/nfs.c
block/null.c
block/nvme.c
block/preallocate.c
block/qcow.c
block/qcow2-cluster.c
block/qcow2.c
block/quorum.c
block/raw-format.c
block/rbd.c
block/throttle.c
block/vdi.c
block/vmdk.c
block/vpc.c
block/vvfat.c
include/block/block_int.h
tests/unit/test-bdrv-drain.c
tests/unit/test-block-iothread.c