summaryrefslogtreecommitdiff
path: root/mm/page_io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-09-24 09:51:37 +0300
committerJens Axboe <axboe@kernel.dk>2020-09-24 22:43:39 +0300
commit5115db10a8e0a525edf8a65b2ed4eac5c8253095 (patch)
tree664bad791aaeda55fbd96229a0977943dc36fb5a /mm/page_io.c
parenta8b456d01cd6b37191f14248f3e2bdbe5ce3a89e (diff)
downloadlinux-5115db10a8e0a525edf8a65b2ed4eac5c8253095.tar.xz
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 <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'mm/page_io.c')
-rw-r--r--mm/page_io.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mm/page_io.c b/mm/page_io.c
index e485a6e8a6cd..b199b87e0aa9 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;