Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/4] mm, ceph: remove wait_on_page_writeback()
@ 2026-08-02 16:50 Tal Zussman
  2026-08-02 16:50 ` [PATCH 1/4] ceph: add ceph_folio_snap_context() Tal Zussman
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Tal Zussman @ 2026-08-02 16:50 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
	Matthew Wilcox (Oracle), Jan Kara, Andrew Morton,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Zi Yan
  Cc: ceph-devel, linux-kernel, linux-fsdevel, linux-mm, Tal Zussman

wait_on_page_writeback() is a compatibility wrapper for
folio_wait_writeback() and has a single remaining caller in ceph's
writeback path. Convert that caller to use folios and remove the
wrapper.

Along the way, replace ceph's page_snap_context(), which uses
page->private, with a folio-based ceph_folio_snap_context(), dropping
three &folio->page conversions at its call sites.

No functional change intended.

Note: This is currently based on mm-new. It may conflict slightly with
Zi Yan's series "Remove PG_private by using page/folio->private checks
instead" [1], which should allow simplifying ceph_folio_snap_context()
further.

[1] https://lore.kernel.org/linux-mm/20260731-remove-pg_private-v1-0-142c97ba3562@nvidia.com/T/

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
Tal Zussman (4):
      ceph: add ceph_folio_snap_context()
      ceph: convert ceph_wait_until_current_writes_complete() to folios
      mm: remove wait_on_page_writeback()
      ceph: remove page_snap_context()

 fs/ceph/addr.c          | 28 ++++++++++++++--------------
 include/linux/pagemap.h |  1 -
 mm/folio-compat.c       |  6 ------
 3 files changed, 14 insertions(+), 21 deletions(-)
---
base-commit: 1dbd7c34bb92dd9c0b0363b75f6ec444299af108
change-id: 20260802-remove-wait-on-page-writeback-8e0cb766d4c7

Best regards,
-- 
Tal Zussman <tz2294@columbia.edu>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/4] ceph: add ceph_folio_snap_context()
  2026-08-02 16:50 [PATCH 0/4] mm, ceph: remove wait_on_page_writeback() Tal Zussman
@ 2026-08-02 16:50 ` Tal Zussman
  2026-08-02 21:52   ` Matthew Wilcox
  2026-08-02 16:50 ` [PATCH 2/4] ceph: convert ceph_wait_until_current_writes_complete() to folios Tal Zussman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Tal Zussman @ 2026-08-02 16:50 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
	Matthew Wilcox (Oracle), Jan Kara, Andrew Morton,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Zi Yan
  Cc: ceph-devel, linux-kernel, linux-fsdevel, linux-mm, Tal Zussman

Add a folio-based counterpart to page_snap_context() that reads the
snap context from folio->private directly.

Convert the three writeback paths that passed &folio->page to
page_snap_context() to ceph_folio_snap_context(), removing three
open-coded folio-to-page conversions. No functional change.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 fs/ceph/addr.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index ecf33b66610c..a8ed2a14da44 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -75,6 +75,13 @@ static inline struct ceph_snap_context *page_snap_context(struct page *page)
 	return NULL;
 }
 
+static inline struct ceph_snap_context *ceph_folio_snap_context(struct folio *folio)
+{
+	if (folio_test_private(folio))
+		return (void *)folio->private;
+	return NULL;
+}
+
 /*
  * Dirty a page.  Optimistically adjust accounting, on the assumption
  * that we won't race with invalidate.  If we do, readjust.
@@ -745,7 +752,7 @@ static int write_folio_nounlock(struct folio *folio,
 		return -EIO;
 
 	/* verify this is a writeable snap context */
-	snapc = page_snap_context(&folio->page);
+	snapc = ceph_folio_snap_context(folio);
 	if (!snapc) {
 		doutc(cl, "%llx.%llx folio %p not dirty?\n", ceph_vinop(inode),
 		      folio);
@@ -1171,7 +1178,7 @@ int ceph_check_page_before_write(struct address_space *mapping,
 	}
 
 	/* only if matching snap context */
-	pgsnapc = page_snap_context(&folio->page);
+	pgsnapc = ceph_folio_snap_context(folio);
 	if (pgsnapc != ceph_wbc->snapc) {
 		doutc(cl, "folio snapc %p %lld != oldest %p %lld\n",
 		      pgsnapc, pgsnapc->seq,
@@ -1824,7 +1831,7 @@ ceph_find_incompatible(struct folio *folio)
 
 		folio_wait_writeback(folio);
 
-		snapc = page_snap_context(&folio->page);
+		snapc = ceph_folio_snap_context(folio);
 		if (!snapc || snapc == ci->i_head_snapc)
 			break;
 

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/4] ceph: convert ceph_wait_until_current_writes_complete() to folios
  2026-08-02 16:50 [PATCH 0/4] mm, ceph: remove wait_on_page_writeback() Tal Zussman
  2026-08-02 16:50 ` [PATCH 1/4] ceph: add ceph_folio_snap_context() Tal Zussman
@ 2026-08-02 16:50 ` Tal Zussman
  2026-08-02 23:22   ` Matthew Wilcox
  2026-08-02 16:50 ` [PATCH 3/4] mm: remove wait_on_page_writeback() Tal Zussman
  2026-08-02 16:50 ` [PATCH 4/4] ceph: remove page_snap_context() Tal Zussman
  3 siblings, 1 reply; 13+ messages in thread
From: Tal Zussman @ 2026-08-02 16:50 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
	Matthew Wilcox (Oracle), Jan Kara, Andrew Morton,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Zi Yan
  Cc: ceph-devel, linux-kernel, linux-fsdevel, linux-mm, Tal Zussman

Iterate the writeback batch as folios rather than using
&folios[i]->page. Use ceph_folio_snap_context() for the snap context
check and folio_wait_writeback() instead of wait_on_page_writeback().

This removes one call to compound_head() and the last caller of
wait_on_page_writeback(). No functional change.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 fs/ceph/addr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index a8ed2a14da44..f4aaf9a5f196 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1625,7 +1625,7 @@ void ceph_wait_until_current_writes_complete(struct address_space *mapping,
 					     struct writeback_control *wbc,
 					     struct ceph_writeback_ctl *ceph_wbc)
 {
-	struct page *page;
+	struct folio *folio;
 	unsigned i, nr;
 
 	if (wbc->sync_mode != WB_SYNC_NONE &&
@@ -1640,10 +1640,10 @@ void ceph_wait_until_current_writes_complete(struct address_space *mapping,
 						     PAGECACHE_TAG_WRITEBACK,
 						     &ceph_wbc->fbatch))) {
 			for (i = 0; i < nr; i++) {
-				page = &ceph_wbc->fbatch.folios[i]->page;
-				if (page_snap_context(page) != ceph_wbc->snapc)
+				folio = ceph_wbc->fbatch.folios[i];
+				if (ceph_folio_snap_context(folio) != ceph_wbc->snapc)
 					continue;
-				wait_on_page_writeback(page);
+				folio_wait_writeback(folio);
 			}
 
 			folio_batch_release(&ceph_wbc->fbatch);

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/4] mm: remove wait_on_page_writeback()
  2026-08-02 16:50 [PATCH 0/4] mm, ceph: remove wait_on_page_writeback() Tal Zussman
  2026-08-02 16:50 ` [PATCH 1/4] ceph: add ceph_folio_snap_context() Tal Zussman
  2026-08-02 16:50 ` [PATCH 2/4] ceph: convert ceph_wait_until_current_writes_complete() to folios Tal Zussman
@ 2026-08-02 16:50 ` Tal Zussman
  2026-08-02 23:23   ` Matthew Wilcox
  2026-08-03 12:34   ` David Hildenbrand (Arm)
  2026-08-02 16:50 ` [PATCH 4/4] ceph: remove page_snap_context() Tal Zussman
  3 siblings, 2 replies; 13+ messages in thread
From: Tal Zussman @ 2026-08-02 16:50 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
	Matthew Wilcox (Oracle), Jan Kara, Andrew Morton,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Zi Yan
  Cc: ceph-devel, linux-kernel, linux-fsdevel, linux-mm, Tal Zussman

The last caller was converted to folio_wait_writeback(), so drop the
wait_on_page_writeback() compatibility wrapper and its declaration.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 include/linux/pagemap.h | 1 -
 mm/folio-compat.c       | 6 ------
 2 files changed, 7 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 4e8b2b29f6d3..c8666fd14d3d 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1335,7 +1335,6 @@ static inline int folio_wait_locked_killable(struct folio *folio)
 }
 
 void folio_end_read(struct folio *folio, bool success);
-void wait_on_page_writeback(struct page *page);
 void folio_wait_writeback(struct folio *folio);
 int folio_wait_writeback_killable(struct folio *folio);
 void end_page_writeback(struct page *page);
diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index a02179a0bded..ae0271591d37 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -23,12 +23,6 @@ void end_page_writeback(struct page *page)
 }
 EXPORT_SYMBOL(end_page_writeback);
 
-void wait_on_page_writeback(struct page *page)
-{
-	return folio_wait_writeback(page_folio(page));
-}
-EXPORT_SYMBOL_GPL(wait_on_page_writeback);
-
 void mark_page_accessed(struct page *page)
 {
 	folio_mark_accessed(page_folio(page));

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/4] ceph: remove page_snap_context()
  2026-08-02 16:50 [PATCH 0/4] mm, ceph: remove wait_on_page_writeback() Tal Zussman
                   ` (2 preceding siblings ...)
  2026-08-02 16:50 ` [PATCH 3/4] mm: remove wait_on_page_writeback() Tal Zussman
@ 2026-08-02 16:50 ` Tal Zussman
  2026-08-03  2:06   ` Matthew Wilcox
  3 siblings, 1 reply; 13+ messages in thread
From: Tal Zussman @ 2026-08-02 16:50 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
	Matthew Wilcox (Oracle), Jan Kara, Andrew Morton,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Zi Yan
  Cc: ceph-devel, linux-kernel, linux-fsdevel, linux-mm, Tal Zussman

Convert the final caller in get_writepages_data_length() to use a folio
and ceph_folio_snap_context(), then remove page_snap_context().

This drops the last open-coded use of page->private in ceph's writeback
path.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 fs/ceph/addr.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index f4aaf9a5f196..702cf5fc1eab 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -29,9 +29,9 @@
  *
  * There are a few funny things going on here.
  *
- * The page->private field is used to reference a struct
- * ceph_snap_context for _every_ dirty page.  This indicates which
- * snapshot the page was logically dirtied in, and thus which snap
+ * The folio->private field is used to reference a struct
+ * ceph_snap_context for _every_ dirty folio.  This indicates which
+ * snapshot the folio was logically dirtied in, and thus which snap
  * context needs to be associated with the osd write during writeback.
  *
  * Similarly, struct ceph_inode_info maintains a set of counters to
@@ -68,13 +68,6 @@
 static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned int len,
 					struct folio **foliop, void **_fsdata);
 
-static inline struct ceph_snap_context *page_snap_context(struct page *page)
-{
-	if (PagePrivate(page))
-		return (void *)page->private;
-	return NULL;
-}
-
 static inline struct ceph_snap_context *ceph_folio_snap_context(struct folio *folio)
 {
 	if (folio_test_private(folio))
@@ -697,7 +690,7 @@ static u64 get_writepages_data_length(struct inode *inode,
 	u64 end = i_size_read(inode);
 	u64 ret;
 
-	snapc = page_snap_context(ceph_fscrypt_pagecache_page(page));
+	snapc = ceph_folio_snap_context(page_folio(ceph_fscrypt_pagecache_page(page)));
 	if (snapc != ci->i_head_snapc) {
 		bool found = false;
 		spin_lock(&ci->i_ceph_lock);

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/4] ceph: add ceph_folio_snap_context()
  2026-08-02 16:50 ` [PATCH 1/4] ceph: add ceph_folio_snap_context() Tal Zussman
@ 2026-08-02 21:52   ` Matthew Wilcox
  2026-08-02 22:44     ` Zi Yan
  0 siblings, 1 reply; 13+ messages in thread
From: Matthew Wilcox @ 2026-08-02 21:52 UTC (permalink / raw)
  To: Tal Zussman
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Zi Yan, ceph-devel,
	linux-kernel, linux-fsdevel, linux-mm

On Sun, Aug 02, 2026 at 12:50:02PM -0400, Tal Zussman wrote:
> +static inline struct ceph_snap_context *ceph_folio_snap_context(struct folio *folio)
> +{
> +	if (folio_test_private(folio))
> +		return (void *)folio->private;
> +	return NULL;
> +}

Filesystem folios _ought_to have folio->private as NULL when PG_private
is unset and PG_private set when folio->private is non-NULL.  Now, ceph
could be doing something Bad (I believe hugetlbfs does not honour this
for various reasons), but it looks like it's using
folio_attach_private() / folio_detach_private() appropriately.

So I think we should just do:

static inline
struct ceph_snap_context *ceph_folio_snap_context(const struct folio *folio)
{
	return folio->private;
}

(folio->private is already void *, so it doesn't need to be cast).
Splitting the definition where I did puts the unimmportant information
(static inline) on the previous line, so somebody grepping for
ceph_folio_snap_context gets the return type, while not breaking 80
columns.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/4] ceph: add ceph_folio_snap_context()
  2026-08-02 21:52   ` Matthew Wilcox
@ 2026-08-02 22:44     ` Zi Yan
  2026-08-03 10:17       ` Tal Zussman
  0 siblings, 1 reply; 13+ messages in thread
From: Zi Yan @ 2026-08-02 22:44 UTC (permalink / raw)
  To: Matthew Wilcox, Tal Zussman
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, ceph-devel, linux-kernel,
	linux-fsdevel, linux-mm

On Sun Aug 2, 2026 at 5:52 PM EDT, Matthew Wilcox wrote:
> On Sun, Aug 02, 2026 at 12:50:02PM -0400, Tal Zussman wrote:
>> +static inline struct ceph_snap_context *ceph_folio_snap_context(struct folio *folio)
>> +{
>> +	if (folio_test_private(folio))
>> +		return (void *)folio->private;
>> +	return NULL;
>> +}
>
> Filesystem folios _ought_to have folio->private as NULL when PG_private
> is unset and PG_private set when folio->private is non-NULL.  Now, ceph
> could be doing something Bad (I believe hugetlbfs does not honour this
> for various reasons), but it looks like it's using
> folio_attach_private() / folio_detach_private() appropriately.
>
> So I think we should just do:
>
> static inline
> struct ceph_snap_context *ceph_folio_snap_context(const struct folio *folio)
> {
> 	return folio->private;
> }

Yes, please. So I do not need to handle another exceptional user when I
am trying to remove PG_private[1].

[1] https://lore.kernel.org/all/20260731-remove-pg_private-v1-0-142c97ba3562@nvidia.com/
>
> (folio->private is already void *, so it doesn't need to be cast).
> Splitting the definition where I did puts the unimmportant information
> (static inline) on the previous line, so somebody grepping for
> ceph_folio_snap_context gets the return type, while not breaking 80
> columns.




-- 
Best Regards,
Yan, Zi


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] ceph: convert ceph_wait_until_current_writes_complete() to folios
  2026-08-02 16:50 ` [PATCH 2/4] ceph: convert ceph_wait_until_current_writes_complete() to folios Tal Zussman
@ 2026-08-02 23:22   ` Matthew Wilcox
  0 siblings, 0 replies; 13+ messages in thread
From: Matthew Wilcox @ 2026-08-02 23:22 UTC (permalink / raw)
  To: Tal Zussman
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Zi Yan, ceph-devel,
	linux-kernel, linux-fsdevel, linux-mm

On Sun, Aug 02, 2026 at 12:50:03PM -0400, Tal Zussman wrote:
> Iterate the writeback batch as folios rather than using
> &folios[i]->page. Use ceph_folio_snap_context() for the snap context
> check and folio_wait_writeback() instead of wait_on_page_writeback().
> 
> This removes one call to compound_head() and the last caller of
> wait_on_page_writeback(). No functional change.
> 
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>

Beautiful.

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/4] mm: remove wait_on_page_writeback()
  2026-08-02 16:50 ` [PATCH 3/4] mm: remove wait_on_page_writeback() Tal Zussman
@ 2026-08-02 23:23   ` Matthew Wilcox
  2026-08-03 12:34   ` David Hildenbrand (Arm)
  1 sibling, 0 replies; 13+ messages in thread
From: Matthew Wilcox @ 2026-08-02 23:23 UTC (permalink / raw)
  To: Tal Zussman
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Zi Yan, ceph-devel,
	linux-kernel, linux-fsdevel, linux-mm

On Sun, Aug 02, 2026 at 12:50:04PM -0400, Tal Zussman wrote:
> The last caller was converted to folio_wait_writeback(), so drop the
> wait_on_page_writeback() compatibility wrapper and its declaration.
> 
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] ceph: remove page_snap_context()
  2026-08-02 16:50 ` [PATCH 4/4] ceph: remove page_snap_context() Tal Zussman
@ 2026-08-03  2:06   ` Matthew Wilcox
  2026-08-03 11:03     ` Tal Zussman
  0 siblings, 1 reply; 13+ messages in thread
From: Matthew Wilcox @ 2026-08-03  2:06 UTC (permalink / raw)
  To: Tal Zussman
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Zi Yan, ceph-devel,
	linux-kernel, linux-fsdevel, linux-mm

On Sun, Aug 02, 2026 at 12:50:05PM -0400, Tal Zussman wrote:
> Convert the final caller in get_writepages_data_length() to use a folio
> and ceph_folio_snap_context(), then remove page_snap_context().
> 
> This drops the last open-coded use of page->private in ceph's writeback
> path.

This one I'm deeply conflicted about.  It's adding an extra call to
compound_head() ... and we're not getting much for it.

I'd feel better about it if it started with::

 static u64 get_writepages_data_length(struct inode *inode,
                                       struct page *page, u64 start)
 {
+	struct folio *folio = page_folio(page);

and then we had a ceph_fscrypt_pagecache_folio() function and
ceph_fscrypt_folio_offset() (we already have a fscrypt_is_bounce_page())

That way we'd have this function entirely converted except for its
argument, and a future patch can do the conversion with little fuss.
And we'd get rid of one of the four remaining calls to
fscrypt_is_bounce_page()

> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
>  fs/ceph/addr.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index f4aaf9a5f196..702cf5fc1eab 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -29,9 +29,9 @@
>   *
>   * There are a few funny things going on here.
>   *
> - * The page->private field is used to reference a struct
> - * ceph_snap_context for _every_ dirty page.  This indicates which
> - * snapshot the page was logically dirtied in, and thus which snap
> + * The folio->private field is used to reference a struct
> + * ceph_snap_context for _every_ dirty folio.  This indicates which
> + * snapshot the folio was logically dirtied in, and thus which snap
>   * context needs to be associated with the osd write during writeback.
>   *
>   * Similarly, struct ceph_inode_info maintains a set of counters to
> @@ -68,13 +68,6 @@
>  static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned int len,
>  					struct folio **foliop, void **_fsdata);
>  
> -static inline struct ceph_snap_context *page_snap_context(struct page *page)
> -{
> -	if (PagePrivate(page))
> -		return (void *)page->private;
> -	return NULL;
> -}
> -
>  static inline struct ceph_snap_context *ceph_folio_snap_context(struct folio *folio)
>  {
>  	if (folio_test_private(folio))
> @@ -697,7 +690,7 @@ static u64 get_writepages_data_length(struct inode *inode,
>  	u64 end = i_size_read(inode);
>  	u64 ret;
>  
> -	snapc = page_snap_context(ceph_fscrypt_pagecache_page(page));
> +	snapc = ceph_folio_snap_context(page_folio(ceph_fscrypt_pagecache_page(page)));
>  	if (snapc != ci->i_head_snapc) {
>  		bool found = false;
>  		spin_lock(&ci->i_ceph_lock);
> 
> -- 
> 2.39.5
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/4] ceph: add ceph_folio_snap_context()
  2026-08-02 22:44     ` Zi Yan
@ 2026-08-03 10:17       ` Tal Zussman
  0 siblings, 0 replies; 13+ messages in thread
From: Tal Zussman @ 2026-08-03 10:17 UTC (permalink / raw)
  To: Zi Yan, Matthew Wilcox
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, ceph-devel, linux-kernel,
	linux-fsdevel, linux-mm

On 8/2/26 6:44 PM, Zi Yan wrote:
> On Sun Aug 2, 2026 at 5:52 PM EDT, Matthew Wilcox wrote:
>> On Sun, Aug 02, 2026 at 12:50:02PM -0400, Tal Zussman wrote:
>>> +static inline struct ceph_snap_context *ceph_folio_snap_context(struct folio *folio)
>>> +{
>>> +	if (folio_test_private(folio))
>>> +		return (void *)folio->private;
>>> +	return NULL;
>>> +}
>>
>> Filesystem folios _ought_to have folio->private as NULL when PG_private
>> is unset and PG_private set when folio->private is non-NULL.  Now, ceph
>> could be doing something Bad (I believe hugetlbfs does not honour this
>> for various reasons), but it looks like it's using
>> folio_attach_private() / folio_detach_private() appropriately.
>>
>> So I think we should just do:
>>
>> static inline
>> struct ceph_snap_context *ceph_folio_snap_context(const struct folio *folio)
>> {
>> 	return folio->private;
>> }
> 
> Yes, please. So I do not need to handle another exceptional user when I
> am trying to remove PG_private[1].
> 

Sounds good, will do.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] ceph: remove page_snap_context()
  2026-08-03  2:06   ` Matthew Wilcox
@ 2026-08-03 11:03     ` Tal Zussman
  0 siblings, 0 replies; 13+ messages in thread
From: Tal Zussman @ 2026-08-03 11:03 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Jan Kara,
	Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Zi Yan, ceph-devel,
	linux-kernel, linux-fsdevel, linux-mm

On 8/2/26 10:06 PM, Matthew Wilcox wrote: 
> On Sun, Aug 02, 2026 at 12:50:05PM -0400, Tal Zussman wrote:
>> Convert the final caller in get_writepages_data_length() to use a folio
>> and ceph_folio_snap_context(), then remove page_snap_context().
>> 
>> This drops the last open-coded use of page->private in ceph's writeback
>> path.
> 
> This one I'm deeply conflicted about.  It's adding an extra call to
> compound_head() ... and we're not getting much for it.
> 
> I'd feel better about it if it started with::
> 
>   static u64 get_writepages_data_length(struct inode *inode,
>                                         struct page *page, u64 start)
>   {
> +	struct folio *folio = page_folio(page);
> 
> and then we had a ceph_fscrypt_pagecache_folio() function and
> ceph_fscrypt_folio_offset() (we already have a fscrypt_is_bounce_page())

If we're adding these, I might as well do a few more conversions...

> That way we'd have this function entirely converted except for its
> argument, and a future patch can do the conversion with little fuss.
> And we'd get rid of one of the four remaining calls to
> fscrypt_is_bounce_page()

I'm tempted to convert the argument as well, offload the page_folio
to the single caller (ceph_submit_write), and be done with this function
in one go. Although now that I look at it again, ceph_submit_write can
also be converted with the fscrypt helpers (albeit with a healthy dose
of page_folio() due to ceph's pages arrays...).


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/4] mm: remove wait_on_page_writeback()
  2026-08-02 16:50 ` [PATCH 3/4] mm: remove wait_on_page_writeback() Tal Zussman
  2026-08-02 23:23   ` Matthew Wilcox
@ 2026-08-03 12:34   ` David Hildenbrand (Arm)
  1 sibling, 0 replies; 13+ messages in thread
From: David Hildenbrand (Arm) @ 2026-08-03 12:34 UTC (permalink / raw)
  To: Tal Zussman, Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko,
	Matthew Wilcox (Oracle), Jan Kara, Andrew Morton, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Zi Yan
  Cc: ceph-devel, linux-kernel, linux-fsdevel, linux-mm

On 8/2/26 18:50, Tal Zussman wrote:
> The last caller was converted to folio_wait_writeback(), so drop the
> wait_on_page_writeback() compatibility wrapper and its declaration.
> 
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-08-03 12:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 16:50 [PATCH 0/4] mm, ceph: remove wait_on_page_writeback() Tal Zussman
2026-08-02 16:50 ` [PATCH 1/4] ceph: add ceph_folio_snap_context() Tal Zussman
2026-08-02 21:52   ` Matthew Wilcox
2026-08-02 22:44     ` Zi Yan
2026-08-03 10:17       ` Tal Zussman
2026-08-02 16:50 ` [PATCH 2/4] ceph: convert ceph_wait_until_current_writes_complete() to folios Tal Zussman
2026-08-02 23:22   ` Matthew Wilcox
2026-08-02 16:50 ` [PATCH 3/4] mm: remove wait_on_page_writeback() Tal Zussman
2026-08-02 23:23   ` Matthew Wilcox
2026-08-03 12:34   ` David Hildenbrand (Arm)
2026-08-02 16:50 ` [PATCH 4/4] ceph: remove page_snap_context() Tal Zussman
2026-08-03  2:06   ` Matthew Wilcox
2026-08-03 11:03     ` Tal Zussman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox