[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251028225648.GA1639650@google.com>
Date: Tue, 28 Oct 2025 22:56:48 +0000
From: Eric Biggers <ebiggers@...nel.org>
To: Carlos Llamas <cmllamas@...gle.com>
Cc: Keith Busch <kbusch@...nel.org>, Keith Busch <kbusch@...a.com>,
linux-block@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-xfs@...r.kernel.org, linux-ext4@...r.kernel.org, hch@....de,
axboe@...nel.dk, Hannes Reinecke <hare@...e.de>,
"Martin K. Petersen" <martin.petersen@...cle.com>
Subject: Re: [PATCHv4 5/8] iomap: simplify direct io validity check
On Tue, Oct 28, 2025 at 10:47:53PM +0000, Carlos Llamas wrote:
> Ok, I did a bit more digging. I'm using f2fs but the problem in this
> case is the blk_crypto layer. The OP_READ request goes through
> submit_bio() which then calls blk_crypto_bio_prep() and if the bio has
> crypto context then it checks for bio_crypt_check_alignment().
>
> This is where the LTP tests fails the alignment. However, the propagated
> error goes through "bio->bi_status = BLK_STS_IOERR" which in bio_endio()
> get translates to EIO due to blk_status_to_errno().
>
> I've verified this restores the original behavior matching the LTP test,
> so I'll write up a patch and send it a bit later.
>
> diff --git a/block/blk-crypto.c b/block/blk-crypto.c
> index 1336cbf5e3bd..a417843e7e4a 100644
> --- a/block/blk-crypto.c
> +++ b/block/blk-crypto.c
> @@ -293,7 +293,7 @@ bool __blk_crypto_bio_prep(struct bio **bio_ptr)
> }
>
> if (!bio_crypt_check_alignment(bio)) {
> - bio->bi_status = BLK_STS_IOERR;
> + bio->bi_status = BLK_STS_INVAL;
> goto fail;
> }
That change looks fine, but I'm wondering how this case was reached in
the first place. Upper layers aren't supposed to be submitting
misaligned bios like this. For example, ext4 and f2fs require
filesystem logical block size alignment for direct I/O on encrypted
files. They check for this early, before getting to the point of
submitting a bio, and fall back to buffered I/O if needed.
- Eric
Powered by blists - more mailing lists