On Sun, Mar 24, 2024 at 09:37:02PM +0800, Ming Lei wrote: > +static bool bio_check_alignment(struct bio *bio, struct request_queue *q) > +{ > + unsigned int bs = q->limits.logical_block_size; > + > + if (bio->bi_iter.bi_size & (bs - 1)) > + return false; > + > + if (bio->bi_iter.bi_sector & ((bs >> SECTOR_SHIFT) - 1)) > + return false; > + > + return true; > +} This should still use bdev_logic_block_size. And maybe it's just me, but I think dropping thelines after the false returns would actually make it more readle. > diff --git a/block/fops.c b/block/fops.c > index 679d9b752fe8..75595c728190 100644 > --- a/block/fops.c > +++ b/block/fops.c > @@ -37,8 +37,7 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb) > static bool blkdev_dio_unaligned(struct block_device *bdev, loff_t pos, > struct iov_iter *iter) > { > - return pos & (bdev_logical_block_size(bdev) - 1) || > - !bdev_iter_is_aligned(bdev, iter); > + return !bdev_iter_is_aligned(bdev, iter); If you drop this: - we now actually go all the way down to building and submiting a bio for a trivial bounds check. - your get a trivial to trigger WARN_ON. I'd strongly advise against dropping this check.