Merge tag 'efi-core-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / mm / page_io.c
index 9e36256..4ca28aa 100644 (file)
@@ -40,7 +40,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags,
                bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
                bio->bi_end_io = end_io;
 
-               bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0);
+               bio_add_page(bio, page, thp_size(page), 0);
        }
        return bio;
 }
@@ -85,7 +85,7 @@ static void swap_slot_free_notify(struct page *page)
                return;
 
        sis = page_swap_info(page);
-       if (!(sis->flags & SWP_BLKDEV))
+       if (data_race(!(sis->flags & SWP_BLKDEV)))
                return;
 
        /*
@@ -252,6 +252,16 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
                unlock_page(page);
                goto out;
        }
+       /*
+        * Arch code may have to preserve more data than just the page
+        * contents, e.g. memory tags.
+        */
+       ret = arch_prepare_to_swap(page);
+       if (ret) {
+               set_page_dirty(page);
+               unlock_page(page);
+               goto out;
+       }
        if (frontswap_store(page) == 0) {
                set_page_writeback(page);
                unlock_page(page);
@@ -274,7 +284,7 @@ static inline void count_swpout_vm_event(struct page *page)
        if (unlikely(PageTransHuge(page)))
                count_vm_event(THP_SWPOUT);
 #endif
-       count_vm_events(PSWPOUT, hpage_nr_pages(page));
+       count_vm_events(PSWPOUT, thp_nr_pages(page));
 }
 
 #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
@@ -302,7 +312,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
        struct swap_info_struct *sis = page_swap_info(page);
 
        VM_BUG_ON_PAGE(!PageSwapCache(page), page);
-       if (sis->flags & SWP_FS) {
+       if (data_race(sis->flags & SWP_FS)) {
                struct kiocb kiocb;
                struct file *swap_file = sis->swap_file;
                struct address_space *mapping = swap_file->f_mapping;
@@ -393,7 +403,7 @@ int swap_readpage(struct page *page, bool synchronous)
                goto out;
        }
 
-       if (sis->flags & SWP_FS) {
+       if (data_race(sis->flags & SWP_FS)) {
                struct file *swap_file = sis->swap_file;
                struct address_space *mapping = swap_file->f_mapping;
 
@@ -455,7 +465,7 @@ int swap_set_page_dirty(struct page *page)
 {
        struct swap_info_struct *sis = page_swap_info(page);
 
-       if (sis->flags & SWP_FS) {
+       if (data_race(sis->flags & SWP_FS)) {
                struct address_space *mapping = sis->swap_file->f_mapping;
 
                VM_BUG_ON_PAGE(!PageSwapCache(page), page);