{
unsigned ret = bio_sectors(bio);
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
+ unsigned max_segments = min_t(unsigned, BIO_MAX_PAGES,
+ queue_max_segments(q));
struct bio_vec *bv, *end = bio_iovec(bio) +
- min_t(int, bio_segments(bio), queue_max_segments(q));
+ min_t(int, bio_segments(bio), max_segments);
struct bvec_merge_data bvm = {
.bi_bdev = bio->bi_bdev,
if (bio->bi_rw & REQ_DISCARD)
return min(ret, q->limits.max_discard_sectors);
- if (bio_segments(bio) > queue_max_segments(q) ||
+ if (bio_segments(bio) > max_segments ||
q->merge_bvec_fn) {
ret = 0;
ret += bv->bv_len >> 9;
bvm.bi_size += bv->bv_len;
}
-
- if (ret >= (BIO_MAX_PAGES * PAGE_SIZE) >> 9)
- return (BIO_MAX_PAGES * PAGE_SIZE) >> 9;
}
ret = min(ret, queue_max_sectors(q));