From: Christoph Hellwig Date: Thu, 24 Sep 2020 06:51:37 +0000 (+0200) Subject: mm: use SWP_SYNCHRONOUS_IO more intelligently X-Git-Tag: v5.10-rc1~168^2~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5115db10a8e0a525edf8a65b2ed4eac5c8253095;p=thirdparty%2Fkernel%2Fstable.git mm: use SWP_SYNCHRONOUS_IO more intelligently 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 Reviewed-by: Jan Kara Reviewed-by: Johannes Thumshirn Signed-off-by: Jens Axboe --- diff --git a/mm/page_io.c b/mm/page_io.c index e485a6e8a6cdd..b199b87e0aa92 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -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;