Commit 5115db10 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a8b456d0
...@@ -403,15 +403,17 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -403,15 +403,17 @@ int swap_readpage(struct page *page, bool synchronous)
goto out; goto out;
} }
ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); if (sis->flags & SWP_SYNCHRONOUS_IO) {
if (!ret) { ret = bdev_read_page(sis->bdev, swap_page_sector(page), page);
if (trylock_page(page)) { if (!ret) {
swap_slot_free_notify(page); if (trylock_page(page)) {
unlock_page(page); swap_slot_free_notify(page);
} unlock_page(page);
}
count_vm_event(PSWPIN); count_vm_event(PSWPIN);
goto out; goto out;
}
} }
ret = 0; ret = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment