On 3/21/24 06:16, Ming Lei wrote:
+static bool bio_check_alignment(struct bio *bio, struct request_queue *q) +{ + unsigned int bs = q->limits.logical_block_size; + unsigned int size = bio->bi_iter.bi_size; + + if (size & (bs - 1)) + return false; + + if (size && ((bio->bi_iter.bi_sector << SECTOR_SHIFT) & (bs - 1))) + return false;
Why "size &&"? It doesn't harm to reject unaligned bios if size == 0 and it will reduce the number of if-tests in the hot path. Why to shift bio->bi_iter.bi_sector left instead of shifting (bs - 1) right? Thanks, Bart.