* [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring
@ 2016-06-12 1:18 Eric Blake
2016-06-12 2:15 ` Fam Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2016-06-12 1:18 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, qemu-block, Max Reitz, Jeff Cody
Commit e253f4b8 converted mirroring from sector-based bdrv_aio_*
to byte-based blk_aio_*, but failed to account for the subtle
difference in signatures (the former takes a semi-redundant length,
the latter takes a flags parameter). Since all of our flags are
currently smaller in size than BDRV_SECTOR_SIZE, it has no ill
effects until we either perform sub-sector mirroring, or we start
asserting that no unexpected flags are set. I found it while
testing new asserts when qemu-iotests 132 started warning about an
unknown flag 0x200000.
Add an assert to help us catch any other improper flags.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/block-backend.c | 2 ++
block/mirror.c | 6 ++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 34500e6..a5dc6e3 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -945,6 +945,8 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
acb->bh = NULL;
acb->has_returned = false;
+ assert(flags <= 0x1f);
+
co = qemu_coroutine_create(co_entry);
qemu_coroutine_enter(co, acb);
diff --git a/block/mirror.c b/block/mirror.c
index fbbc496..41848b2 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -157,8 +157,7 @@ static void mirror_read_complete(void *opaque, int ret)
return;
}
blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
- op->nb_sectors * BDRV_SECTOR_SIZE,
- mirror_write_complete, op);
+ 0, mirror_write_complete, op);
}
static inline void mirror_clip_sectors(MirrorBlockJob *s,
@@ -275,8 +274,7 @@ static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num,
s->sectors_in_flight += nb_sectors;
trace_mirror_one_iteration(s, sector_num, nb_sectors);
- blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,
- nb_sectors * BDRV_SECTOR_SIZE,
+ blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov, 0,
mirror_read_complete, op);
return ret;
}
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring
2016-06-12 1:18 [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring Eric Blake
@ 2016-06-12 2:15 ` Fam Zheng
2016-06-13 12:39 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2016-06-12 2:15 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-devel, kwolf, Jeff Cody, qemu-block, Max Reitz
On Sat, 06/11 19:18, Eric Blake wrote:
> Commit e253f4b8 converted mirroring from sector-based bdrv_aio_*
> to byte-based blk_aio_*, but failed to account for the subtle
> difference in signatures (the former takes a semi-redundant length,
> the latter takes a flags parameter). Since all of our flags are
> currently smaller in size than BDRV_SECTOR_SIZE, it has no ill
> effects until we either perform sub-sector mirroring, or we start
> asserting that no unexpected flags are set. I found it while
> testing new asserts when qemu-iotests 132 started warning about an
> unknown flag 0x200000.
>
> Add an assert to help us catch any other improper flags.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> block/block-backend.c | 2 ++
> block/mirror.c | 6 ++----
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 34500e6..a5dc6e3 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -945,6 +945,8 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
> acb->bh = NULL;
> acb->has_returned = false;
>
> + assert(flags <= 0x1f);
> +
Maybe define BDRV_REQ_FLAGS_MAX in include/block/block.h so it's easier to keep
this assertion valid when we introduce more flags in the future?
Otherwise the patch looks good.
Fam
> co = qemu_coroutine_create(co_entry);
> qemu_coroutine_enter(co, acb);
>
> diff --git a/block/mirror.c b/block/mirror.c
> index fbbc496..41848b2 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -157,8 +157,7 @@ static void mirror_read_complete(void *opaque, int ret)
> return;
> }
> blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
> - op->nb_sectors * BDRV_SECTOR_SIZE,
> - mirror_write_complete, op);
> + 0, mirror_write_complete, op);
> }
>
> static inline void mirror_clip_sectors(MirrorBlockJob *s,
> @@ -275,8 +274,7 @@ static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num,
> s->sectors_in_flight += nb_sectors;
> trace_mirror_one_iteration(s, sector_num, nb_sectors);
>
> - blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,
> - nb_sectors * BDRV_SECTOR_SIZE,
> + blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov, 0,
> mirror_read_complete, op);
> return ret;
> }
> --
> 2.5.5
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring
2016-06-12 2:15 ` Fam Zheng
@ 2016-06-13 12:39 ` Eric Blake
0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-06-13 12:39 UTC (permalink / raw)
To: Fam Zheng; +Cc: qemu-devel, kwolf, Jeff Cody, qemu-block, Max Reitz
[-- Attachment #1: Type: text/plain, Size: 2102 bytes --]
On 06/11/2016 08:15 PM, Fam Zheng wrote:
> On Sat, 06/11 19:18, Eric Blake wrote:
>> Commit e253f4b8 converted mirroring from sector-based bdrv_aio_*
>> to byte-based blk_aio_*, but failed to account for the subtle
>> difference in signatures (the former takes a semi-redundant length,
>> the latter takes a flags parameter). Since all of our flags are
>> currently smaller in size than BDRV_SECTOR_SIZE, it has no ill
>> effects until we either perform sub-sector mirroring, or we start
>> asserting that no unexpected flags are set. I found it while
>> testing new asserts when qemu-iotests 132 started warning about an
>> unknown flag 0x200000.
>>
>> Add an assert to help us catch any other improper flags.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>> block/block-backend.c | 2 ++
>> block/mirror.c | 6 ++----
>> 2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/block/block-backend.c b/block/block-backend.c
>> index 34500e6..a5dc6e3 100644
>> --- a/block/block-backend.c
>> +++ b/block/block-backend.c
>> @@ -945,6 +945,8 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
>> acb->bh = NULL;
>> acb->has_returned = false;
>>
>> + assert(flags <= 0x1f);
>> +
>
> Maybe define BDRV_REQ_FLAGS_MAX in include/block/block.h so it's easier to keep
> this assertion valid when we introduce more flags in the future?
Oh, good idea. And I also don't know if blk_aio_prwv() is really the
best place (it happened to be nicer for getting a good gdb backtrace of
the culprit caller prior to entering coroutines, since coroutines tend
to kill the call trace - but is too narrow in that it doesn't catch
non-aio entry into the block layer) - so I should probably make the
actual asserts live in better places like bdrv_driver_p*. I'll split
the patch between bug fix and assertion additions, v2 coming up later today.
>
> Otherwise the patch looks good.
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-13 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-12 1:18 [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring Eric Blake
2016-06-12 2:15 ` Fam Zheng
2016-06-13 12:39 ` Eric Blake
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.