On Thu, May 19, 2022 at 08:08:50AM -0600, Keith Busch wrote: > > > size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); > > > + if (size > 0) > > > + size = ALIGN_DOWN(size, queue_logical_block_size(q)); > > > > So if we do get a size that is not logical block size alignment here, > > we reduce it to the block size aligned one below. Why do we do that? > > There are two possibilities: > > In the first case, the number of pages in this iteration exceeds bi_max_vecs. > Rounding down completes the bio with a block aligned size, and the remainder > will be picked up for the next bio, or possibly even the current bio if the > pages are sufficiently physically contiguous. > > The other case is a bad iov. If we're doing __blkdev_direct_IO(), it will error > out immediately if the rounded size is 0, or the next iteration when the next > size is rounded to 0. If we're doing the __blkdev_direct_IO_simple(), it will > error out when it sees the iov hasn't advanced to the end. Can you please document this with a comment in the code?