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 4/9] ceph: Convert ceph_readdir_cache_control to store a folio
Date: Mon, 17 Feb 2025 18:51:12 +0000 [thread overview]
Message-ID: <20250217185119.430193-5-willy@infradead.org> (raw)
In-Reply-To: <20250217185119.430193-1-willy@infradead.org>
Pass a folio around instead of a page. This removes an access to
page->index and a few hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
---
fs/ceph/dir.c | 15 ++++++++-------
fs/ceph/inode.c | 26 ++++++++++++++------------
fs/ceph/super.h | 2 +-
3 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 62e99e65250d..d22be9314de3 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -141,17 +141,18 @@ __dcache_find_get_entry(struct dentry *parent, u64 idx,
if (ptr_pos >= i_size_read(dir))
return NULL;
- if (!cache_ctl->page || ptr_pgoff != cache_ctl->page->index) {
+ if (!cache_ctl->folio || ptr_pgoff != cache_ctl->folio->index) {
ceph_readdir_cache_release(cache_ctl);
- cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff);
- if (!cache_ctl->page) {
- doutc(cl, " page %lu not found\n", ptr_pgoff);
+ cache_ctl->folio = filemap_lock_folio(&dir->i_data, ptr_pgoff);
+ if (IS_ERR(cache_ctl->folio)) {
+ cache_ctl->folio = NULL;
+ doutc(cl, " folio %lu not found\n", ptr_pgoff);
return ERR_PTR(-EAGAIN);
}
/* reading/filling the cache are serialized by
- i_rwsem, no need to use page lock */
- unlock_page(cache_ctl->page);
- cache_ctl->dentries = kmap(cache_ctl->page);
+ i_rwsem, no need to use folio lock */
+ folio_unlock(cache_ctl->folio);
+ cache_ctl->dentries = kmap_local_folio(cache_ctl->folio, 0);
}
cache_ctl->index = idx & idx_mask;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 7dd6c2275085..c15970fa240f 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1845,10 +1845,9 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,
void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl)
{
- if (ctl->page) {
- kunmap(ctl->page);
- put_page(ctl->page);
- ctl->page = NULL;
+ if (ctl->folio) {
+ folio_release_kmap(ctl->folio, ctl->dentries);
+ ctl->folio = NULL;
}
}
@@ -1862,20 +1861,23 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn,
unsigned idx = ctl->index % nsize;
pgoff_t pgoff = ctl->index / nsize;
- if (!ctl->page || pgoff != ctl->page->index) {
+ if (!ctl->folio || pgoff != ctl->folio->index) {
ceph_readdir_cache_release(ctl);
+ fgf_t fgf = FGP_LOCK;
+
if (idx == 0)
- ctl->page = grab_cache_page(&dir->i_data, pgoff);
- else
- ctl->page = find_lock_page(&dir->i_data, pgoff);
- if (!ctl->page) {
+ fgf |= FGP_ACCESSED | FGP_CREAT;
+
+ ctl->folio = __filemap_get_folio(&dir->i_data, pgoff,
+ fgf, mapping_gfp_mask(&dir->i_data));
+ if (!ctl->folio) {
ctl->index = -1;
return idx == 0 ? -ENOMEM : 0;
}
/* reading/filling the cache are serialized by
- * i_rwsem, no need to use page lock */
- unlock_page(ctl->page);
- ctl->dentries = kmap(ctl->page);
+ * i_rwsem, no need to use folio lock */
+ folio_unlock(ctl->folio);
+ ctl->dentries = kmap_local_folio(ctl->folio, 0);
if (idx == 0)
memset(ctl->dentries, 0, PAGE_SIZE);
}
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 7fa1e7be50e4..bb0db0cc8003 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -903,7 +903,7 @@ ceph_find_rw_context(struct ceph_file_info *cf)
}
struct ceph_readdir_cache_control {
- struct page *page;
+ struct folio *folio;
struct dentry **dentries;
int index;
};
--
2.47.2
next prev 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 ` [PATCH v3 3/9] ceph: Convert ceph_find_incompatible() to take a folio Matthew Wilcox (Oracle)
2025-02-17 18:51 ` Matthew Wilcox (Oracle) [this message]
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-5-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).