On Thu, Mar 21, 2024 at 08:14:24AM -0700, Bart Van Assche wrote: > 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. It doesn't make sense to check the alignment for bio without data. > > Why to shift bio->bi_iter.bi_sector left instead of shifting (bs - 1) > right? unit of bs is bytes, so .bi_sector needs to be converted to byte first. Thanks, Ming