From: Kevin Wolf <kwolf@redhat.com>
To: Charlie Shepherd <charlie@ctshepherd.com>
Cc: pbonzini@redhat.com, gabriel@kerneis.info, qemu-devel@nongnu.org,
stefanha@gmail.com
Subject: Re: [Qemu-devel] [PATCH 4/5] Convert block functions to coroutine versions
Date: Tue, 6 Aug 2013 11:36:28 +0200 [thread overview]
Message-ID: <20130806093628.GG3117@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1375728247-1306-5-git-send-email-charlie@ctshepherd.com>
Am 05.08.2013 um 20:44 hat Charlie Shepherd geschrieben:
> This patch follows on from the previous one and converts some block layer functions to be
> explicitly annotated with coroutine_fn instead of yielding depending upon calling context.
> ---
> block.c | 235 ++++++++++++++++++++++++++------------------------
> block/mirror.c | 4 +-
> include/block/block.h | 37 ++++----
> 3 files changed, 148 insertions(+), 128 deletions(-)
>
> diff --git a/block.c b/block.c
> index aaa122c..e7011f9 100644
> --- a/block.c
> +++ b/block.c
> @@ -164,7 +164,7 @@ bool bdrv_io_limits_enabled(BlockDriverState *bs)
> || io_limits->iops[BLOCK_IO_LIMIT_TOTAL];
> }
>
> -static void bdrv_io_limits_intercept(BlockDriverState *bs,
> +static void coroutine_fn bdrv_io_limits_intercept(BlockDriverState *bs,
> bool is_write, int nb_sectors)
> {
> int64_t wait_time = -1;
> @@ -364,7 +364,7 @@ BlockDriver *bdrv_find_whitelisted_format(const char *format_name,
>
> typedef struct CreateCo {
> BlockDriver *drv;
> - char *filename;
> + const char *filename;
> QEMUOptionParameter *options;
> int ret;
> } CreateCo;
Like Gabriel said, this should be a separate patch. Keeping it in this
series is probably easiest.
> @@ -372,48 +372,48 @@ typedef struct CreateCo {
> static void coroutine_fn bdrv_create_co_entry(void *opaque)
> {
> CreateCo *cco = opaque;
> - assert(cco->drv);
> -
> - cco->ret = cco->drv->bdrv_co_create(cco->filename, cco->options);
> + cco->ret = bdrv_create(cco->drv, cco->filename, cco->options);
> }
>
> -int bdrv_create(BlockDriver *drv, const char* filename,
> +int coroutine_fn bdrv_create(BlockDriver *drv, const char* filename,
> QEMUOptionParameter *options)
> {
> int ret;
> + char *dup_fn;
> +
> + assert(drv);
> + if (!drv->bdrv_co_create) {
> + return -ENOTSUP;
> + }
>
> + dup_fn = g_strdup(filename);
> + ret = drv->bdrv_co_create(dup_fn, options);
> + g_free(dup_fn);
> + return ret;
> +}
> +
> +
> +int bdrv_create_sync(BlockDriver *drv, const char* filename,
> + QEMUOptionParameter *options)
bdrv_foo_sync is an unfortunate naming convention, because
bdrv_pwrite_sync already exists and means something totally different:
It's a write directly followed by a disk flush.
> diff --git a/include/block/block.h b/include/block/block.h
> index dd8eca1..57d8ba2 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -125,9 +125,9 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top);
> void bdrv_delete(BlockDriverState *bs);
> int bdrv_parse_cache_flags(const char *mode, int *flags);
> int bdrv_parse_discard_flags(const char *mode, int *flags);
> -int bdrv_file_open(BlockDriverState **pbs, const char *filename,
> +int coroutine_fn bdrv_file_open(BlockDriverState **pbs, const char *filename,
> QDict *options, int flags);
> -int bdrv_open_backing_file(BlockDriverState *bs, QDict *options);
> +int coroutine_fn bdrv_open_backing_file(BlockDriverState *bs, QDict *options);
> int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
> int flags, BlockDriver *drv);
> BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
> @@ -150,18 +150,24 @@ void bdrv_dev_eject_request(BlockDriverState *bs, bool force);
> bool bdrv_dev_has_removable_media(BlockDriverState *bs);
> bool bdrv_dev_is_tray_open(BlockDriverState *bs);
> bool bdrv_dev_is_medium_locked(BlockDriverState *bs);
> -int bdrv_read(BlockDriverState *bs, int64_t sector_num,
> +int coroutine_fn bdrv_read(BlockDriverState *bs, int64_t sector_num,
> uint8_t *buf, int nb_sectors);
> -int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
> +int bdrv_read_sync(BlockDriverState *bs, int64_t sector_num,
> + uint8_t *buf, int nb_sectors);
> +int coroutine_fn bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
> uint8_t *buf, int nb_sectors);
> -int bdrv_write(BlockDriverState *bs, int64_t sector_num,
> +int coroutine_fn bdrv_write(BlockDriverState *bs, int64_t sector_num,
> + const uint8_t *buf, int nb_sectors);
> +int bdrv_write_sync(BlockDriverState *bs, int64_t sector_num,
> const uint8_t *buf, int nb_sectors);
> -int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov);
> -int bdrv_pread(BlockDriverState *bs, int64_t offset,
> +int coroutine_fn bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov);
> +int coroutine_fn bdrv_pread(BlockDriverState *bs, int64_t offset,
> + void *buf, int count);
> +int bdrv_pread_sync(BlockDriverState *bs, int64_t offset,
> void *buf, int count);
I haven't checked everything, but bdrv_pread_sync is an example of a
declaration without any user and without implementation.
Proper patch splitting will make review of such things easier, so I'll
defer thorough review until then.
Kevin
next prev parent reply other threads:[~2013-08-06 9:36 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-05 18:44 [Qemu-devel] RFC: [PATCH 0/5] Explicitly annotating coroutine_fn functions Charlie Shepherd
2013-08-05 18:44 ` [Qemu-devel] [PATCH 1/5] Add an explanation of when a function should be marked coroutine_fn Charlie Shepherd
2013-08-06 8:39 ` Stefan Hajnoczi
2013-08-08 1:20 ` Charlie Shepherd
2013-08-05 18:44 ` [Qemu-devel] [PATCH 2/5] qemu_coroutine_self should not be marked coroutine_fn as it cannot yield Charlie Shepherd
2013-08-07 19:18 ` Stefan Hajnoczi
2013-08-07 22:13 ` Gabriel Kerneis
2013-08-08 1:29 ` Charlie Shepherd
2013-08-08 6:16 ` Gabriel Kerneis
2013-08-08 9:10 ` Charlie Shepherd
2013-08-08 9:12 ` Gabriel Kerneis
2013-08-08 1:25 ` Charlie Shepherd
2013-08-05 18:44 ` [Qemu-devel] [PATCH 3/5] Convert BlockDriver to explicit coroutine annotations Charlie Shepherd
2013-08-05 19:23 ` Gabriel Kerneis
2013-08-05 19:33 ` Charlie Shepherd
2013-08-05 20:05 ` Gabriel Kerneis
2013-08-06 9:04 ` Kevin Wolf
2013-08-07 19:30 ` Stefan Hajnoczi
2013-08-08 1:31 ` Charlie Shepherd
2013-08-08 6:27 ` Gabriel Kerneis
2013-08-06 9:24 ` Kevin Wolf
2013-08-08 1:14 ` Charlie Shepherd
2013-08-05 18:44 ` [Qemu-devel] [PATCH 4/5] Convert block functions to coroutine versions Charlie Shepherd
2013-08-05 20:01 ` Gabriel Kerneis
2013-08-06 9:36 ` Kevin Wolf [this message]
2013-08-08 1:17 ` Charlie Shepherd
2013-08-05 18:44 ` [Qemu-devel] [PATCH 5/5] Convert block layer callers' annotations Charlie Shepherd
2013-08-05 20:15 ` Gabriel Kerneis
2013-08-08 1:19 ` Charlie Shepherd
2013-08-05 19:25 ` [Qemu-devel] RFC: [PATCH 0/5] Explicitly annotating coroutine_fn functions Charlie Shepherd
2013-08-06 7:06 ` Gabriel Kerneis
2013-08-06 9:37 ` Kevin Wolf
2013-08-08 1:22 ` Charlie Shepherd
2013-08-08 7:15 ` Kevin Wolf
2013-08-08 9:36 ` Charlie Shepherd
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=20130806093628.GG3117@dhcp-200-207.str.redhat.com \
--to=kwolf@redhat.com \
--cc=charlie@ctshepherd.com \
--cc=gabriel@kerneis.info \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).