On Mon, May 23, 2022 at 02:01:19PM -0700, Keith Busch wrote: > Removed iomap support for now Do you plan to add a separate patch for it? It would be a shame to miss it especially as you said you already tested xfs. > + struct request_queue *q = bdev_get_queue(bio->bi_bdev); > struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; > struct page **pages = (struct page **)bv; > ssize_t size, left; > @@ -1219,7 +1220,19 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) > BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2); > pages += entries_left * (PAGE_PTRS_PER_BVEC - 1); > > + /* > + * Each segment in the iov is required to be a block size multiple. > + * However, we may not be able to get the entire segment if it spans > + * more pages than bi_max_vecs allows, so we have to ALIGN_DOWN the > + * result to ensure the bio's total size is correct. The remainder of > + * the iov data will be picked up in the next bio iteration. > + * > + * If the result is ever 0, that indicates the iov fails the segment > + * size requirement and is an error. > + */ > size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); > + if (size > 0) > + size = ALIGN_DOWN(size, queue_logical_block_size(q)); I think we can simply use bdev_logical_block_size here and remove the need for the q local variable. Given that bio_iov_iter_get_pages is used by more than the block device direct I/O code maybe split this up further? > @@ -42,6 +42,16 @@ static unsigned int dio_bio_write_op(struct kiocb *iocb) > return op; > } > > +static int blkdev_dio_aligned(struct block_device *bdev, loff_t pos, > + struct iov_iter *iter) > +{ > + if ((pos | iov_iter_count(iter)) & (bdev_logical_block_size(bdev) - 1)) > + return -EINVAL; > + if (iov_iter_alignment(iter) & bdev_dma_alignment(bdev)) > + return -EINVAL; > + return 0; > +} I'd also split adding this helper into another prep patch to see the actual change in behavior more easily.