From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "Fam Zheng" <fam@euphon.net>,
qemu-devel@nongnu.org, "Denis V. Lunev" <den@openvz.org>,
"Eric Blake" <eblake@redhat.com>,
qemu-block@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Greg Kurz" <groug@kaod.org>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"John Snow" <jsnow@redhat.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Hanna Reitz" <hreitz@redhat.com>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v6 02/33] include/block/block: split header into I/O and global state API
Date: Mon, 31 Jan 2022 14:40:40 +0100 [thread overview]
Message-ID: <ac8b0576-4c03-4eb6-9ef6-c0a6b20b6184@redhat.com> (raw)
In-Reply-To: <YfJ7pbLDuwP2hgnw@redhat.com>
On 27/01/2022 12:01, Kevin Wolf wrote:
>> +/* Common functions that are neither I/O nor Global State */
>> +
>> +int bdrv_parse_aio(const char *mode, int *flags);
> Makes sense to me to have this here, it is just a helper function that
> parses stuff and doesn't touch any state. However, what is different
> about the following?
>
> int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough);
> int bdrv_parse_discard_flags(const char *mode, int *flags);
>
> Despite being simple helpers, you kept them as global state.
>
I guess those two are only called by GS functions, while tihs one is
not. Anyways, you are right, I will move them to block-common.h
[...]
>>> +/* disk I/O throttling */
>> Let's remove this comment (maybe in a separate preparational patch), it
>> doesn't make any sense at all any more. It was added in commit
>> 0563e191516 to describe bdrv_io_limits_enable()/disable(), which were
>> removed in commit 97148076, but apparently I forgot to remove the
>> comment.
>>
Done, sent as a separate patch "block.h: remove outdated comment"
[...]
>>> +void bdrv_init_with_whitelist(void);
>>> +bool bdrv_uses_whitelist(void);
>>> +int bdrv_is_whitelisted(BlockDriver *drv, bool read_only);
>> The whitelist is static and doesn't touch runtime state.
Ok I am moving all the three above in block-common.h
[...]
>>> +/* async block I/O */
>>> +void bdrv_aio_cancel(BlockAIOCB *acb);
>>> +void bdrv_invalidate_cache_all(Error **errp);
>>> +
>>> +int bdrv_inactivate_all(void);
>> The grouping is odd here. The comment refers only to bdrv_aio_cancel(),
>> while bdrv_invalidate_cache_all()/bdrv_inactivate_all() are a logically
>> related function pair.
>>
>> Also odd: Why keep bdrv_aio_cancel() as global state, but make
>> bdrv_aio_cancel_async() an I/O function? (The latter is required, of
>> course, because virtio-scsi can call it in I/O threads.)
>>
>> bdrv_aio_cancel() calls aio_poll(). I think this means that it actually
>> must run in the AioContext that is polled, which may or may not be the
>> main thread. Before this series, we assert running in the main thread
>> only in one if branch.
ok moving the comment + bdrv_aio_cancel in block-io.h
[...]
>>> + BlockDriverState *bs_ = (bs); \
>>> + AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \
>>> + cond); })
>> Hmm... AIO_WAIT_WHILE() is explicitly documented to be called from I/O
>> threads. But it has to be a specific I/O thread, the home thread of the
>> AioContext of bs.
>>
>> So it really fits neither the description for global state (it works
>> outside the main thread) nor for I/O functions (it doesn't work in any
>> arbitrary thread).
So I would say BDRV_POLL_WHILE can go in block-common? what you wrote
above is the exact definition of common functions.
[...]
>>> +
>>> +/**
>>> + * bdrv_drained_begin:
>>> + *
>>> + * Begin a quiesced section for exclusive access to the BDS, by disabling
>>> + * external request sources including NBD server, block jobs, and device model.
>>> + *
>>> + * This function can be recursive.
>>> + */
>>> +void bdrv_drained_begin(BlockDriverState *bs);
>> I don't see how the whole family of drain functions can work in any
>> arbitrary thread. They call BDRV_POLL_WHILE(), the rules for which are
>> that it has to be either in the main thread or in the AioContext of bs
>> (which currently ensures that all block nodes and their users are in the
>> same AioContext).
>>
>> Cross-AioContext BDRV_POLL_WHILE() can cause deadlocks, as documented in
>> AIO_WAIT_WHILE().
>>
>> Actually, the same is true for all other BDRV_POLL_WHILE() callers, too.
>> For example, every function generated by block-coroutine-wrapper.py can
>> only be thread-safe when called in coroutine context, otherwise it has
>> to be called from the node's AioContext.
>>
Maybe not in any arbitrary thread, but an iothread can call these
function in any case. Therefore it is not a GS function for sure, so I
would leave it as I/O.
I guess you can also see I/O more as "all the ones that are not GS".
Rest of comments that I did not answer: I agree.
Emanuele
next prev parent reply other threads:[~2022-01-31 14:19 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 17:05 [PATCH v6 00/33] block layer: split block APIs in global state and I/O Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 01/33] main-loop.h: introduce qemu_in_main_thread() Emanuele Giuseppe Esposito
2022-01-27 10:56 ` Kevin Wolf
2022-01-31 11:25 ` Emanuele Giuseppe Esposito
2022-01-31 14:33 ` Kevin Wolf
2022-01-31 15:49 ` Paolo Bonzini
2022-02-01 9:08 ` Emanuele Giuseppe Esposito
2022-02-01 10:41 ` Paolo Bonzini
2022-02-01 11:55 ` Kevin Wolf
2022-02-01 12:10 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 02/33] include/block/block: split header into I/O and global state API Emanuele Giuseppe Esposito
2022-01-27 11:01 ` Kevin Wolf
2022-01-31 13:40 ` Emanuele Giuseppe Esposito [this message]
2022-01-31 14:54 ` Kevin Wolf
2022-01-31 15:58 ` Paolo Bonzini
2022-02-01 9:45 ` Emanuele Giuseppe Esposito
2022-02-01 10:30 ` Paolo Bonzini
2022-02-07 16:53 ` Kevin Wolf
2022-02-08 10:50 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 03/33] assertions for block " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 04/33] block/export/fuse.c: allow writable exports to take RESIZE permission Emanuele Giuseppe Esposito
2022-01-25 16:51 ` Hanna Reitz
2022-01-28 14:44 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 05/33] include/sysemu/block-backend: split header into I/O and global state (GS) API Emanuele Giuseppe Esposito
2022-02-07 17:04 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 06/33] block/block-backend.c: assertions for block-backend Emanuele Giuseppe Esposito
2022-01-26 9:02 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 07/33] include/block/block_int: split header into I/O and global state API Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 08/33] assertions for block_int " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 09/33] block: introduce assert_bdrv_graph_writable Emanuele Giuseppe Esposito
2022-02-07 17:14 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 10/33] include/block/blockjob_int.h: split header into I/O and GS API Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 11/33] assertions for blockjob_int.h Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 12/33] block.c: add assertions to static functions Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 13/33] include/block/blockjob.h: global state API Emanuele Giuseppe Esposito
2022-02-07 17:26 ` Kevin Wolf
2022-02-08 10:50 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 14/33] assertions for blockjob.h " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 15/33] include/sysemu/blockdev.h: " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 16/33] assertions for blockdev.h " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 17/33] include/block/snapshot: global state API + assertions Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 18/33] block/copy-before-write.h: " Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 19/33] block: introduce bdrv_activate Emanuele Giuseppe Esposito
2022-01-26 11:49 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 20/33] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache Emanuele Giuseppe Esposito
2022-01-24 10:44 ` Juan Quintela
2022-01-27 9:18 ` Emanuele Giuseppe Esposito
2022-01-31 15:59 ` Paolo Bonzini
2022-01-26 11:57 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 21/33] block: move BQL logic of bdrv_co_invalidate_cache in bdrv_activate Emanuele Giuseppe Esposito
2022-01-26 12:20 ` Hanna Reitz
2022-01-27 11:03 ` Kevin Wolf
2022-02-02 17:27 ` Paolo Bonzini
2022-02-02 18:27 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 22/33] block/coroutines: I/O API Emanuele Giuseppe Esposito
2022-02-07 17:36 ` Kevin Wolf
2022-01-21 17:05 ` [PATCH v6 23/33] block_int-common.h: split function pointers in BlockDriver Emanuele Giuseppe Esposito
2022-01-26 12:29 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 24/33] block_int-common.h: assertions in the callers of BlockDriver function pointers Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 25/33] block_int-common.h: split function pointers in BdrvChildClass Emanuele Giuseppe Esposito
2022-01-26 12:42 ` Hanna Reitz
2022-01-28 15:08 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 26/33] block_int-common.h: assertions in the callers of BdrvChildClass function pointers Emanuele Giuseppe Esposito
2022-01-26 12:46 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 27/33] block-backend-common.h: split function pointers in BlockDevOps Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 28/33] job.h: split function pointers in JobDriver Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 29/33] job.h: assertions in the callers of JobDriver funcion pointers Emanuele Giuseppe Esposito
2022-01-26 14:13 ` Hanna Reitz
2022-01-28 15:19 ` Emanuele Giuseppe Esposito
2022-01-31 8:49 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 30/33] include/block/block_int-common.h: introduce bdrv_amend_pre_run and bdrv_amend_clean Emanuele Giuseppe Esposito
2022-01-26 14:54 ` Hanna Reitz
2022-01-21 17:05 ` [PATCH v6 31/33] include/qemu/job.h: introduce job->pre_run() and use it in amend Emanuele Giuseppe Esposito
2022-01-26 15:57 ` Hanna Reitz
2022-02-07 18:14 ` Kevin Wolf
2022-02-08 11:05 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 32/33] crypto: delegate permission functions to JobDriver .pre_run Emanuele Giuseppe Esposito
2022-01-24 14:41 ` Paolo Bonzini
2022-01-26 16:10 ` Hanna Reitz
2022-01-28 16:57 ` Emanuele Giuseppe Esposito
2022-01-21 17:05 ` [PATCH v6 33/33] block.c: assertions to the block layer permissions API Emanuele Giuseppe Esposito
2022-02-07 18:30 ` [PATCH v6 00/33] block layer: split block APIs in global state and I/O Kevin Wolf
2022-02-08 11:42 ` Emanuele Giuseppe Esposito
2022-02-08 13:08 ` Kevin Wolf
2022-02-10 16:19 ` Emanuele Giuseppe Esposito
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=ac8b0576-4c03-4eb6-9ef6-c0a6b20b6184@redhat.com \
--to=eesposit@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=den@openvz.org \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=f4bug@amsat.org \
--cc=fam@euphon.net \
--cc=groug@kaod.org \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.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).