> +/* > + * Figure out max_size hint of iov_iter_extract_pages() for minimizing > + * bio & iov iter revert so that bio can be aligned with max io size. > + */ > +static unsigned int bio_get_buffer_size_hint(const struct bio *bio, > + unsigned int left) > +{ > + unsigned int nr_bvecs = bio->bi_max_vecs - bio->bi_vcnt; > + unsigned int size, predicted_space, max_bytes; > + unsigned int space = nr_bvecs << PAGE_SHIFT; > + unsigned int align_deviation; > + > + /* If we have enough space really, just try to get all pages */ > + if (!bio->bi_bdev || nr_bvecs >= (bio->bi_max_vecs / 4) || > + !bio->bi_vcnt || left <= space) We need to either decided if the bdev is mandatory and we can rely on it, or stop adding conditionals based on it. NAK for anything adding more if bio->bi_bdev in this path. But more important I'm not sure why we need all this extra code to start with. If you just did an extra for more space than we want to submit, just release the pages that we grabbed but don't want to add instead of adding them to be bio_vec. Remember this is an absolute fast path for high IOPS I/O, we should avoid adding cruft to it.