summaryrefslogtreecommitdiff
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2022-02-13 06:48:55 +0300
committerMatthew Wilcox (Oracle) <willy@infradead.org>2022-03-21 19:59:01 +0300
commit5100da38ef3c33d9ad8b60b29c2b671249bf7e1d (patch)
treeeef4a39c6e56852c4cba81fe237adabb6e70213d /mm/vmscan.c
parente41c81d0d30e1a6ebf408feaf561f80cac4457dc (diff)
downloadlinux-5100da38ef3c33d9ad8b60b29c2b671249bf7e1d.tar.xz
mm: Convert remove_mapping() to take a folio
Add kernel-doc and return the number of pages removed in order to get the statistics right in __invalidate_mapping_pages(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index e49f5fb40a83..5a018aa5ab7c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1335,23 +1335,28 @@ cannot_free:
return 0;
}
-/*
- * Attempt to detach a locked page from its ->mapping. If it is dirty or if
- * someone else has a ref on the page, abort and return 0. If it was
- * successfully detached, return 1. Assumes the caller has a single ref on
- * this page.
+/**
+ * remove_mapping() - Attempt to remove a folio from its mapping.
+ * @mapping: The address space.
+ * @folio: The folio to remove.
+ *
+ * If the folio is dirty, under writeback or if someone else has a ref
+ * on it, removal will fail.
+ * Return: The number of pages removed from the mapping. 0 if the folio
+ * could not be removed.
+ * Context: The caller should have a single refcount on the folio and
+ * hold its lock.
*/
-int remove_mapping(struct address_space *mapping, struct page *page)
+long remove_mapping(struct address_space *mapping, struct folio *folio)
{
- struct folio *folio = page_folio(page);
if (__remove_mapping(mapping, folio, false, NULL)) {
/*
- * Unfreezing the refcount with 1 rather than 2 effectively
+ * Unfreezing the refcount with 1 effectively
* drops the pagecache ref for us without requiring another
* atomic operation.
*/
folio_ref_unfreeze(folio, 1);
- return 1;
+ return folio_nr_pages(folio);
}
return 0;
}