linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Keith Busch <kbusch@meta.com>
Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, snitzer@kernel.org,
	axboe@kernel.dk, dw@davidwei.uk, brauner@kernel.org,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCHv2 2/7] block: align the bio after building it
Date: Sun, 10 Aug 2025 07:43:46 -0700	[thread overview]
Message-ID: <aJiwIgotNmmJvtjP@infradead.org> (raw)
In-Reply-To: <20250805141123.332298-3-kbusch@meta.com>

On Tue, Aug 05, 2025 at 07:11:18AM -0700, Keith Busch wrote:
> +static inline void bio_revert(struct bio *bio, unsigned int nbytes)

Can you add a little comment explaining what this code does?  The name
suggast it is similar to iov_iter_revert, but I'm not sure how similar
it is intended to be.  The direct poking into bi_io_vec suggest it
can only be used by the I/O submitter, and the use of bio_release_page
suggests it is closely tied to to bio_iov_iter_get_pages despite the
very generic name.

> +static int bio_align_to_lbs(struct bio *bio, struct iov_iter *iter)
> +{
> +	struct block_device *bdev = bio->bi_bdev;
> +	size_t nbytes;
> +
> +	if (!bdev)
> +		return 0;

So this is something horribly Kent put in where he failed to deal with
review feedback and just fed his stuff to Linus, and I think we need
to fix it when touching this code again.  Assuming we want to support
bio_iov_iter_get_pages on bios without bi_bdev set we simplify can't
rely in looking at bdev_logical_block_size here, but instead need to
pass it explicitly.  Which honestly doesn't sound to bad, just add an
explicit argument for the required alignment to bio_iov_iter_get_pages
instead of trying to derive it.  Which is actually going to be useful
to reduce duplicate checks for file systems the require > LBA size
alignment as well.

> -	return bio->bi_vcnt ? 0 : ret;
> +	if (bio->bi_vcnt)
> +		return bio_align_to_lbs(bio, iter);
> +	return ret;

Nit, this would flow a little more easily by moving the error /
exceptional case into the branch, i.e.

	if (!bio->bi_vcnt)
		return ret;
	return bio_align_to_lbs(bio, iter);

  parent reply	other threads:[~2025-08-10 14:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05 14:11 [PATCHv2 0/7] direct-io: even more flexible io vectors Keith Busch
2025-08-05 14:11 ` [PATCHv2 1/7] block: check for valid bio while splitting Keith Busch
2025-08-10 14:37   ` Christoph Hellwig
2025-08-10 15:39     ` Keith Busch
2025-08-10 17:14       ` Christoph Hellwig
2025-08-13 20:06   ` Keith Busch
2025-08-13 20:41     ` Bart Van Assche
2025-08-13 21:01       ` Keith Busch
2025-08-13 23:17         ` Bart Van Assche
2025-08-14  1:42         ` Damien Le Moal
2025-08-13 21:23     ` Martin K. Petersen
2025-08-13 21:52       ` Keith Busch
2025-08-18  4:49         ` Christoph Hellwig
2025-08-05 14:11 ` [PATCHv2 2/7] block: align the bio after building it Keith Busch
2025-08-06  6:07   ` Hannes Reinecke
2025-08-10 14:43   ` Christoph Hellwig [this message]
2025-08-05 14:11 ` [PATCHv2 3/7] block: simplify direct io validity check Keith Busch
2025-08-05 14:11 ` [PATCHv2 4/7] iomap: " Keith Busch
2025-08-06  6:07   ` Hannes Reinecke
2025-08-05 14:11 ` [PATCHv2 5/7] block: remove bdev_iter_is_aligned Keith Busch
2025-08-05 14:11 ` [PATCHv2 6/7] blk-integrity: use simpler alignment check Keith Busch
2025-08-05 14:11 ` [PATCHv2 7/7] iov_iter: remove iov_iter_is_aligned Keith Busch
2025-08-06  6:08   ` Hannes Reinecke
2025-08-06  3:03 ` [PATCHv2 0/7] direct-io: even more flexible io vectors Martin K. Petersen
2025-08-06 14:51 ` Christoph Hellwig
2025-08-07 23:20   ` Keith Busch
2025-08-11 10:32     ` Christoph Hellwig

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=aJiwIgotNmmJvtjP@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=dw@davidwei.uk \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@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 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).