qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: jcody@redhat.com, armbru@redhat.com, qemu-block@nongnu.org,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/5] blockjob: add Job parameter to BlockCompletionFunc
Date: Mon, 18 Jan 2016 15:25:58 +0100	[thread overview]
Message-ID: <20160118142558.GB4558@noname.redhat.com> (raw)
In-Reply-To: <1452558972-20316-6-git-send-email-jsnow@redhat.com>

Am 12.01.2016 um 01:36 hat John Snow geschrieben:
> It will no longer be sufficient to rely on the opaque parameter
> containing a BDS, and there's no way to reliably include a
> self-reference to the job we're creating, so always pass the Job
> object forward to any callbacks.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  block/backup.c            |  2 +-
>  block/commit.c            |  2 +-
>  block/mirror.c            |  6 +++---
>  block/stream.c            |  2 +-
>  blockdev.c                | 14 +++++++-------
>  blockjob.c                | 13 +++++++++++--
>  include/block/block.h     |  2 ++
>  include/block/block_int.h | 10 +++++-----
>  include/block/blockjob.h  |  6 ++++--
>  qemu-img.c                |  4 ++--
>  tests/test-blockjob-txn.c |  4 ++--
>  11 files changed, 39 insertions(+), 26 deletions(-)
> 
> diff --git a/block/backup.c b/block/backup.c
> index 58c76be..cadb880 100644
> --- a/block/backup.c
> +++ b/block/backup.c
> @@ -506,7 +506,7 @@ BlockJob *backup_start(BlockDriverState *bs, BlockDriverState *target,
>                         BdrvDirtyBitmap *sync_bitmap,
>                         BlockdevOnError on_source_error,
>                         BlockdevOnError on_target_error,
> -                       BlockCompletionFunc *cb, void *opaque,
> +                       BlockJobCompletionFunc *cb, void *opaque,
>                         BlockJobTxn *txn, Error **errp)
>  {
>      int64_t len;
> diff --git a/block/commit.c b/block/commit.c
> index a5d02aa..ef4fd5a 100644
> --- a/block/commit.c
> +++ b/block/commit.c
> @@ -202,7 +202,7 @@ static const BlockJobDriver commit_job_driver = {
>  
>  void commit_start(BlockDriverState *bs, BlockDriverState *base,
>                    BlockDriverState *top, int64_t speed,
> -                  BlockdevOnError on_error, BlockCompletionFunc *cb,
> +                  BlockdevOnError on_error, BlockJobCompletionFunc *cb,
>                    void *opaque, const char *backing_file_str, Error **errp)
>  {
>      CommitBlockJob *s;
> diff --git a/block/mirror.c b/block/mirror.c
> index 92706ab..18134e4 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -714,7 +714,7 @@ static BlockJob *mirror_start_job(BlockDriverState *bs,
>                                    BlockdevOnError on_source_error,
>                                    BlockdevOnError on_target_error,
>                                    bool unmap,
> -                                  BlockCompletionFunc *cb,
> +                                  BlockJobCompletionFunc *cb,
>                                    void *opaque, Error **errp,
>                                    const BlockJobDriver *driver,
>                                    bool is_none_mode, BlockDriverState *base)
> @@ -801,7 +801,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
>                    MirrorSyncMode mode, BlockdevOnError on_source_error,
>                    BlockdevOnError on_target_error,
>                    bool unmap,
> -                  BlockCompletionFunc *cb,
> +                  BlockJobCompletionFunc *cb,
>                    void *opaque, Error **errp)
>  {
>      bool is_none_mode;
> @@ -826,7 +826,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
>  BlockJob *commit_active_start(BlockDriverState *bs, BlockDriverState *base,
>                                int64_t speed,
>                                BlockdevOnError on_error,
> -                              BlockCompletionFunc *cb,
> +                              BlockJobCompletionFunc *cb,
>                                void *opaque, Error **errp)
>  {
>      int64_t length, base_length;
> diff --git a/block/stream.c b/block/stream.c
> index 1dfeac0..1bd8220 100644
> --- a/block/stream.c
> +++ b/block/stream.c
> @@ -216,7 +216,7 @@ static const BlockJobDriver stream_job_driver = {
>  BlockJob *stream_start(BlockDriverState *bs, BlockDriverState *base,
>                    const char *backing_file_str, int64_t speed,
>                    BlockdevOnError on_error,
> -                  BlockCompletionFunc *cb,
> +                  BlockJobCompletionFunc *cb,
>                    void *opaque, Error **errp)
>  {
>      StreamBlockJob *s;
> diff --git a/blockdev.c b/blockdev.c
> index 9b37ace..6713ecb 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2855,28 +2855,28 @@ out:
>      aio_context_release(aio_context);
>  }
>  
> -static void block_job_cb(void *opaque, int ret)
> +static void block_job_cb(BlockJob *job, int ret)
>  {
>      /* Note that this function may be executed from another AioContext besides
>       * the QEMU main loop.  If you need to access anything that assumes the
>       * QEMU global mutex, use a BH or introduce a mutex.
>       */
>  
> -    BlockDriverState *bs = opaque;
> +    BlockDriverState *bs = job->bs;
>      const char *msg = NULL;
>  
> -    trace_block_job_cb(bs, bs->job, ret);
> +    trace_block_job_cb(bs, job, ret);

You could directly use job->bs here, then the last user of the local
variable bs is gone.

> -    assert(bs->job);
> +    assert(job);

That's a bit late. If job == NULL, we have already segfaulted. I'd
suggest to just remove the assertion now that the job is directly
passed.

Kevin

      reply	other threads:[~2016-01-18 14:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12  0:36 [Qemu-devel] [PATCH 0/5] block: reduce reliance on bs->job pointer John Snow
2016-01-12  0:36 ` [Qemu-devel] [PATCH 1/5] block: Allow mirror_start to return job references John Snow
2016-01-12  0:36 ` [Qemu-devel] [PATCH 2/5] block: Allow stream_start " John Snow
2016-01-12  0:36 ` [Qemu-devel] [PATCH 3/5] block: allow backup_start " John Snow
2016-01-12  0:36 ` [Qemu-devel] [PATCH 4/5] block/backup: Add subclassed notifier John Snow
2016-01-12  8:46   ` Paolo Bonzini
2016-01-12 17:57     ` John Snow
2016-01-12 18:01       ` Paolo Bonzini
2016-01-12 18:02         ` John Snow
2016-01-18 14:29           ` Kevin Wolf
2016-01-18 16:20             ` John Snow
2016-01-12  0:36 ` [Qemu-devel] [PATCH 5/5] blockjob: add Job parameter to BlockCompletionFunc John Snow
2016-01-18 14:25   ` Kevin Wolf [this message]

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=20160118142558.GB4558@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@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).