mm: zram: use rw_page for zram page but submit_bio for zram wb page

Since reading zram wb page is an async operation, we can not immediately
free the slot here. So we need to read the page via submit_bio and free
the slot in end_swap_bio_read. (bio chain will be used to handle bio here
and bio in zram driver for wb page).

Change-Id: I71b88c4a2388c086bd7e0cd63b8c632b93217a95
Signed-off-by: huangzq2 <huangzq2@motorola.com>
Reviewed-on: https://gerrit.mot.com/1933720
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1952123
Reviewed-by: Yonghui Jia <jiayh2@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
This commit is contained in:
huangzq2 2021-04-27 18:08:04 +08:00 • committed by Xiaojun Ji
commit 632683b8f1

View file

@ -84,7 +84,7 @@ bool swap_slot_has_sync_io(swp_entry_t entry)
SWP_SYNCHRONOUS_IO, swp_offset(entry)) == 1;
}
return false;
return (sis->flags & SWP_SYNCHRONOUS_IO) == SWP_SYNCHRONOUS_IO;
}
static void swap_slot_free_notify(struct page *page)
@ -368,6 +368,7 @@ int swap_readpage(struct page *page, bool synchronous)
blk_qc_t qc;
struct gendisk *disk;
unsigned long pflags;
swp_entry_t entry;
VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page);
VM_BUG_ON_PAGE(!PageLocked(page), page);
@ -396,15 +397,24 @@ 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);
}
/* Moto huangzq2: Use rw_page for zram page but submit_bio for zram wb page.
* Since reading zram wb page is an async operation, we can not immediately
* free the slot here. So we need to read the page via submit_bio and free
* the slot in end_swap_bio_read. (bio chain will be used to handle bio here
* and bio in zram driver for wb page).
*/
entry.val = page_private(page);
if (swap_slot_has_sync_io(entry)) {
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;