]> www.infradead.org Git - users/hch/block.git/commitdiff
mm: use SWP_SYNCHRONOUS_IO more intelligently
authorChristoph Hellwig <hch@lst.de>
Sat, 20 Jun 2020 09:37:11 +0000 (11:37 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 24 Sep 2020 06:29:19 +0000 (08:29 +0200)
There is no point in trying to call bdev_read_page if SWP_SYNCHRONOUS_IO
is not set, as the device won't support it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
mm/page_io.c

index e485a6e8a6cddb22c6e71b1280a1b35cc1b725aa..b199b87e0aa92b0e683241725fd8098e618a5da9 100644 (file)
@@ -403,15 +403,17 @@ int swap_readpage(struct page *page, bool synchronous)
                goto out;
        }
 
-       ret = bdev_read_page(sis->bdev, swap_page_sector(page), page);
-       if (!ret) {
-               if (trylock_page(page)) {
-                       swap_slot_free_notify(page);
-                       unlock_page(page);
-               }
+       if (sis->flags & SWP_SYNCHRONOUS_IO) {
+               ret = bdev_read_page(sis->bdev, swap_page_sector(page), page);
+               if (!ret) {
+                       if (trylock_page(page)) {
+                               swap_slot_free_notify(page);
+                               unlock_page(page);
+                       }
 
-               count_vm_event(PSWPIN);
-               goto out;
+                       count_vm_event(PSWPIN);
+                       goto out;
+               }
        }
 
        ret = 0;