[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [RFC v4 15/21] blockjobs: add prepare call

From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [RFC v4 15/21] blockjobs: add prepare callback
Date: Tue, 27 Feb 2018 13:56:50 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 02/23/2018 05:51 PM, John Snow wrote:
Some jobs upon finalization may need to perform some work that can
still fail. If these jobs are part of a transaction, it's important
that these callbacks fail the entire transaction.

We allow for a new callback in addition to commit/abort/clean that
allows us the opportunity to have fairly late-breaking failures
in the transactional process.

The expected flow is:

- All jobs in a transaction converge to the WAITING state
   (added in a forthcoming commit)
- All jobs prepare to call either commit/abort
- If any job fails, is canceled, or fails preparation, all jobs
   call their .abort callback.
- All jobs enter the PENDING state, awaiting manual intervention
   (also added in a forthcoming commit)
- block-job-finalize is issued by the user/management layer
- All jobs call their commit callbacks.

Signed-off-by: John Snow <address@hidden>
  blockjob.c                   | 34 +++++++++++++++++++++++++++++++---
  include/block/blockjob_int.h | 10 ++++++++++
  2 files changed, 41 insertions(+), 3 deletions(-)

@@ -467,17 +480,22 @@ static void block_job_cancel_async(BlockJob *job)
      job->cancelled = true;
-static void block_job_txn_apply(BlockJobTxn *txn, void fn(BlockJob *))
+static int block_job_txn_apply(BlockJobTxn *txn, int fn(BlockJob *))
      AioContext *ctx;
      BlockJob *job, *next;
+    int rc;
QLIST_FOREACH_SAFE(job, &txn->jobs, txn_list, next) {
          ctx = blk_get_aio_context(job->blk);
-        fn(job);
+        rc = fn(job);
+        if (rc) {
+            break;
+        }

This short-circuits the application of the function to the rest of the group. Is that ever going to be a problem?

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]