linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	stable@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v2 1/7] ceph: Do not look at the index of an encrypted page
Date: Fri, 14 Feb 2025 15:57:03 +0000	[thread overview]
Message-ID: <20250214155710.2790505-2-willy@infradead.org> (raw)
In-Reply-To: <20250214155710.2790505-1-willy@infradead.org>

If the pages array contains encrypted pages, we cannot look at
page->index because that field is uninitialised.  Instead, use the new
ceph_fscrypt_pagecache_folio() to get the pagecache folio and look at
the index of that.

Fixes: d55207717ded (ceph: add encryption support to writepage and writepages)
Cc: stable@vger.kernel.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/addr.c   | 5 ++++-
 fs/ceph/crypto.h | 7 +++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index f5224a566b69..80bc0cbacd7a 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1356,8 +1356,11 @@ static int ceph_writepages_start(struct address_space *mapping,
 			memset(data_pages + i, 0,
 			       locked_pages * sizeof(*pages));
 		} else {
+			struct folio *folio;
+
 			BUG_ON(num_ops != req->r_num_ops);
-			index = pages[i - 1]->index + 1;
+			folio = ceph_fscrypt_pagecache_folio(pages[i - 1]);
+			index = folio->index + 1;
 			/* request message now owns the pages array */
 			pages = NULL;
 		}
diff --git a/fs/ceph/crypto.h b/fs/ceph/crypto.h
index d0768239a1c9..e4404ef589a1 100644
--- a/fs/ceph/crypto.h
+++ b/fs/ceph/crypto.h
@@ -280,6 +280,13 @@ static inline struct page *ceph_fscrypt_pagecache_page(struct page *page)
 }
 #endif /* CONFIG_FS_ENCRYPTION */
 
+static inline struct folio *ceph_fscrypt_pagecache_folio(struct page *page)
+{
+	if (fscrypt_is_bounce_page(page))
+		page = fscrypt_pagecache_page(page);
+	return page_folio(page);
+}
+
 static inline loff_t ceph_fscrypt_page_offset(struct page *page)
 {
 	return page_offset(ceph_fscrypt_pagecache_page(page));
-- 
2.47.2


  reply	other threads:[~2025-02-14 15:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14 15:57 [PATCH v2 0/7] Remove accesses to page->index from ceph Matthew Wilcox (Oracle)
2025-02-14 15:57 ` Matthew Wilcox (Oracle) [this message]
2025-02-14 15:57 ` [PATCH v2 2/7] ceph: Remove ceph_writepage() Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 3/7] ceph: Use a folio in ceph_page_mkwrite() Matthew Wilcox (Oracle)
2025-02-14 19:05   ` Viacheslav Dubeyko
2025-02-14 15:57 ` [PATCH v2 4/7] ceph: Convert ceph_find_incompatible() to take a folio Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 5/7] ceph: Convert ceph_readdir_cache_control to store " Matthew Wilcox (Oracle)
2025-02-14 19:10   ` Viacheslav Dubeyko
2025-02-14 19:34     ` Matthew Wilcox
2025-02-14 19:38       ` Viacheslav Dubeyko
2025-02-14 15:57 ` [PATCH v2 6/7] ceph: Convert writepage_nounlock() to write_folio_nounlock() Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 7/7] ceph: Use a folio in ceph_writepages_start() Matthew Wilcox (Oracle)

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=20250214155710.2790505-2-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=stable@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).