When CONFIG_FAIL_MAKE_REQUEST is not enabled, gcc may optimize out calls to should_fail_bio() because the content of should_fail_bio() is empty returning always 0. The gcc compiler then detects the function call to should_fail_bio() being empty and optimizes out the call to it. This prevents block I/O error injection programs attached to it from working. The compiler is not aware of the side effect of calling this probe function. This issue is seen with gcc compiler version 14. Previous versions of gcc compiler (checked 9, 11, 12, 13) don't have this optimization. Clang compiler (seen with version 18.1.18) has the same issue of optimizing out calls to should_fail_bio(). Adding asm("") statement to should_fail_bio() function as suggested in the GCC documentation for "noinline" attribute fixes the problem. This works for both gcc and clang kernel builds. Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Prasad Singamsetty <prasad.singamsetty@xxxxxxxxxx> --- v2: Instead of adding noipa attribute, use the preferred method of adding asm("") statement to should_fail_bio() to create the side effect. block/blk-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/blk-core.c b/block/blk-core.c index e8cc270a453f..d777f0a30c5e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -543,6 +543,7 @@ static noinline int should_fail_bio(struct bio *bio) { if (should_fail_request(bdev_whole(bio->bi_bdev), bio->bi_iter.bi_size)) return -EIO; + asm(""); /* prevent calls to the function optimized out */ return 0; } ALLOW_ERROR_INJECTION(should_fail_bio, ERRNO); base-commit: 1a1d569a75f3ab2923cb62daf356d102e4df2b86 -- 2.43.5