[PATCH v3 03/12] ceph: add ceph_folio_snap_context()
From: Tal Zussman
Date: Mon Aug 10 2026 - 10:29:57 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.
Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
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 de0113b23940..3d86e4c85b06 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.
@@ -758,7 +764,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);
@@ -1183,7 +1189,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,
@@ -1840,7 +1846,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