Thread (24 messages) 24 messages, 6 authors, 2025-11-04

Re: [PATCHv4 5/8] iomap: simplify direct io validity check

From: Eric Biggers <ebiggers@kernel.org>
Date: 2025-10-28 22:56:51
Also in: linux-block, linux-fsdevel, linux-xfs

On Tue, Oct 28, 2025 at 10:47:53PM +0000, Carlos Llamas wrote:
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help