Update to 3.4-final.
[linux-flexiantxendom0-3.2.10.git] / mm / page_io.c
index 5245453..651a912 100644 (file)
 
 #include <linux/mm.h>
 #include <linux/kernel_stat.h>
+#include <linux/gfp.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/bio.h>
 #include <linux/swapops.h>
-#include <linux/buffer_head.h>
 #include <linux/writeback.h>
+#include <linux/frontswap.h>
 #include <asm/pgtable.h>
 
 static struct bio *get_swap_bio(gfp_t gfp_flags,
@@ -93,30 +94,17 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
 {
        struct bio *bio;
        int ret = 0, rw = WRITE;
-       struct swap_info_struct *sis = page_swap_info(page);
 
        if (try_to_free_swap(page)) {
                unlock_page(page);
                goto out;
        }
-
-       if (sis->flags & SWP_FILE) {
-               struct file *swap_file = sis->swap_file;
-               struct address_space *mapping = swap_file->f_mapping;
-
-               ret = mapping->a_ops->swap_out(swap_file, page, wbc);
-               if (!ret)
-                       count_vm_event(PSWPOUT);
-               return ret;
-       }
-
-       if (preswap_put(page) == 1) {
+       if (frontswap_put_page(page) == 0) {
                set_page_writeback(page);
                unlock_page(page);
                end_page_writeback(page);
                goto out;
        }
-
        bio = get_swap_bio(GFP_NOIO, page, end_swap_bio_write);
        if (bio == NULL) {
                set_page_dirty(page);
@@ -125,7 +113,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
                goto out;
        }
        if (wbc->sync_mode == WB_SYNC_ALL)
-               rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
+               rw |= REQ_SYNC;
        count_vm_event(PSWPOUT);
        set_page_writeback(page);
        unlock_page(page);
@@ -134,63 +122,18 @@ out:
        return ret;
 }
 
-/* this comment ensure the patch applies to swap_sync_page
- * and not swap_set_page_dirty by mistake
- */
-void swap_sync_page(struct page *page)
-{
-       struct swap_info_struct *sis = page_swap_info(page);
-
-       if (!sis)
-               return;
-       if (sis->flags & SWP_FILE) {
-               struct address_space *mapping = sis->swap_file->f_mapping;
-
-               if (mapping->a_ops->sync_page)
-                       mapping->a_ops->sync_page(page);
-       } else {
-               block_sync_page(page);
-       }
-}
-
-int swap_set_page_dirty(struct page *page)
-{
-       struct swap_info_struct *sis = page_swap_info(page);
-
-       if (sis->flags & SWP_FILE) {
-               struct address_space *mapping = sis->swap_file->f_mapping;
-
-               return mapping->a_ops->set_page_dirty(page);
-       } else {
-               return __set_page_dirty_nobuffers(page);
-       }
-}
-
 int swap_readpage(struct page *page)
 {
        struct bio *bio;
        int ret = 0;
-       struct swap_info_struct *sis = page_swap_info(page);
 
        VM_BUG_ON(!PageLocked(page));
        VM_BUG_ON(PageUptodate(page));
-
-       if (sis->flags & SWP_FILE) {
-               struct file *swap_file = sis->swap_file;
-               struct address_space *mapping = swap_file->f_mapping;
-
-               ret = mapping->a_ops->swap_in(swap_file, page);
-               if (!ret)
-                       count_vm_event(PSWPIN);
-               return ret;
-       }
-
-       if (preswap_get(page) == 1) {
+       if (frontswap_get_page(page) == 0) {
                SetPageUptodate(page);
                unlock_page(page);
                goto out;
        }
-
        bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read);
        if (bio == NULL) {
                unlock_page(page);