From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: jcody@redhat.com, jsnow@redhat.com, berto@igalia.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 13/14] commit: Use BlockBackend for I/O
Date: Fri, 13 May 2016 17:36:57 +0200 [thread overview]
Message-ID: <a9a99471-dd72-bde6-9924-498f37e0c8db@redhat.com> (raw)
In-Reply-To: <1462354765-14037-14-git-send-email-kwolf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4321 bytes --]
On 04.05.2016 11:39, Kevin Wolf wrote:
> This changes the commit block job to use the job's BlockBackend for
> performing its I/O. job->bs isn't used by the commit code any more
> afterwards.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/commit.c | 42 +++++++++++++++++++++++++++---------------
> 1 file changed, 27 insertions(+), 15 deletions(-)
>
> diff --git a/block/commit.c b/block/commit.c
> index f308c8c..863e059 100644
> --- a/block/commit.c
> +++ b/block/commit.c
> @@ -36,28 +36,34 @@ typedef struct CommitBlockJob {
> BlockJob common;
> RateLimit limit;
> BlockDriverState *active;
> - BlockDriverState *top;
> - BlockDriverState *base;
> + BlockBackend *top;
> + BlockBackend *base;
> BlockdevOnError on_error;
> int base_flags;
> int orig_overlay_flags;
> char *backing_file_str;
> } CommitBlockJob;
>
> -static int coroutine_fn commit_populate(BlockDriverState *bs,
> - BlockDriverState *base,
> +static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *base,
> int64_t sector_num, int nb_sectors,
> void *buf)
> {
> int ret = 0;
> + QEMUIOVector qiov;
> + struct iovec iov = {
> + .iov_base = (void *)buf,
Why the cast?
> + .iov_len = nb_sectors * BDRV_SECTOR_SIZE,
> + };
>
> - ret = bdrv_read(bs, sector_num, buf, nb_sectors);
> - if (ret) {
> + qemu_iovec_init_external(&qiov, &iov, 1);
> +
> + ret = blk_co_readv(bs, sector_num, nb_sectors, &qiov);
> + if (ret < 0) {
> return ret;
> }
>
> - ret = bdrv_write(base, sector_num, buf, nb_sectors);
> - if (ret) {
> + ret = blk_co_writev(base, sector_num, nb_sectors, &qiov);
> + if (ret < 0) {
> return ret;
> }
>
> @@ -73,8 +79,8 @@ static void commit_complete(BlockJob *job, void *opaque)
> CommitBlockJob *s = container_of(job, CommitBlockJob, common);
> CommitCompleteData *data = opaque;
> BlockDriverState *active = s->active;
> - BlockDriverState *top = s->top;
> - BlockDriverState *base = s->base;
> + BlockDriverState *top = blk_bs(s->top);
> + BlockDriverState *base = blk_bs(s->base);
> BlockDriverState *overlay_bs;
> int ret = data->ret;
>
> @@ -94,6 +100,8 @@ static void commit_complete(BlockJob *job, void *opaque)
> bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);
> }
> g_free(s->backing_file_str);
> + blk_unref(s->top);
> + blk_unref(s->base);
> block_job_completed(&s->common, ret);
> g_free(data);
> }
> @@ -102,8 +110,8 @@ static void coroutine_fn commit_run(void *opaque)
> {
> CommitBlockJob *s = opaque;
> CommitCompleteData *data;
> - BlockDriverState *top = s->top;
> - BlockDriverState *base = s->base;
> + BlockDriverState *top = blk_bs(s->top);
> + BlockDriverState *base = blk_bs(s->base);
I think for this function it would definitely be nicer to drop these
variables (or make them BlockBackend pointers) and use them with the
blk_* functions. The only function where this is not possible is
bdrv_is_allocated_above(), and I think it won't be too ugly to use
blk_bs() in its parameter list there.
> int64_t sector_num, end;
> int ret = 0;
> int n = 0;
> @@ -158,7 +166,7 @@ wait:
> goto wait;
> }
> }
> - ret = commit_populate(top, base, sector_num, n, buf);
> + ret = commit_populate(s->top, s->base, sector_num, n, buf);
> bytes_written += n * BDRV_SECTOR_SIZE;
> }
> if (ret < 0) {
> @@ -253,8 +261,12 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
> return;
> }
>
> - s->base = base;
> - s->top = top;
> + s->base = blk_new(&error_abort);
> + blk_insert_bs(s->base, base);
> +
> + s->top = blk_new(&error_abort);
> + blk_insert_bs(s->top, top);
> +
But again, this is why I'm hesitant to give an R-b for this patch.
Max
> s->active = bs;
>
> s->base_flags = orig_base_flags;
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-05-13 15:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-04 9:39 [Qemu-devel] [PATCH 00/14] block jobs: Convert I/O to BlockBackend Kevin Wolf
2016-05-04 9:39 ` [Qemu-devel] [PATCH 01/14] block: keep a list of block jobs Kevin Wolf
2016-05-13 13:09 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 02/14] block: Cancel jobs first in bdrv_close_all() Kevin Wolf
2016-05-06 9:17 ` Alberto Garcia
2016-05-13 13:14 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 03/14] block: Default to enabled write cache in blk_new() Kevin Wolf
2016-05-13 13:24 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 04/14] block: Convert block job core to BlockBackend Kevin Wolf
2016-05-13 13:45 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 05/14] stream: Use BlockBackend for I/O Kevin Wolf
2016-05-13 14:03 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 06/14] mirror: Allow target that already has a BlockBackend Kevin Wolf
2016-05-13 14:18 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 07/14] mirror: Use BlockBackend for I/O Kevin Wolf
2016-05-13 14:38 ` Max Reitz
2016-05-13 14:38 ` Max Reitz
2016-05-13 14:57 ` Eric Blake
2016-05-04 9:39 ` [Qemu-devel] [PATCH 08/14] backup: Don't leak BackupBlockJob in error path Kevin Wolf
2016-05-09 13:21 ` Alberto Garcia
2016-05-13 14:46 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 09/14] backup: Pack Notifier within BackupBlockJob Kevin Wolf
2016-05-13 15:01 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 10/14] backup: Remove bs parameter from backup_do_cow() Kevin Wolf
2016-05-13 15:06 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 11/14] block: Add blk_co_readv/writev() Kevin Wolf
2016-05-13 15:12 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 12/14] backup: Use BlockBackend for I/O Kevin Wolf
2016-05-13 15:25 ` Max Reitz
2016-05-04 9:39 ` [Qemu-devel] [PATCH 13/14] commit: " Kevin Wolf
2016-05-13 15:36 ` Max Reitz [this message]
2016-05-04 9:39 ` [Qemu-devel] [PATCH 14/14] blockjob: Remove BlockJob.bs Kevin Wolf
2016-05-13 15:37 ` Max Reitz
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=a9a99471-dd72-bde6-9924-498f37e0c8db@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@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).