mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
mm: break up swap_writepage() for frontswap backends
swap_writepage() is currently where frontswap hooks into the swap write path to capture pages with the frontswap_store() function. However, if a frontswap backend wants to "resume" the writeback of a page to the swap device, it can't call swap_writepage() as the page will simply reenter the backend. This patch separates swap_writepage() into a top and bottom half, the bottom half named __swap_writepage() to allow a frontswap backend, like zswap, to resume writeback beyond the frontswap_store() hook. __add_to_swap_cache() is also made non-static so that the page for which writeback is to be resumed can be added to the swap cache. Signed-off-by: Seth Jennings <[email protected]> Signed-off-by: Bob Liu <[email protected]> Acked-by: Minchan Kim <[email protected]> Reviewed-by: Dan Magenheimer <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
e8420a8ece
commit
2f772e6cad
3 changed files with 14 additions and 4 deletions
14
mm/page_io.c
14
mm/page_io.c
|
|
@ -185,9 +185,7 @@ bad_bmap:
|
|||
*/
|
||||
int swap_writepage(struct page *page, struct writeback_control *wbc)
|
||||
{
|
||||
struct bio *bio;
|
||||
int ret = 0, rw = WRITE;
|
||||
struct swap_info_struct *sis = page_swap_info(page);
|
||||
int ret = 0;
|
||||
|
||||
if (try_to_free_swap(page)) {
|
||||
unlock_page(page);
|
||||
|
|
@ -199,6 +197,16 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
|
|||
end_page_writeback(page);
|
||||
goto out;
|
||||
}
|
||||
ret = __swap_writepage(page, wbc);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __swap_writepage(struct page *page, struct writeback_control *wbc)
|
||||
{
|
||||
struct bio *bio;
|
||||
int ret = 0, rw = WRITE;
|
||||
struct swap_info_struct *sis = page_swap_info(page);
|
||||
|
||||
if (sis->flags & SWP_FILE) {
|
||||
struct kiocb kiocb;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ void show_swap_cache_info(void)
|
|||
* __add_to_swap_cache resembles add_to_page_cache_locked on swapper_space,
|
||||
* but sets SwapCache flag and private instead of mapping and index.
|
||||
*/
|
||||
static int __add_to_swap_cache(struct page *page, swp_entry_t entry)
|
||||
int __add_to_swap_cache(struct page *page, swp_entry_t entry)
|
||||
{
|
||||
int error;
|
||||
struct address_space *address_space;
|
||||
|
|
|
|||
Loading…
Reference in a new issue