Merge tag 'block-5.15-2021-09-05' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / block / bounce.c
index 7e9e666..05fc714 100644 (file)
@@ -239,24 +239,19 @@ void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
         * because the 'bio' is single-page bvec.
         */
        for (i = 0, to = bio->bi_io_vec; i < bio->bi_vcnt; to++, i++) {
-               struct page *page = to->bv_page;
+               struct page *bounce_page;
 
-               if (!PageHighMem(page))
+               if (!PageHighMem(to->bv_page))
                        continue;
 
-               to->bv_page = mempool_alloc(&page_pool, GFP_NOIO);
-               inc_zone_page_state(to->bv_page, NR_BOUNCE);
+               bounce_page = mempool_alloc(&page_pool, GFP_NOIO);
+               inc_zone_page_state(bounce_page, NR_BOUNCE);
 
                if (rw == WRITE) {
-                       char *vto, *vfrom;
-
-                       flush_dcache_page(page);
-
-                       vto = page_address(to->bv_page) + to->bv_offset;
-                       vfrom = kmap_atomic(page) + to->bv_offset;
-                       memcpy(vto, vfrom, to->bv_len);
-                       kunmap_atomic(vfrom);
+                       flush_dcache_page(to->bv_page);
+                       memcpy_from_bvec(page_address(bounce_page), to);
                }
+               to->bv_page = bounce_page;
        }
 
        trace_block_bio_bounce(*bio_orig);