From 81a949790a69058f4c62bddaeed240e083f52d7f Mon Sep 17 00:00:00 2001 From: Tal Zussman Date: Wed, 2 Sep 2026 12:11:27 -0400 Subject: [PATCH] ceph: add ceph_folio_snap_context() 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 Acked-by: Zi Yan Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Alex Markuze Signed-off-by: Ilya Dryomov --- fs/ceph/addr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 739ae42a3b89..a0c18b93182a 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -75,6 +75,12 @@ static inline struct ceph_snap_context *page_snap_context(struct page *page) return NULL; } +static inline +struct ceph_snap_context *ceph_folio_snap_context(const struct folio *folio) +{ + return folio->private; +} + /* * Dirty a page. Optimistically adjust accounting, on the assumption * that we won't race with invalidate. If we do, readjust. @@ -774,7 +780,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); @@ -1203,7 +1209,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, @@ -1874,7 +1880,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;