linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	David Howells <dhowells@redhat.com>
Subject: [PATCH v3 3/9] ceph: Convert ceph_find_incompatible() to take a folio
Date: Mon, 17 Feb 2025 18:51:11 +0000	[thread overview]
Message-ID: <20250217185119.430193-4-willy@infradead.org> (raw)
In-Reply-To: <20250217185119.430193-1-willy@infradead.org>

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>
---
 fs/ceph/addr.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 045ec57e72b8..08f8bdfc275e 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1781,56 +1781,56 @@ static int context_is_writeable_or_written(struct inode *inode,
 
 /**
  * ceph_find_incompatible - find an incompatible context and return it
- * @page: page being dirtied
+ * @folio: folio being dirtied
  *
- * We are only allowed to write into/dirty a page if the page is
+ * We are only allowed to write into/dirty a folio if the folio is
  * clean, or already dirty within the same snap context. Returns a
  * conflicting context if there is one, NULL if there isn't, or a
  * negative error code on other errors.
  *
- * Must be called with page lock held.
+ * Must be called with folio lock held.
  */
 static struct ceph_snap_context *
-ceph_find_incompatible(struct page *page)
+ceph_find_incompatible(struct folio *folio)
 {
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	struct ceph_client *cl = ceph_inode_to_client(inode);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 
 	if (ceph_inode_is_shutdown(inode)) {
-		doutc(cl, " %llx.%llx page %p is shutdown\n",
-		      ceph_vinop(inode), page);
+		doutc(cl, " %llx.%llx folio %p is shutdown\n",
+		      ceph_vinop(inode), folio);
 		return ERR_PTR(-ESTALE);
 	}
 
 	for (;;) {
 		struct ceph_snap_context *snapc, *oldest;
 
-		wait_on_page_writeback(page);
+		folio_wait_writeback(folio);
 
-		snapc = page_snap_context(page);
+		snapc = page_snap_context(&folio->page);
 		if (!snapc || snapc == ci->i_head_snapc)
 			break;
 
 		/*
-		 * this page is already dirty in another (older) snap
+		 * this folio is already dirty in another (older) snap
 		 * context!  is it writeable now?
 		 */
 		oldest = get_oldest_context(inode, NULL, NULL);
 		if (snapc->seq > oldest->seq) {
 			/* not writeable -- return it for the caller to deal with */
 			ceph_put_snap_context(oldest);
-			doutc(cl, " %llx.%llx page %p snapc %p not current or oldest\n",
-			      ceph_vinop(inode), page, snapc);
+			doutc(cl, " %llx.%llx folio %p snapc %p not current or oldest\n",
+			      ceph_vinop(inode), folio, snapc);
 			return ceph_get_snap_context(snapc);
 		}
 		ceph_put_snap_context(oldest);
 
-		/* yay, writeable, do it now (without dropping page lock) */
-		doutc(cl, " %llx.%llx page %p snapc %p not current, but oldest\n",
-		      ceph_vinop(inode), page, snapc);
-		if (clear_page_dirty_for_io(page)) {
-			int r = writepage_nounlock(page, NULL);
+		/* yay, writeable, do it now (without dropping folio lock) */
+		doutc(cl, " %llx.%llx folio %p snapc %p not current, but oldest\n",
+		      ceph_vinop(inode), folio, snapc);
+		if (folio_clear_dirty_for_io(folio)) {
+			int r = writepage_nounlock(&folio->page, NULL);
 			if (r < 0)
 				return ERR_PTR(r);
 		}
@@ -1845,7 +1845,7 @@ static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_snap_context *snapc;
 
-	snapc = ceph_find_incompatible(folio_page(*foliop, 0));
+	snapc = ceph_find_incompatible(*foliop);
 	if (snapc) {
 		int r;
 
@@ -2105,7 +2105,7 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
 			break;
 		}
 
-		snapc = ceph_find_incompatible(&folio->page);
+		snapc = ceph_find_incompatible(folio);
 		if (!snapc) {
 			/* success.  we'll keep the folio locked. */
 			folio_mark_dirty(folio);
-- 
2.47.2


  parent reply	other threads:[~2025-02-17 18:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 18:51 [PATCH v3 0/9] Remove accesses to page->index from ceph Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 1/9] ceph: Remove ceph_writepage() Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 2/9] ceph: Use a folio in ceph_page_mkwrite() Matthew Wilcox (Oracle)
2025-02-17 18:51 ` Matthew Wilcox (Oracle) [this message]
2025-02-17 18:51 ` [PATCH v3 4/9] ceph: Convert ceph_readdir_cache_control to store a folio Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 5/9] ceph: Convert writepage_nounlock() to write_folio_nounlock() Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 6/9] ceph: Convert ceph_check_page_before_write() to use a folio Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 7/9] ceph: Remove uses of page from ceph_process_folio_batch() Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 8/9] ceph: Convert ceph_move_dirty_page_in_page_array() to move_dirty_folio_in_page_array() Matthew Wilcox (Oracle)
2025-02-17 18:51 ` [PATCH v3 9/9] ceph: Pass a folio to ceph_allocate_page_array() Matthew Wilcox (Oracle)
2025-02-18  0:34 ` [PATCH v3 0/9] Remove accesses to page->index from ceph Viacheslav Dubeyko
2025-02-21 20:44 ` [PATCH v3 10/9] fs: Remove page_mkwrite_check_truncate() Matthew Wilcox (Oracle)
2025-02-21 20:45   ` Matthew Wilcox
2025-02-24 20:11     ` Viacheslav Dubeyko
2025-02-24 20:19       ` Matthew Wilcox
2025-02-24 20:39         ` Viacheslav Dubeyko
2025-02-24 22:24   ` Viacheslav Dubeyko
2025-02-28 10:22 ` [PATCH v3 0/9] Remove accesses to page->index from ceph Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250217185119.430193-4-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=Slava.Dubeyko@ibm.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).