diff options
-rw-r--r-- | block/bio.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c index 29cd6cf4da51..299a0e7651ec 100644 --- a/block/bio.c +++ b/block/bio.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
17 | #include <linux/cgroup.h> | 17 | #include <linux/cgroup.h> |
18 | #include <linux/blk-cgroup.h> | 18 | #include <linux/blk-cgroup.h> |
19 | #include <linux/highmem.h> | ||
19 | 20 | ||
20 | #include <trace/events/block.h> | 21 | #include <trace/events/block.h> |
21 | #include "blk.h" | 22 | #include "blk.h" |
@@ -1441,8 +1442,22 @@ void bio_unmap_user(struct bio *bio) | |||
1441 | bio_put(bio); | 1442 | bio_put(bio); |
1442 | } | 1443 | } |
1443 | 1444 | ||
1445 | static void bio_invalidate_vmalloc_pages(struct bio *bio) | ||
1446 | { | ||
1447 | #ifdef ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE | ||
1448 | if (bio->bi_private && !op_is_write(bio_op(bio))) { | ||
1449 | unsigned long i, len = 0; | ||
1450 | |||
1451 | for (i = 0; i < bio->bi_vcnt; i++) | ||
1452 | len += bio->bi_io_vec[i].bv_len; | ||
1453 | invalidate_kernel_vmap_range(bio->bi_private, len); | ||
1454 | } | ||
1455 | #endif | ||
1456 | } | ||
1457 | |||
1444 | static void bio_map_kern_endio(struct bio *bio) | 1458 | static void bio_map_kern_endio(struct bio *bio) |
1445 | { | 1459 | { |
1460 | bio_invalidate_vmalloc_pages(bio); | ||
1446 | bio_put(bio); | 1461 | bio_put(bio); |
1447 | } | 1462 | } |
1448 | 1463 | ||
@@ -1463,6 +1478,8 @@ struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, | |||
1463 | unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; | 1478 | unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; |
1464 | unsigned long start = kaddr >> PAGE_SHIFT; | 1479 | unsigned long start = kaddr >> PAGE_SHIFT; |
1465 | const int nr_pages = end - start; | 1480 | const int nr_pages = end - start; |
1481 | bool is_vmalloc = is_vmalloc_addr(data); | ||
1482 | struct page *page; | ||
1466 | int offset, i; | 1483 | int offset, i; |
1467 | struct bio *bio; | 1484 | struct bio *bio; |
1468 | 1485 | ||
@@ -1470,6 +1487,11 @@ struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, | |||
1470 | if (!bio) | 1487 | if (!bio) |
1471 | return ERR_PTR(-ENOMEM); | 1488 | return ERR_PTR(-ENOMEM); |
1472 | 1489 | ||
1490 | if (is_vmalloc) { | ||
1491 | flush_kernel_vmap_range(data, len); | ||
1492 | bio->bi_private = data; | ||
1493 | } | ||
1494 | |||
1473 | offset = offset_in_page(kaddr); | 1495 | offset = offset_in_page(kaddr); |
1474 | for (i = 0; i < nr_pages; i++) { | 1496 | for (i = 0; i < nr_pages; i++) { |
1475 | unsigned int bytes = PAGE_SIZE - offset; | 1497 | unsigned int bytes = PAGE_SIZE - offset; |
@@ -1480,7 +1502,11 @@ struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, | |||
1480 | if (bytes > len) | 1502 | if (bytes > len) |
1481 | bytes = len; | 1503 | bytes = len; |
1482 | 1504 | ||
1483 | if (bio_add_pc_page(q, bio, virt_to_page(data), bytes, | 1505 | if (!is_vmalloc) |
1506 | page = virt_to_page(data); | ||
1507 | else | ||
1508 | page = vmalloc_to_page(data); | ||
1509 | if (bio_add_pc_page(q, bio, page, bytes, | ||
1484 | offset) < bytes) { | 1510 | offset) < bytes) { |
1485 | /* we don't support partial mappings */ | 1511 | /* we don't support partial mappings */ |
1486 | bio_put(bio); | 1512 | bio_put(bio); |