]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: skip unnecessary checks for split bio
authorYu Kuai <yukuai3@huawei.com>
Wed, 10 Sep 2025 06:30:54 +0000 (14:30 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Sep 2025 11:23:46 +0000 (05:23 -0600)
Lots of checks are already done while submitting this bio the first
time, and there is no need to check them again when this bio is
resubmitted after split.

Hence open code should_fail_bio() and blk_throtl_bio() that are still
necessary from submit_bio_split_bioset().

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-merge.c
block/blk.h

index 83c262a3dfd9cf666e1970f7e486ab896d5f10db..1021a09c59587bc357f6f3a0d9a54d82ac87f546 100644 (file)
@@ -539,7 +539,7 @@ static inline void bio_check_ro(struct bio *bio)
        }
 }
 
-static noinline int should_fail_bio(struct bio *bio)
+int should_fail_bio(struct bio *bio)
 {
        if (should_fail_request(bdev_whole(bio->bi_bdev), bio->bi_iter.bi_size))
                return -EIO;
index f680ccf8186456778ffcb11534ba59d27b3c8a8a..c16f4bdf251ff384df9cf63c57dfeed55377cd9c 100644 (file)
@@ -130,7 +130,11 @@ struct bio *bio_submit_split_bioset(struct bio *bio, unsigned int split_sectors,
        bio_chain(split, bio);
        trace_block_split(split, bio->bi_iter.bi_sector);
        WARN_ON_ONCE(bio_zone_write_plugging(bio));
-       submit_bio_noacct(bio);
+
+       if (should_fail_bio(bio))
+               bio_io_error(bio);
+       else if (!blk_throtl_bio(bio))
+               submit_bio_noacct_nocheck(bio);
 
        return split;
 }
index 41397688b941a2160543316db71bfc6e68298f05..694ae6c9bb0f6588d2ec71c5c8ac564fc4c9ac7e 100644 (file)
@@ -616,6 +616,7 @@ extern const struct address_space_operations def_blk_aops;
 int disk_register_independent_access_ranges(struct gendisk *disk);
 void disk_unregister_independent_access_ranges(struct gendisk *disk);
 
+int should_fail_bio(struct bio *bio);
 #ifdef CONFIG_FAIL_MAKE_REQUEST
 bool should_fail_request(struct block_device *part, unsigned int bytes);
 #else /* CONFIG_FAIL_MAKE_REQUEST */