Merge tag 'mips-fixes_5.12_2' of git://git.kernel.org/pub/scm/linux/kernel/git/mips...
[linux-2.6-microblaze.git] / block / bounce.c
index fc55314..6c441f4 100644 (file)
@@ -214,8 +214,7 @@ static void bounce_end_io_read_isa(struct bio *bio)
        __bounce_end_io_read(bio, &isa_page_pool);
 }
 
-static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
-               struct bio_set *bs)
+static struct bio *bounce_clone_bio(struct bio *bio_src)
 {
        struct bvec_iter iter;
        struct bio_vec bv;
@@ -230,10 +229,10 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
         *  - The point of cloning the biovec is to produce a bio with a biovec
         *    the caller can modify: bi_idx and bi_bvec_done should be 0.
         *
-        *  - The original bio could've had more than BIO_MAX_PAGES biovecs; if
+        *  - The original bio could've had more than BIO_MAX_VECS biovecs; if
         *    we tried to clone the whole thing bio_alloc_bioset() would fail.
         *    But the clone should succeed as long as the number of biovecs we
-        *    actually need to allocate is fewer than BIO_MAX_PAGES.
+        *    actually need to allocate is fewer than BIO_MAX_VECS.
         *
         *  - Lastly, bi_vcnt should not be looked at or relied upon by code
         *    that does not own the bio - reason being drivers don't use it for
@@ -242,10 +241,12 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
         *    asking for trouble and would force extra work on
         *    __bio_clone_fast() anyways.
         */
-
-       bio = bio_alloc_bioset(gfp_mask, bio_segments(bio_src), bs);
-       if (!bio)
-               return NULL;
+       if (bio_is_passthrough(bio_src))
+               bio = bio_kmalloc(GFP_NOIO | __GFP_NOFAIL,
+                                 bio_segments(bio_src));
+       else
+               bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src),
+                                      &bounce_bio_set);
        bio->bi_bdev            = bio_src->bi_bdev;
        if (bio_flagged(bio_src, BIO_REMAPPED))
                bio_set_flag(bio, BIO_REMAPPED);
@@ -269,11 +270,11 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
                break;
        }
 
-       if (bio_crypt_clone(bio, bio_src, gfp_mask) < 0)
+       if (bio_crypt_clone(bio, bio_src, GFP_NOIO) < 0)
                goto err_put;
 
        if (bio_integrity(bio_src) &&
-           bio_integrity_clone(bio, bio_src, gfp_mask) < 0)
+           bio_integrity_clone(bio, bio_src, GFP_NOIO) < 0)
                goto err_put;
 
        bio_clone_blkg_association(bio, bio_src);
@@ -296,10 +297,9 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
        unsigned i = 0;
        bool bounce = false;
        int sectors = 0;
-       bool passthrough = bio_is_passthrough(*bio_orig);
 
        bio_for_each_segment(from, *bio_orig, iter) {
-               if (i++ < BIO_MAX_PAGES)
+               if (i++ < BIO_MAX_VECS)
                        sectors += from.bv_len >> 9;
                if (page_to_pfn(from.bv_page) > q->limits.bounce_pfn)
                        bounce = true;
@@ -307,14 +307,14 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
        if (!bounce)
                return;
 
-       if (!passthrough && sectors < bio_sectors(*bio_orig)) {
+       if (!bio_is_passthrough(*bio_orig) &&
+           sectors < bio_sectors(*bio_orig)) {
                bio = bio_split(*bio_orig, sectors, GFP_NOIO, &bounce_bio_split);
                bio_chain(bio, *bio_orig);
                submit_bio_noacct(*bio_orig);
                *bio_orig = bio;
        }
-       bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL :
-                       &bounce_bio_set);
+       bio = bounce_clone_bio(*bio_orig);
 
        /*
         * Bvec table can't be updated by bio_for_each_segment_all(),