qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Jeff Cody <jcody@redhat.com>, Max Reitz <mreitz@redhat.com>,
	jtc@redhat.com, Markus Armbruster <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 16/21] block/commit: refactor commit to use job callbacks
Date: Thu, 16 Aug 2018 08:52:21 +0200	[thread overview]
Message-ID: <20180816065221.GB5511@localhost.localdomain> (raw)
In-Reply-To: <60ef1ca4-2b17-3600-972a-ecf004fd989c@redhat.com>

Am 15.08.2018 um 23:17 hat John Snow geschrieben:
> On 08/09/2018 11:12 AM, Kevin Wolf wrote:
> > Am 07.08.2018 um 06:33 hat John Snow geschrieben:
> >> Use the component callbacks; prepare, commit, abort, and clean.
> >>
> >> NB: prepare is only called when the job has not yet failed;
> >> and abort can be called after prepare.
> >>
> >> complete -> prepare -> abort -> clean
> >> complete -> abort -> clean
> > 
> > I always found this confusing. After converting all jobs to use the
> > infrastructure, do you think that this design is helpful? You seem to be
> > calling *_common function from commit and abort, with an almost empty
> > prepare, which looks like a hint that maybe we should reorganise things.
> > 
> 
> After rewriting things a bit, I think it would be nicer to call prepare
> regardless of circumstances. The callbacks will be nicer for it.
> 
> When I wrote it the first time, the thought process was something like:
> 
> "Well, we won't need to prepare anything if we've already failed, we
> just need to speed along to abort."
> 
> I wasn't considering so carefully the common cleanup case that needs to
> occur post-finalization which appears to actually happen in a good
> number of jobs.

Maybe let's see how things turn out when we actually make some more jobs
transactionable. For now, it seems that the *_common function can go
away at least for commit; and we didn't even try to properly split the
completion of the other two jobs.

> >> Signed-off-by: John Snow <jsnow@redhat.com>
> >> ---
> >>  block/commit.c | 94 +++++++++++++++++++++++++++++++++++++---------------------
> >>  1 file changed, 61 insertions(+), 33 deletions(-)
> >>
> >> diff --git a/block/commit.c b/block/commit.c
> >> index 1a4a56795f..6673a0544e 100644
> >> --- a/block/commit.c
> >> +++ b/block/commit.c
> >> @@ -35,7 +35,9 @@ typedef struct CommitBlockJob {
> >>      BlockJob common;
> >>      BlockDriverState *commit_top_bs;
> >>      BlockBackend *top;
> >> +    BlockDriverState *top_bs;
> >>      BlockBackend *base;
> >> +    BlockDriverState *base_bs;
> >>      BlockdevOnError on_error;
> >>      int base_flags;
> >>      char *backing_file_str;
> > 
> > More state. :-(
> > 
> > Can we at least move the new fields to the end of the struct with a
> > comment that they are only valid after .exit()?
> > 
> 
> Sure ... admittedly this is just a crutch because I was not precisely
> sure exactly when these might change out from underneath me. If there
> are some clever ways to avoid needing the state, feel free to suggest them.

I did, in the reply to my own mail. Everything that would need the state
can actually live in .abort, so it can be local.

> >> +}
> >> +
> >> +static void commit_commit(Job *job)
> >> +{
> >> +    commit_exit_common(job);
> >> +}
> > 
> > (I think I've answered this question now, by effectively proposing to do
> > away with .commit, but I'll leave it there anyway.)
> > 
> > Is there any reason for the split between .prepare and .commit as it is
> > or is this mostly arbitrary? Probably the latter because commit isn't
> > even transactionable?
> > 
> 
> Just historical, yeah -- we only had commit and abort for a while, and
> prepare didn't join the party until we wanted finalize and it became
> apparent we needed a way to check the return code and still be able to
> fail the transaction in time to be able to do a final commit or still
> abort very, very late in the process.
> 
> Probably there's no real meaningful reason that prepare and commit need
> to be separate callbacks.
> 
> It is possible that:
> 
> prepare --> [abort] --> clean
> 
> would be entirely sufficient for all current cases.

I think jobs that actually support transactions (i.e. backup currently)
do in fact need commit. The other ones might not.

Kevin

  reply	other threads:[~2018-08-16  6:52 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07  4:33 [Qemu-devel] [PATCH 00/21] jobs: defer graph changes until finalize John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 01/21] jobs: canonize Error object John Snow
2018-08-08 14:57   ` Kevin Wolf
2018-08-08 15:50     ` John Snow
2018-08-08 16:02       ` Kevin Wolf
2018-08-07  4:33 ` [Qemu-devel] [PATCH 02/21] jobs: add exit shim John Snow
2018-08-08  4:02   ` Jeff Cody
2018-08-08 13:55     ` John Snow
2018-08-08 15:23     ` Kevin Wolf
2018-08-08 15:38       ` John Snow
2018-08-08 15:47         ` Kevin Wolf
2018-08-07  4:33 ` [Qemu-devel] [PATCH 03/21] block/backup: utilize job_exit shim John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 04/21] block/commit: " John Snow
2018-08-08  3:41   ` Jeff Cody
2018-08-08 14:00     ` John Snow
2018-08-08 16:29   ` Kevin Wolf
2018-08-15 20:52     ` John Snow
2018-08-16  6:41       ` Kevin Wolf
2018-08-07  4:33 ` [Qemu-devel] [PATCH 05/21] block/mirror: " John Snow
2018-08-08  3:47   ` Jeff Cody
2018-08-07  4:33 ` [Qemu-devel] [PATCH 06/21] block/stream: " John Snow
2018-08-08  3:47   ` Jeff Cody
2018-08-07  4:33 ` [Qemu-devel] [PATCH 07/21] block/create: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 08/21] tests/test-blockjob-txn: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 09/21] tests/test-blockjob: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 10/21] tests/test-bdrv-drain: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 11/21] jobs: remove job_defer_to_main_loop John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 12/21] jobs: allow entrypoints to return status code John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 13/21] block/commit: add block job creation flags John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 14/21] block/mirror: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 15/21] block/stream: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 16/21] block/commit: refactor commit to use job callbacks John Snow
2018-08-09 15:12   ` Kevin Wolf
2018-08-09 16:22     ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2018-08-15 21:17     ` [Qemu-devel] " John Snow
2018-08-16  6:52       ` Kevin Wolf [this message]
2018-08-07  4:33 ` [Qemu-devel] [PATCH 17/21] block/mirror: conservative mirror_exit refactor John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 18/21] block/commit: refactor stream to use job callbacks John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 19/21] qapi/block-commit: expose new job properties John Snow
2018-08-07 14:52   ` Eric Blake
2018-08-07 18:11     ` John Snow
2018-08-10 11:47     ` Kevin Wolf
2018-08-07  4:33 ` [Qemu-devel] [PATCH 20/21] qapi/block-mirror: " John Snow
2018-08-07  4:33 ` [Qemu-devel] [PATCH 21/21] qapi/block-stream: " John Snow
2018-08-15 14:44 ` [Qemu-devel] [Qemu-block] [PATCH 00/21] jobs: defer graph changes until finalize Peter Krempa
2018-08-15 15:00   ` Kevin Wolf
2018-08-15 15:04     ` Peter Krempa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180816065221.GB5511@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=jtc@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).