Skip to content

Commit f9707a8

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
ceph: Convert ceph_find_incompatible() to take a folio
Both callers already have the folio. Pass it in and use it throughout. Removes some hidden calls to compound_head() and a reference to page->mapping. Signed-off-by: "Matthew Wilcox (Oracle)" <willy@infradead.org> Link: https://lore.kernel.org/r/20250217185119.430193-4-willy@infradead.org Tested-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 88a59bd commit f9707a8

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

fs/ceph/addr.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,56 +1771,56 @@ static int context_is_writeable_or_written(struct inode *inode,
17711771

17721772
/**
17731773
* ceph_find_incompatible - find an incompatible context and return it
1774-
* @page: page being dirtied
1774+
* @folio: folio being dirtied
17751775
*
1776-
* We are only allowed to write into/dirty a page if the page is
1776+
* We are only allowed to write into/dirty a folio if the folio is
17771777
* clean, or already dirty within the same snap context. Returns a
17781778
* conflicting context if there is one, NULL if there isn't, or a
17791779
* negative error code on other errors.
17801780
*
1781-
* Must be called with page lock held.
1781+
* Must be called with folio lock held.
17821782
*/
17831783
static struct ceph_snap_context *
1784-
ceph_find_incompatible(struct page *page)
1784+
ceph_find_incompatible(struct folio *folio)
17851785
{
1786-
struct inode *inode = page->mapping->host;
1786+
struct inode *inode = folio->mapping->host;
17871787
struct ceph_client *cl = ceph_inode_to_client(inode);
17881788
struct ceph_inode_info *ci = ceph_inode(inode);
17891789

17901790
if (ceph_inode_is_shutdown(inode)) {
1791-
doutc(cl, " %llx.%llx page %p is shutdown\n",
1792-
ceph_vinop(inode), page);
1791+
doutc(cl, " %llx.%llx folio %p is shutdown\n",
1792+
ceph_vinop(inode), folio);
17931793
return ERR_PTR(-ESTALE);
17941794
}
17951795

17961796
for (;;) {
17971797
struct ceph_snap_context *snapc, *oldest;
17981798

1799-
wait_on_page_writeback(page);
1799+
folio_wait_writeback(folio);
18001800

1801-
snapc = page_snap_context(page);
1801+
snapc = page_snap_context(&folio->page);
18021802
if (!snapc || snapc == ci->i_head_snapc)
18031803
break;
18041804

18051805
/*
1806-
* this page is already dirty in another (older) snap
1806+
* this folio is already dirty in another (older) snap
18071807
* context! is it writeable now?
18081808
*/
18091809
oldest = get_oldest_context(inode, NULL, NULL);
18101810
if (snapc->seq > oldest->seq) {
18111811
/* not writeable -- return it for the caller to deal with */
18121812
ceph_put_snap_context(oldest);
1813-
doutc(cl, " %llx.%llx page %p snapc %p not current or oldest\n",
1814-
ceph_vinop(inode), page, snapc);
1813+
doutc(cl, " %llx.%llx folio %p snapc %p not current or oldest\n",
1814+
ceph_vinop(inode), folio, snapc);
18151815
return ceph_get_snap_context(snapc);
18161816
}
18171817
ceph_put_snap_context(oldest);
18181818

1819-
/* yay, writeable, do it now (without dropping page lock) */
1820-
doutc(cl, " %llx.%llx page %p snapc %p not current, but oldest\n",
1821-
ceph_vinop(inode), page, snapc);
1822-
if (clear_page_dirty_for_io(page)) {
1823-
int r = writepage_nounlock(page, NULL);
1819+
/* yay, writeable, do it now (without dropping folio lock) */
1820+
doutc(cl, " %llx.%llx folio %p snapc %p not current, but oldest\n",
1821+
ceph_vinop(inode), folio, snapc);
1822+
if (folio_clear_dirty_for_io(folio)) {
1823+
int r = writepage_nounlock(&folio->page, NULL);
18241824
if (r < 0)
18251825
return ERR_PTR(r);
18261826
}
@@ -1835,7 +1835,7 @@ static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned
18351835
struct ceph_inode_info *ci = ceph_inode(inode);
18361836
struct ceph_snap_context *snapc;
18371837

1838-
snapc = ceph_find_incompatible(folio_page(*foliop, 0));
1838+
snapc = ceph_find_incompatible(*foliop);
18391839
if (snapc) {
18401840
int r;
18411841

@@ -2095,7 +2095,7 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
20952095
break;
20962096
}
20972097

2098-
snapc = ceph_find_incompatible(&folio->page);
2098+
snapc = ceph_find_incompatible(folio);
20992099
if (!snapc) {
21002100
/* success. we'll keep the folio locked. */
21012101
folio_mark_dirty(folio);

0 commit comments

Comments
 (0)