Update to 3.4-final.
[linux-flexiantxendom0-3.2.10.git] / mm / bounce.c
index 06722c4..d1be02c 100644 (file)
@@ -4,8 +4,9 @@
  */
 
 #include <linux/mm.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/swap.h>
+#include <linux/gfp.h>
 #include <linux/bio.h>
 #include <linux/pagemap.h>
 #include <linux/mempool.h>
 #include <linux/init.h>
 #include <linux/hash.h>
 #include <linux/highmem.h>
-#include <linux/blktrace_api.h>
+#include <linux/bootmem.h>
 #include <asm/tlbflush.h>
 
+#include <trace/events/block.h>
+
 #define POOL_SIZE      64
 #define ISA_POOL_SIZE  16
 
@@ -24,12 +27,10 @@ static mempool_t *page_pool, *isa_page_pool;
 #ifdef CONFIG_HIGHMEM
 static __init int init_emergency_pool(void)
 {
-       struct sysinfo i;
-       si_meminfo(&i);
-       si_swapinfo(&i);
-
-       if (!i.totalhigh)
+#ifndef CONFIG_MEMORY_HOTPLUG
+       if (max_pfn <= max_low_pfn)
                return 0;
+#endif
 
        page_pool = mempool_create_page_pool(POOL_SIZE, 0);
        BUG_ON(!page_pool);
@@ -49,9 +50,9 @@ static void bounce_copy_vec(struct bio_vec *to, unsigned char *vfrom)
        unsigned char *vto;
 
        local_irq_save(flags);
-       vto = kmap_atomic(to->bv_page, KM_BOUNCE_READ);
+       vto = kmap_atomic(to->bv_page);
        memcpy(vto + to->bv_offset, vfrom, to->bv_len);
-       kunmap_atomic(vto, KM_BOUNCE_READ);
+       kunmap_atomic(vto);
        local_irq_restore(flags);
 }
 
@@ -114,8 +115,8 @@ static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
                 */
                vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
 
-               flush_dcache_page(tovec->bv_page);
                bounce_copy_vec(tovec, vfrom);
+               flush_dcache_page(tovec->bv_page);
        }
 }
 
@@ -189,14 +190,19 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
                /*
                 * is destination page below bounce pfn?
                 */
-               if (page_to_pfn(page) <= q->bounce_pfn)
+               if (page_to_pfn(page) <= queue_bounce_pfn(q))
                        continue;
 
                /*
                 * irk, bounce it
                 */
-               if (!bio)
-                       bio = bio_alloc(GFP_NOIO, (*bio_orig)->bi_vcnt);
+               if (!bio) {
+                       unsigned int cnt = (*bio_orig)->bi_vcnt;
+
+                       bio = bio_alloc(GFP_NOIO, cnt);
+                       memset(bio->bi_io_vec, 0, cnt * sizeof(struct bio_vec));
+               }
+                       
 
                to = bio->bi_io_vec + i;
 
@@ -222,7 +228,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
        if (!bio)
                return;
 
-       blk_add_trace_bio(q, *bio_orig, BLK_TA_BOUNCE);
+       trace_block_bio_bounce(q, *bio_orig);
 
        /*
         * at least one page was bounced, fill in possible non-highmem
@@ -276,7 +282,7 @@ void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
         * don't waste time iterating over bio segments
         */
        if (!(q->bounce_gfp & GFP_DMA)) {
-               if (q->bounce_pfn >= blk_max_pfn)
+               if (queue_bounce_pfn(q) >= blk_max_pfn)
                        return;
                pool = page_pool;
        } else {