]> git.karo-electronics.de Git - linux-beck.git/commitdiff
bcache: Correctly check against BIO_MAX_PAGES
authorKent Overstreet <koverstreet@google.com>
Wed, 10 Apr 2013 22:50:57 +0000 (15:50 -0700)
committerKent Overstreet <koverstreet@google.com>
Sun, 21 Apr 2013 00:57:42 +0000 (17:57 -0700)
bch_bio_max_sectors() was checking against BIO_MAX_PAGES as if the limit
was for the total bytes in the bio, not the number of segments.

Signed-off-by: Kent Overstreet <koverstreet@google.com>
drivers/md/bcache/io.c

index b4c0e28a7cd16d65f31184143dba49aaf22d55d2..5304eaab6cbe0417f980e74fca24b2a8f2b28737 100644 (file)
@@ -158,8 +158,10 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
 {
        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,
@@ -171,7 +173,7 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
        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;
 
@@ -183,9 +185,6 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
                        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));