[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/8] block: add missing coroutine_fn annotations


  • To: Kevin Wolf <kwolf@xxxxxxxxxx>
  • From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
  • Date: Sat, 25 Jul 2026 01:20:14 +0400
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/2m0dqcoMneC3Zf15VEtk2J/x4FvDYNzHSWnoIQbyCM=; fh=SyT053ljnhqOzbbXkLLuNSP6fA0uzMsv4ECq2hzhfN4=; b=PcnU5ta2bJPuam8AldskWrxa7FUS9EiEoXxF7z6S59kEaughroEtpfkmIgicHk9Qju 939At7B7FzPZJX9Z4l6Ru2dU8B9egihgxgnVIaFKxkyqcZ76WOoAFxmFdm4Y4ri039Nl WJOSy0jIwDHuir1aJM1qW9Ul8/QAfvfd4Q3rqqVYCdmfHDEY9OiuMS+DEmnC5CbPTaEa aAq++wrVKHAPKtzhxi1cLZxBjlOfaMrigp/3UpEqAeBUY3QLcyJG5zZ8kOXZwb3UOK5B Sq5tfAlKEj88B0YmTp8UBq/y7AKpYsitJTn8kmA0etDvQwV8oQVZrg3TASnA01kr7Qwj Rj+Q==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1784928027; cv=none; d=google.com; s=arc-20260327; b=hnDhozoSoJHfBc+xyUWTKBC4HfQbEXGP6V0nAUwIS7VcZALo0yESM2LtmgbRYhT6u5 6CEE4710kCHMNSxdDQDpXkYCr45h9cbLDECUXvYp0OMxFymPChsSmtc2q+N/aqzp1u4f Fbbu+w6yKTVkbeTaYDbpFciGskaRRCWWJ0+wKzqn4uGUi4IILjSCHWhuIgqyL4X655A/ FRWqaISkPvLaDoTb2bSPTiz5wVrClDtcufcKhX4khz0JM79vvaXJ9qrkIKz/ZCJvNe3C guxLnpNtkMeYrWEywEdcac+1Uta+XWpoYj+125/Eo8Yl+YHLcjsLoVJJYsUtiTmFiHVx TyHQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=redhat.com header.i="@redhat.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: qemu-devel@xxxxxxxxxx, Markus Armbruster <armbru@xxxxxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Fabiano Rosas <farosas@xxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxxx>, Hanna Reitz <hreitz@xxxxxxxxxx>, qemu-block@xxxxxxxxxx, Stefan Hajnoczi <stefanha@xxxxxxxxxx>, Fam Zheng <fam@xxxxxxxxxx>, "Denis V. Lunev" <den@xxxxxxxxxx>, Christian Schoenebeck <qemu_oss@xxxxxxxxxxxxx>, Greg Kurz <groug@xxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Li Zhijian <lizhijian@xxxxxxxxxxx>
  • Delivery-date: Fri, 24 Jul 2026 21:20:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi

On Fri, Jul 24, 2026 at 5:20 PM Kevin Wolf <kwolf@xxxxxxxxxx> wrote:
>
> Am 20.07.2026 um 09:55 hat Marc-André Lureau geschrieben:
> > The functions call coroutine functions or are called by coroutine.
>
> That it's called only by coroutines isn't a reason to make a function
> coroutine_fn as long as it theoretically could be called by
> non-coroutine code and it would still work fine (i.e. it doesn't yield).
>
> > Add an assert() in qcow2_do_close() code path which calls a
> > no_coroutine_fn bdrv_graph_wrlock_drained().
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
>
> > diff --git a/block/parallels.c b/block/parallels.c
> > index 7a90fb5220b..46a6e8f2743 100644
> > --- a/block/parallels.c
> > +++ b/block/parallels.c
> > @@ -142,8 +142,9 @@ static uint32_t host_cluster_index(BDRVParallelsState 
> > *s, int64_t off)
> >      return off / s->cluster_size;
> >  }
> >
> > -static int64_t block_status(BDRVParallelsState *s, int64_t sector_num,
> > -                            int nb_sectors, int *pnum)
> > +static int64_t coroutine_fn
> > +block_status(BDRVParallelsState *s, int64_t sector_num,
> > +             int nb_sectors, int *pnum)
> >  {
> >      int64_t start_off = -2, prev_end_off = -2;
> >
>
> Specifically this hunk is unclear to me.
>
> As far as I can see, block_status() can't yield. Why did you add the
> coroutine_fn marker here, but not e.g. for seek_to_sector() or
> cluster_remainder(), which are only called by block_status() and
> therefore also always only in coroutine context?
>

Indeed, that's a wrong annotation I added

> I believe the right way to stay consistent is to leave all of them
> unmarked because there is no fundamental reason why they would only make
> sense in coroutine context.
>
> > diff --git a/block/qcow2.c b/block/qcow2.c
> > index 19271b10a49..161626fa3cb 100644
> > --- a/block/qcow2.c
> > +++ b/block/qcow2.c
> > @@ -1287,9 +1287,10 @@ fail:
> >  }
> >
> >  /* s_locked specifies whether s->lock is held or not */
> > -static void qcow2_update_options_commit(BlockDriverState *bs,
> > -                                        Qcow2ReopenState *r,
> > -                                        bool s_locked)
> > +static void coroutine_fn
> > +qcow2_update_options_commit(BlockDriverState *bs,
> > +                            Qcow2ReopenState *r,
> > +                            bool s_locked)
> >  {
> >      BDRVQcow2State *s = bs->opaque;
> >      int i;
> > @@ -2126,7 +2127,8 @@ fail:
> >      return ret;
> >  }
> >
> > -static void qcow2_reopen_commit(BDRVReopenState *state)
> > +static void coroutine_fn
> > +qcow2_reopen_commit(BDRVReopenState *state)
> >  {
> >      BDRVQcow2State *s = state->bs->opaque;
> >
>
> This doesn't match the declaration of the .bdrv_reopen_commit callback
> in BlockDriver, and as far as I can see, the callers are actually
> guaranteed to _not_ be in coroutine context.
>
> If this is true, qcow2_update_options_commit() should probably be marked
> coroutine_mixed_fn and this one stay unannotated or no_coroutine_fn.

it calls qcow2_update_options_commit(), which itself calls coroutine
cache_clean_timer_co_locked_del_and_wait(bs).

But since s_locked is false, the function is safe it call in non-coroutine.

Given that there are 2 callers, I suggest we move the coroutine call
outside and drop the annotation.


>
> The other parts of the patch looks correct.
>
> Kevin
>
>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.