On Tue, Aug 19, 2025 at 09:49:17AM -0700, Keith Busch wrote: > +/* > + * Aligns the bio size to the len_align_mask, releasing any excessive bio vecs > + * that __bio_iov_iter_get_pages may have inserted and reverts that length for > + * the next iteration. > + */ > +static int bio_align(struct bio *bio, struct iov_iter *iter, > + unsigned len_align_mask) I think the name is a bit too generic, as the function is very specific to the __bio_iov_iter_get_pages-path only releasing of pages, and also only aligns down. Maybe name it bio_iov_iter_align_down or something like that? > + size_t nbytes = bio->bi_iter.bi_size & len_align_mask; > + > + if (!nbytes) > + return 0; > + > + iov_iter_revert(iter, nbytes); > + bio->bi_iter.bi_size -= nbytes; > + while (nbytes) { > + struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; > + > + if (nbytes < bv->bv_len) { > + bv->bv_len -= nbytes; > + nbytes = 0; > + } else { > + bio_release_page(bio, bv->bv_page); > + bio->bi_vcnt--; > + nbytes -= bv->bv_len; > + } > + } Minor nitpicks on the loop: it could be turned into a do { } while () loop, because nbytes is already checked above. And the condition that sets nbytes to 0 could just break out of the loo. > + > + if (!bio->bi_iter.bi_size) > + return -EFAULT; And as bi_size doesn't change in the loop, this should probably move above the loop.