summaryrefslogtreecommitdiff
path: root/blockjob.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-05-08 16:13:03 +0200
committerJeff Cody <jcody@redhat.com>2017-05-24 16:38:51 -0400
commitf321dcb57f50be177250c7c5ba4b6334e9cb6ca5 (patch)
treea90002fe1312444a8122d5e38c61e45bb0c249f0 /blockjob.c
parent05b0d8e3b8a1ed1a5840a317ce4f7f4ebe53156f (diff)
blockjob: introduce block_job_pause/resume_all
Remove use of block_job_pause/resume from outside blockjob.c, thus making them static. The new functions are used by the block layer, so place them in blockjob_int.h. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-id: 20170508141310.8674-5-pbonzini@redhat.com Signed-off-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r--blockjob.c114
1 files changed, 69 insertions, 45 deletions
diff --git a/blockjob.c b/blockjob.c
index 5a722c3635..85ad610cae 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -55,36 +55,6 @@ struct BlockJobTxn {
static QLIST_HEAD(, BlockJob) block_jobs = QLIST_HEAD_INITIALIZER(block_jobs);
-static char *child_job_get_parent_desc(BdrvChild *c)
-{
- BlockJob *job = c->opaque;
- return g_strdup_printf("%s job '%s'",
- BlockJobType_lookup[job->driver->job_type],
- job->id);
-}
-
-static const BdrvChildRole child_job = {
- .get_parent_desc = child_job_get_parent_desc,
- .stay_at_node = true,
-};
-
-static void block_job_drained_begin(void *opaque)
-{
- BlockJob *job = opaque;
- block_job_pause(job);
-}
-
-static void block_job_drained_end(void *opaque)
-{
- BlockJob *job = opaque;
- block_job_resume(job);
-}
-
-static const BlockDevOps block_job_dev_ops = {
- .drained_begin = block_job_drained_begin,
- .drained_end = block_job_drained_end,
-};
-
BlockJob *block_job_next(BlockJob *job)
{
if (!job) {
@@ -106,6 +76,21 @@ BlockJob *block_job_get(const char *id)
return NULL;
}
+static void block_job_pause(BlockJob *job)
+{
+ job->pause_count++;
+}
+
+static void block_job_resume(BlockJob *job)
+{
+ assert(job->pause_count > 0);
+ job->pause_count--;
+ if (job->pause_count) {
+ return;
+ }
+ block_job_enter(job);
+}
+
static void block_job_ref(BlockJob *job)
{
++job->refcnt;
@@ -171,6 +156,36 @@ static void block_job_detach_aio_context(void *opaque)
block_job_unref(job);
}
+static char *child_job_get_parent_desc(BdrvChild *c)
+{
+ BlockJob *job = c->opaque;
+ return g_strdup_printf("%s job '%s'",
+ BlockJobType_lookup[job->driver->job_type],
+ job->id);
+}
+
+static const BdrvChildRole child_job = {
+ .get_parent_desc = child_job_get_parent_desc,
+ .stay_at_node = true,
+};
+
+static void block_job_drained_begin(void *opaque)
+{
+ BlockJob *job = opaque;
+ block_job_pause(job);
+}
+
+static void block_job_drained_end(void *opaque)
+{
+ BlockJob *job = opaque;
+ block_job_resume(job);
+}
+
+static const BlockDevOps block_job_dev_ops = {
+ .drained_begin = block_job_drained_begin,
+ .drained_end = block_job_drained_end,
+};
+
void block_job_remove_all_bdrv(BlockJob *job)
{
GSList *l;
@@ -471,11 +486,6 @@ void block_job_complete(BlockJob *job, Error **errp)
job->driver->complete(job, errp);
}
-void block_job_pause(BlockJob *job)
-{
- job->pause_count++;
-}
-
void block_job_user_pause(BlockJob *job)
{
job->user_paused = true;
@@ -520,16 +530,6 @@ void coroutine_fn block_job_pause_point(BlockJob *job)
}
}
-void block_job_resume(BlockJob *job)
-{
- assert(job->pause_count > 0);
- job->pause_count--;
- if (job->pause_count) {
- return;
- }
- block_job_enter(job);
-}
-
void block_job_user_resume(BlockJob *job)
{
if (job && job->user_paused && job->pause_count > 0) {
@@ -723,6 +723,30 @@ static void block_job_event_completed(BlockJob *job, const char *msg)
&error_abort);
}
+void block_job_pause_all(void)
+{
+ BlockJob *job = NULL;
+ while ((job = block_job_next(job))) {
+ AioContext *aio_context = blk_get_aio_context(job->blk);
+
+ aio_context_acquire(aio_context);
+ block_job_pause(job);
+ aio_context_release(aio_context);
+ }
+}
+
+void block_job_resume_all(void)
+{
+ BlockJob *job = NULL;
+ while ((job = block_job_next(job))) {
+ AioContext *aio_context = blk_get_aio_context(job->blk);
+
+ aio_context_acquire(aio_context);
+ block_job_resume(job);
+ aio_context_release(aio_context);
+ }
+}
+
void block_job_event_ready(BlockJob *job)
{
job->ready = true;