aboutsummaryrefslogtreecommitdiff
path: root/blockjob.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2018-03-10 03:27:38 -0500
committerKevin Wolf <kwolf@redhat.com>2018-03-19 12:01:24 +0100
commit43628d9336e832c07dc964433bdfaee44c49e5ac (patch)
treee7b00705e7298c2e7725556d7e76e2d5f5ce88c7 /blockjob.c
parent35d6b368f2fcc52de01773b80246bfbe55211903 (diff)
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: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r--blockjob.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/blockjob.c b/blockjob.c
index 61af628376..0c64fadc6d 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -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)
{
assert(job->completed);
@@ -423,17 +446,11 @@ static void block_job_completed_single(BlockJob *job)
block_job_update_rc(job);
if (!job->ret) {
- if (job->driver->commit) {
- job->driver->commit(job);
- }
+ block_job_commit(job);
} else {
- if (job->driver->abort) {
- job->driver->abort(job);
- }
- }
- if (job->driver->clean) {
- job->driver->clean(job);
+ block_job_abort(job);
}
+ block_job_clean(job);
if (job->cb) {
job->cb(job->opaque, job->ret);