提交 8493211c 编写于 作者: E Eric Blake 提交者: Kevin Wolf

stream: Switch stream_populate() to byte-based

We are gradually converting to byte-based interfaces, as they are
easier to reason about than sector-based.  Start by converting an
internal function (no semantic change).
Signed-off-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NJohn Snow <jsnow@redhat.com>
Reviewed-by: NJeff Cody <jcody@redhat.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 5cb1a49e
...@@ -41,20 +41,20 @@ typedef struct StreamBlockJob { ...@@ -41,20 +41,20 @@ typedef struct StreamBlockJob {
} StreamBlockJob; } StreamBlockJob;
static int coroutine_fn stream_populate(BlockBackend *blk, static int coroutine_fn stream_populate(BlockBackend *blk,
int64_t sector_num, int nb_sectors, int64_t offset, uint64_t bytes,
void *buf) void *buf)
{ {
struct iovec iov = { struct iovec iov = {
.iov_base = buf, .iov_base = buf,
.iov_len = nb_sectors * BDRV_SECTOR_SIZE, .iov_len = bytes,
}; };
QEMUIOVector qiov; QEMUIOVector qiov;
assert(bytes < SIZE_MAX);
qemu_iovec_init_external(&qiov, &iov, 1); qemu_iovec_init_external(&qiov, &iov, 1);
/* Copy-on-read the unallocated clusters */ /* Copy-on-read the unallocated clusters */
return blk_co_preadv(blk, sector_num * BDRV_SECTOR_SIZE, qiov.size, &qiov, return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_READ);
BDRV_REQ_COPY_ON_READ);
} }
typedef struct { typedef struct {
...@@ -171,7 +171,8 @@ static void coroutine_fn stream_run(void *opaque) ...@@ -171,7 +171,8 @@ static void coroutine_fn stream_run(void *opaque)
trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE, trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, ret); n * BDRV_SECTOR_SIZE, ret);
if (copy) { if (copy) {
ret = stream_populate(blk, sector_num, n, buf); ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, buf);
} }
if (ret < 0) { if (ret < 0) {
BlockErrorAction action = BlockErrorAction action =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册