swap: convert swap_writepage() to use a folio

Removes many calls to compound_head().

Link: https://lkml.kernel.org/r/20220902194653.1739778-41-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2022-09-02 20:46:36 +01:00 committed by Andrew Morton
parent aedd74d439
commit 71fa1a533d

View File

@ -180,29 +180,30 @@ bad_bmap:
*/ */
int swap_writepage(struct page *page, struct writeback_control *wbc) int swap_writepage(struct page *page, struct writeback_control *wbc)
{ {
struct folio *folio = page_folio(page);
int ret = 0; int ret = 0;
if (try_to_free_swap(page)) { if (folio_free_swap(folio)) {
unlock_page(page); folio_unlock(folio);
goto out; goto out;
} }
/* /*
* Arch code may have to preserve more data than just the page * Arch code may have to preserve more data than just the page
* contents, e.g. memory tags. * contents, e.g. memory tags.
*/ */
ret = arch_prepare_to_swap(page); ret = arch_prepare_to_swap(&folio->page);
if (ret) { if (ret) {
set_page_dirty(page); folio_mark_dirty(folio);
unlock_page(page); folio_unlock(folio);
goto out; goto out;
} }
if (frontswap_store(page) == 0) { if (frontswap_store(&folio->page) == 0) {
set_page_writeback(page); folio_start_writeback(folio);
unlock_page(page); folio_unlock(folio);
end_page_writeback(page); folio_end_writeback(folio);
goto out; goto out;
} }
ret = __swap_writepage(page, wbc); ret = __swap_writepage(&folio->page, wbc);
out: out:
return ret; return ret;
} }