Skip to content

Commit

Permalink
mm: use SWP_SYNCHRONOUS_IO more intelligently
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Sep 24, 2020
1 parent a8b456d commit 5115db1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mm/page_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5115db1

Please sign in to comment.