[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 09/12] mirror: switch mirror_iteration to AIO
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH v3 09/12] mirror: switch mirror_iteration to AIO |
Date: |
Mon, 21 Jan 2013 19:59:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 |
Am 21.01.2013 17:09, schrieb Paolo Bonzini:
> There is really no change in the behavior of the job here, since
> there is still a maximum of one in-flight I/O operation between
> the source and the target. However, this patch already introduces
> the AIO callbacks (which are unmodified in the next patch)
> and some of the logic to count in-flight operations and only
> complete the job when there is none.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> v2->v3: Only set cow_bitmap after successful write. [Kevin]
> Fix resolution of SLICE_TIME in comment. [Kevin]
> Remove extraneous change from "goto" to "break". [Kevin]
> Rename "nb_sectors_chunk" to "sectors_per_chunk" [Kevin]
> and consistently use "chunks" in all related variables.
>
> block/mirror.c | 166
> +++++++++++++++++++++++++++++++++++++++++++--------------
> trace-events | 2 +
> 2 files changed, 127 insertions(+), 41 deletions(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index ca0c5a1..dd7436b 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -33,8 +33,19 @@ typedef struct MirrorBlockJob {
> unsigned long *cow_bitmap;
> HBitmapIter hbi;
> uint8_t *buf;
> +
> + int in_flight;
> + int ret;
> } MirrorBlockJob;
>
> +typedef struct MirrorOp {
> + MirrorBlockJob *s;
> + QEMUIOVector qiov;
> + struct iovec iov;
> + int64_t sector_num;
> + int nb_sectors;
> +} MirrorOp;
> +
> static BlockErrorAction mirror_error_action(MirrorBlockJob *s, bool read,
> int error)
> {
> @@ -48,15 +59,69 @@ static BlockErrorAction
> mirror_error_action(MirrorBlockJob *s, bool read,
> }
> }
>
> -static int coroutine_fn mirror_iteration(MirrorBlockJob *s,
> - BlockErrorAction *p_action)
> +static void mirror_iteration_done(MirrorOp *op)
> +{
> + MirrorBlockJob *s = op->s;
> + int64_t chunk_num;
> + int nb_chunks, sectors_per_chunk;
> +
> + s->in_flight--;
> + sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
> + chunk_num = op->sector_num / sectors_per_chunk;
> + nb_chunks = op->nb_sectors / sectors_per_chunk;
> + if (s->cow_bitmap) {
&& ret >= 0? (ret would have to be passed by the callers)
> + bitmap_set(s->cow_bitmap, chunk_num, nb_chunks);
> + }
> +
> + trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors);
> + g_slice_free(MirrorOp, op);
> + qemu_coroutine_enter(s->common.co, NULL);
> +}
Kevin
- [Qemu-devel] [PATCH v3 00/12] Drive mirroring performance improvements, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 08/12] mirror: allow customizing the granularity, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 05/12] mirror: perform COW if the cluster size is bigger than the granularity, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 07/12] block: allow customizing the granularity of the dirty bitmap, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 06/12] block: return count of dirty sectors, not chunks, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 09/12] mirror: switch mirror_iteration to AIO, Paolo Bonzini, 2013/01/21
- Re: [Qemu-devel] [PATCH v3 09/12] mirror: switch mirror_iteration to AIO,
Kevin Wolf <=
- [Qemu-devel] [PATCH v3 10/12] mirror: add buf-size argument to drive-mirror, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 12/12] mirror: support arbitrarily-sized iterations, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 11/12] mirror: support more than one in-flight AIO operation, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 04/12] block: make round_to_clusters public, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 03/12] block: implement dirty bitmap using HBitmap, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 02/12] add hierarchical bitmap data type and test cases, Paolo Bonzini, 2013/01/21
- [Qemu-devel] [PATCH v3 01/12] host-utils: add ffsl, Paolo Bonzini, 2013/01/21