[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/6] block: add blk_io_plug_call() API
On Wed, May 17, 2023 at 06:10:17PM -0400, Stefan Hajnoczi wrote: > Introduce a new API for thread-local blk_io_plug() that does not > traverse the block graph. The goal is to make blk_io_plug() multi-queue > friendly. > > Instead of having block drivers track whether or not we're in a plugged > section, provide an API that allows them to defer a function call until > we're unplugged: blk_io_plug_call(fn, opaque). If blk_io_plug_call() is > called multiple times with the same fn/opaque pair, then fn() is only > called once at the end of the function - resulting in batching. > > This patch introduces the API and changes blk_io_plug()/blk_io_unplug(). > blk_io_plug()/blk_io_unplug() no longer require a BlockBackend argument > because the plug state is now thread-local. > > Later patches convert block drivers to blk_io_plug_call() and then we > can finally remove .bdrv_co_io_plug() once all block drivers have been > converted. > > Signed-off-by: Stefan Hajnoczi <stefanha@xxxxxxxxxx> > --- > +++ b/block/plug.c > + > +/** > + * blk_io_plug_call: > + * @fn: a function pointer to be invoked > + * @opaque: a user-defined argument to @fn() > + * > + * Call @fn(@opaque) immediately if not within a > blk_io_plug()/blk_io_unplug() > + * section. > + * > + * Otherwise defer the call until the end of the outermost > + * blk_io_plug()/blk_io_unplug() section in this thread. If the same > + * @fn/@opaque pair has already been deferred, it will only be called once > upon > + * blk_io_unplug() so that accumulated calls are batched into a single call. > + * > + * The caller must ensure that @opaque is not be freed before @fn() is > invoked. s/be // > + */ > +void blk_io_plug_call(void (*fn)(void *), void *opaque) Reviewed-by: Eric Blake <eblake@xxxxxxxxxx> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |