aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2020-02-14 21:08:09 +0100
committerKevin Wolf <kwolf@redhat.com>2020-02-18 10:53:56 +0100
commit0c42e175fcc9d9ed888e4d7a30237ddf36454d19 (patch)
treec298090b02a0fd9dc5b4247d511e1bb98e05f70f
parentc5507b4d55f1f2989d3c108be387f62ed092ddc0 (diff)
commit: Inline commit_populate()
commit_populate() is a very short function and only called in a single place. Its return value doesn't tell us whether an error happened while reading or writing, which would be necessary for sending the right data in the BLOCK_JOB_ERROR QMP event. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200214200812.28180-5-kwolf@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/commit.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/block/commit.c b/block/commit.c
index 8189f079d2..2992a1012f 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -43,27 +43,6 @@ typedef struct CommitBlockJob {
char *backing_file_str;
} CommitBlockJob;
-static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *base,
- int64_t offset, uint64_t bytes,
- void *buf)
-{
- int ret = 0;
-
- assert(bytes < SIZE_MAX);
-
- ret = blk_co_pread(bs, offset, bytes, buf, 0);
- if (ret < 0) {
- return ret;
- }
-
- ret = blk_co_pwrite(base, offset, bytes, buf, 0);
- if (ret < 0) {
- return ret;
- }
-
- return 0;
-}
-
static int commit_prepare(Job *job)
{
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
@@ -178,7 +157,12 @@ static int coroutine_fn commit_run(Job *job, Error **errp)
copy = (ret == 1);
trace_commit_one_iteration(s, offset, n, ret);
if (copy) {
- ret = commit_populate(s->top, s->base, offset, n, buf);
+ assert(n < SIZE_MAX);
+
+ ret = blk_co_pread(s->top, offset, n, buf, 0);
+ if (ret >= 0) {
+ ret = blk_co_pwrite(s->base, offset, n, buf, 0);
+ }
}
if (ret < 0) {
BlockErrorAction action =