Commit 3d70ff53 authored by Kevin Wolf's avatar Kevin Wolf
Browse files

job: Move completion and cancellation to Job



This moves the top-level job completion and cancellation functions from
BlockJob to Job.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 7eaa8fb5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -3362,7 +3362,9 @@ static void bdrv_close(BlockDriverState *bs)

void bdrv_close_all(void)
{
    block_job_cancel_sync_all();
    /* TODO We do want to cancel all jobs instead of just block jobs on
     * shutdown, but bdrv_close_all() isn't the right place any more. */
    job_cancel_sync_all();
    nbd_export_close_all();

    /* Drop references from requests still in flight, such as canceled block
+1 −2
Original line number Diff line number Diff line
@@ -319,10 +319,9 @@ typedef struct {

static void backup_complete(Job *job, void *opaque)
{
    BlockJob *bjob = container_of(job, BlockJob, job);
    BackupCompleteData *data = opaque;

    block_job_completed(bjob, data->ret);
    job_completed(job, data->ret);
    g_free(data);
}

+3 −3
Original line number Diff line number Diff line
@@ -112,12 +112,12 @@ static void commit_complete(Job *job, void *opaque)
    blk_unref(s->top);

    /* If there is more than one reference to the job (e.g. if called from
     * job_finish_sync()), block_job_completed() won't free it and therefore
     * the blockers on the intermediate nodes remain. This would cause
     * job_finish_sync()), job_completed() won't free it and therefore the
     * blockers on the intermediate nodes remain. This would cause
     * bdrv_set_backing_hd() to fail. */
    block_job_remove_all_bdrv(bjob);

    block_job_completed(&s->common, ret);
    job_completed(job, ret);
    g_free(data);

    /* If bdrv_drop_intermediate() didn't already do that, remove the commit
+3 −3
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ static void mirror_exit(Job *job, void *opaque)
    bdrv_release_dirty_bitmap(src, s->dirty_bitmap);

    /* Make sure that the source BDS doesn't go away before we called
     * block_job_completed(). */
     * job_completed(). */
    bdrv_ref(src);
    bdrv_ref(mirror_top_bs);
    bdrv_ref(target_bs);
@@ -581,7 +581,7 @@ static void mirror_exit(Job *job, void *opaque)
    blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
    blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);

    block_job_completed(&s->common, data->ret);
    job_completed(job, data->ret);

    g_free(data);
    bdrv_drained_end(src);
@@ -954,7 +954,7 @@ static void mirror_complete(Job *job, Error **errp)
    }

    s->should_complete = true;
    block_job_enter(&s->common);
    job_enter(job);
}

static void mirror_pause(Job *job)
+2 −2
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ static void replication_close(BlockDriverState *bs)
        replication_stop(s->rs, false, NULL);
    }
    if (s->stage == BLOCK_REPLICATION_FAILOVER) {
        block_job_cancel_sync(s->active_disk->bs->job);
        job_cancel_sync(&s->active_disk->bs->job->job);
    }

    if (s->mode == REPLICATION_MODE_SECONDARY) {
@@ -681,7 +681,7 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp)
         * disk, secondary disk in backup_job_completed().
         */
        if (s->secondary_disk->bs->job) {
            block_job_cancel_sync(s->secondary_disk->bs->job);
            job_cancel_sync(&s->secondary_disk->bs->job->job);
        }

        if (!failover) {
Loading