aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r--drivers/md/bcache/io.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index b4c0e28a7cd1..5304eaab6cbe 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -158,8 +158,10 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
158{ 158{
159 unsigned ret = bio_sectors(bio); 159 unsigned ret = bio_sectors(bio);
160 struct request_queue *q = bdev_get_queue(bio->bi_bdev); 160 struct request_queue *q = bdev_get_queue(bio->bi_bdev);
161 unsigned max_segments = min_t(unsigned, BIO_MAX_PAGES,
162 queue_max_segments(q));
161 struct bio_vec *bv, *end = bio_iovec(bio) + 163 struct bio_vec *bv, *end = bio_iovec(bio) +
162 min_t(int, bio_segments(bio), queue_max_segments(q)); 164 min_t(int, bio_segments(bio), max_segments);
163 165
164 struct bvec_merge_data bvm = { 166 struct bvec_merge_data bvm = {
165 .bi_bdev = bio->bi_bdev, 167 .bi_bdev = bio->bi_bdev,
@@ -171,7 +173,7 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
171 if (bio->bi_rw & REQ_DISCARD) 173 if (bio->bi_rw & REQ_DISCARD)
172 return min(ret, q->limits.max_discard_sectors); 174 return min(ret, q->limits.max_discard_sectors);
173 175
174 if (bio_segments(bio) > queue_max_segments(q) || 176 if (bio_segments(bio) > max_segments ||
175 q->merge_bvec_fn) { 177 q->merge_bvec_fn) {
176 ret = 0; 178 ret = 0;
177 179
@@ -183,9 +185,6 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
183 ret += bv->bv_len >> 9; 185 ret += bv->bv_len >> 9;
184 bvm.bi_size += bv->bv_len; 186 bvm.bi_size += bv->bv_len;
185 } 187 }
186
187 if (ret >= (BIO_MAX_PAGES * PAGE_SIZE) >> 9)
188 return (BIO_MAX_PAGES * PAGE_SIZE) >> 9;
189 } 188 }
190 189
191 ret = min(ret, queue_max_sectors(q)); 190 ret = min(ret, queue_max_sectors(q));