aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page_io.c')
-rw-r--r--mm/page_io.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/mm/page_io.c b/mm/page_io.c
index c6f3e5071de3..afeed89a0a5d 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -19,20 +19,17 @@
19#include <linux/writeback.h> 19#include <linux/writeback.h>
20#include <asm/pgtable.h> 20#include <asm/pgtable.h>
21 21
22static struct bio *get_swap_bio(gfp_t gfp_flags, pgoff_t index, 22static struct bio *get_swap_bio(gfp_t gfp_flags,
23 struct page *page, bio_end_io_t end_io) 23 struct page *page, bio_end_io_t end_io)
24{ 24{
25 struct bio *bio; 25 struct bio *bio;
26 26
27 bio = bio_alloc(gfp_flags, 1); 27 bio = bio_alloc(gfp_flags, 1);
28 if (bio) { 28 if (bio) {
29 struct swap_info_struct *sis; 29 swp_entry_t entry;
30 swp_entry_t entry = { .val = index, }; 30 entry.val = page_private(page);
31 31 bio->bi_sector = map_swap_page(entry, &bio->bi_bdev);
32 sis = get_swap_info_struct(swp_type(entry)); 32 bio->bi_sector <<= PAGE_SHIFT - 9;
33 bio->bi_sector = map_swap_page(sis, swp_offset(entry)) *
34 (PAGE_SIZE >> 9);
35 bio->bi_bdev = sis->bdev;
36 bio->bi_io_vec[0].bv_page = page; 33 bio->bi_io_vec[0].bv_page = page;
37 bio->bi_io_vec[0].bv_len = PAGE_SIZE; 34 bio->bi_io_vec[0].bv_len = PAGE_SIZE;
38 bio->bi_io_vec[0].bv_offset = 0; 35 bio->bi_io_vec[0].bv_offset = 0;
@@ -102,8 +99,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
102 unlock_page(page); 99 unlock_page(page);
103 goto out; 100 goto out;
104 } 101 }
105 bio = get_swap_bio(GFP_NOIO, page_private(page), page, 102 bio = get_swap_bio(GFP_NOIO, page, end_swap_bio_write);
106 end_swap_bio_write);
107 if (bio == NULL) { 103 if (bio == NULL) {
108 set_page_dirty(page); 104 set_page_dirty(page);
109 unlock_page(page); 105 unlock_page(page);
@@ -127,8 +123,7 @@ int swap_readpage(struct page *page)
127 123
128 VM_BUG_ON(!PageLocked(page)); 124 VM_BUG_ON(!PageLocked(page));
129 VM_BUG_ON(PageUptodate(page)); 125 VM_BUG_ON(PageUptodate(page));
130 bio = get_swap_bio(GFP_KERNEL, page_private(page), page, 126 bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read);
131 end_swap_bio_read);
132 if (bio == NULL) { 127 if (bio == NULL) {
133 unlock_page(page); 128 unlock_page(page);
134 ret = -ENOMEM; 129 ret = -ENOMEM;