提交 43628d93 编写于 作者: J John Snow 提交者: Kevin Wolf

blockjobs: add commit, abort, clean helpers

The completed_single function is getting a little mucked up with
checking to see which callbacks exist, so let's factor them out.
Signed-off-by: NJohn Snow <jsnow@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 35d6b368
...@@ -415,6 +415,29 @@ static void block_job_update_rc(BlockJob *job) ...@@ -415,6 +415,29 @@ static void block_job_update_rc(BlockJob *job)
} }
} }
static void block_job_commit(BlockJob *job)
{
assert(!job->ret);
if (job->driver->commit) {
job->driver->commit(job);
}
}
static void block_job_abort(BlockJob *job)
{
assert(job->ret);
if (job->driver->abort) {
job->driver->abort(job);
}
}
static void block_job_clean(BlockJob *job)
{
if (job->driver->clean) {
job->driver->clean(job);
}
}
static void block_job_completed_single(BlockJob *job) static void block_job_completed_single(BlockJob *job)
{ {
assert(job->completed); assert(job->completed);
...@@ -423,17 +446,11 @@ static void block_job_completed_single(BlockJob *job) ...@@ -423,17 +446,11 @@ static void block_job_completed_single(BlockJob *job)
block_job_update_rc(job); block_job_update_rc(job);
if (!job->ret) { if (!job->ret) {
if (job->driver->commit) { block_job_commit(job);
job->driver->commit(job);
}
} else { } else {
if (job->driver->abort) { block_job_abort(job);
job->driver->abort(job);
}
}
if (job->driver->clean) {
job->driver->clean(job);
} }
block_job_clean(job);
if (job->cb) { if (job->cb) {
job->cb(job->opaque, job->ret); job->cb(job->opaque, job->ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册