[PATCH v2 01/10] ceph: add ceph_folio_snap_context()

From: Tal Zussman

Date: Tue Aug 04 2026 - 14:54:17 EST


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@xxxxxxxxxxxx>
---
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 e2da3ab9f808..8347366ce5d9 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.
@@ -749,7 +755,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 +1177,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 +1830,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