All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>
Cc: Carlos Maiolino <cem@kernel.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	linux-block@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/5] block: factor out a bio_await helper
Date: Tue, 7 Apr 2026 07:59:57 -0700	[thread overview]
Message-ID: <dbbd5553-1442-4a90-88cd-59348f81cbb7@acm.org> (raw)
In-Reply-To: <20260407140538.633364-4-hch@lst.de>

On 4/7/26 7:05 AM, Christoph Hellwig wrote:
>   /**
> - * submit_bio_wait - submit a bio, and wait until it completes
> - * @bio: The &struct bio which describes the I/O
> + * bio_await - call a function on a bio, and wait until it completes
> + * @bio:	the bio which describes the I/O
> + * @submit:	function called to submit the bio
> + * @priv:	private data passed to @submit
>    *
> - * Simple wrapper around submit_bio(). Returns 0 on success, or the error from
> - * bio_endio() on failure.
> + * Wait for the bio as well as any bio chained off it after executing the
> + * passed in callback @submit.  The wait for the bio is set up before calling
> + * @submit to ensure that the completion is captured.  If @submit is %NULL,
> + * submit_bio() is used instead to submit the bio.
>    *
> - * WARNING: Unlike to how submit_bio() is usually used, this function does not
> - * result in bio reference to be consumed. The caller must drop the reference
> - * on his own.
> + * Note: this overrides the bi_private and bi_end_io fields in the bio.
>    */
> -int submit_bio_wait(struct bio *bio)
> +void bio_await(struct bio *bio, void *priv,
> +	       void (*submit)(struct bio *bio, void *priv))
>   {
>   	DECLARE_COMPLETION_ONSTACK_MAP(done,
>   			bio->bi_bdev->bd_disk->lockdep_map);
> @@ -1486,13 +1489,37 @@ int submit_bio_wait(struct bio *bio)
>   	bio->bi_private = &done;
>   	bio->bi_end_io = bio_wait_end_io;
>   	bio->bi_opf |= REQ_SYNC;
> -	submit_bio(bio);
> +	if (submit)
> +		submit(bio, priv);
> +	else
> +		submit_bio(bio);
>   	blk_wait_io(&done);
> +}
> +EXPORT_SYMBOL_GPL(bio_await);

[ ... ]

>   void bio_await_chain(struct bio *bio)
>   {
> -	DECLARE_COMPLETION_ONSTACK_MAP(done,
> -			bio->bi_bdev->bd_disk->lockdep_map);
> -
> -	bio->bi_private = &done;
> -	bio->bi_end_io = bio_wait_end_io;
> -	bio_endio(bio);
> -	blk_wait_io(&done);
> +	bio_await(bio, NULL, bio_endio_cb);
>   	bio_put(bio);
>   }
The comment above bio_await() says that the callback function passed as 
third argument submits the bio. The above code passes bio_end_cb as the
"submit" argument. bio_end_cb() does something else than submitting a
bio. How about renaming the "submit" argument of bio_await() into
something else, e.g. "cb" or "callback" to make its role more clear?

Thanks,

Bart.

  reply	other threads:[~2026-04-07 15:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 14:05 refactor submit_bio_wait and bio await helpers v3 Christoph Hellwig
2026-04-07 14:05 ` [PATCH 1/5] xfs: fix number of GC bvecs Christoph Hellwig
2026-04-07 14:05 ` [PATCH 2/5] block: unify the synchronous bi_end_io callbacks Christoph Hellwig
2026-04-08  7:56   ` Chaitanya Kulkarni
2026-04-07 14:05 ` [PATCH 3/5] block: factor out a bio_await helper Christoph Hellwig
2026-04-07 14:59   ` Bart Van Assche [this message]
2026-04-08  5:11     ` Christoph Hellwig
2026-04-07 14:05 ` [PATCH 4/5] block: add a bio_submit_or_kill helper Christoph Hellwig
2026-04-07 15:04   ` Bart Van Assche
2026-04-07 18:37   ` Bart Van Assche
2026-04-08  5:16     ` Christoph Hellwig
2026-04-14  8:24     ` Christoph Hellwig
2026-04-07 14:05 ` [PATCH 5/5] xfs: use bio_await in xfs_zone_gc_reset_sync Christoph Hellwig
2026-04-08  7:57   ` Chaitanya Kulkarni
2026-04-07 14:22 ` refactor submit_bio_wait and bio await helpers v3 Jens Axboe

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=dbbd5553-1442-4a90-88cd-59348f81cbb7@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=cem@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /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 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.