Re: [PATCH v6 02/30] mm: Add set/end/wait functions for PG_private_2

From: David Howells
Date: Thu Apr 08 2021 - 11:57:48 EST


Here's a partial change, but we still need to deal with the assumption that
page_has_private() makes that its output can be used to count the number of
refs held for PG_private *and* PG_private_2 - which isn't true for my code
here.

David
---
commit e7c28d83b84b972c3faa0dd86020548aa50eda75
Author: David Howells <dhowells@xxxxxxxxxx>
Date: Thu Apr 8 16:33:20 2021 +0100

netfs: Fix PG_private_2 helper functions to consistently use compound_head()

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index ef511364cc0c..63ca6430aef5 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -699,6 +699,7 @@ void page_endio(struct page *page, bool is_write, int err);
*/
static inline void set_page_private_2(struct page *page)
{
+ page = compound_head(page);
get_page(page);
SetPagePrivate2(page);
}
diff --git a/mm/filemap.c b/mm/filemap.c
index 0ce93c8799ca..46e0321ba87a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1461,6 +1461,7 @@ EXPORT_SYMBOL(end_page_private_2);
*/
void wait_on_page_private_2(struct page *page)
{
+ page = compound_head(page);
while (PagePrivate2(page))
wait_on_page_bit(page, PG_private_2);
}
@@ -1481,6 +1482,7 @@ int wait_on_page_private_2_killable(struct page *page)
{
int ret = 0;

+ page = compound_head(page);
while (PagePrivate2(page)) {
ret = wait_on_page_bit_killable(page, PG_private_2);
if (ret < 0)