ceph: Convert ceph_readdir_cache_control to store a folio

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>
Link: https://lore.kernel.org/r/20250217185119.430193-5-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>
This commit is contained in:
Matthew Wilcox (Oracle) 2025-02-17 18:51:12 +00:00 committed by Christian Brauner
parent f9707a8b5b
commit baff9740bc
No known key found for this signature in database
GPG key ID: 91C61BC06578DCA2
3 changed files with 23 additions and 20 deletions

View file

@ -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;

View file

@ -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);
}

View file

@ -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;
};