On Sun, Mar 24, 2024 at 04:25:04PM -0700, Christoph Hellwig wrote: > 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. OK, will remove the blank line. > > > 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. OK. Also only q->limits.logical_block_size is fetched for small BS IO fast path, I think log(lbs) can be cached in request_queue for avoiding the extra fetch of q.limits. Especially, it could be easier to do so with your recent queue limit atomic update changes. Thanks, Ming