Message ID | 20250214155710.2790505-6-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Remove accesses to page->index from ceph | expand |
On Fri, 2025-02-14 at 15:57 +0000, Matthew Wilcox (Oracle) wrote: > 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> > --- > fs/ceph/dir.c | 13 +++++++------ > fs/ceph/inode.c | 26 ++++++++++++++------------ > fs/ceph/super.h | 2 +- > 3 files changed, 22 insertions(+), 19 deletions(-) > > diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c > index 62e99e65250d..66f00604c86b 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) { > + cache_ctl->folio = filemap_lock_folio(&dir->i_data, ptr_pgoff); > + if (IS_ERR(cache_ctl->folio)) { > + cache_ctl->folio = NULL; > doutc(cl, " page %lu not found\n", ptr_pgoff); Maybe, we need to change debug output here too? doutc(cl, " folio %lu not found\n", ptr_pgoff); Thanks, Slava.
On Fri, Feb 14, 2025 at 07:10:26PM +0000, Viacheslav Dubeyko wrote: > > - cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff); > > - if (!cache_ctl->page) { > > + cache_ctl->folio = filemap_lock_folio(&dir->i_data, ptr_pgoff); > > + if (IS_ERR(cache_ctl->folio)) { > > + cache_ctl->folio = NULL; > > doutc(cl, " page %lu not found\n", ptr_pgoff); > > Maybe, we need to change debug output here too? > > doutc(cl, " folio %lu not found\n", ptr_pgoff); I'm happy to make that change for the next version, or for somebody to make that change while applying the patches.
On Fri, 2025-02-14 at 19:34 +0000, Matthew Wilcox wrote: > On Fri, Feb 14, 2025 at 07:10:26PM +0000, Viacheslav Dubeyko wrote: > > > - cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff); > > > - if (!cache_ctl->page) { > > > + cache_ctl->folio = filemap_lock_folio(&dir->i_data, ptr_pgoff); > > > + if (IS_ERR(cache_ctl->folio)) { > > > + cache_ctl->folio = NULL; > > > doutc(cl, " page %lu not found\n", ptr_pgoff); > > > > Maybe, we need to change debug output here too? > > > > doutc(cl, " folio %lu not found\n", ptr_pgoff); > > I'm happy to make that change for the next version, or for somebody to > make that change while applying the patches. It's not critical one. The patch looks good. Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Thanks, Slava.
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 62e99e65250d..66f00604c86b 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) { + cache_ctl->folio = filemap_lock_folio(&dir->i_data, ptr_pgoff); + if (IS_ERR(cache_ctl->folio)) { + cache_ctl->folio = NULL; doutc(cl, " page %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; };
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> --- fs/ceph/dir.c | 13 +++++++------ fs/ceph/inode.c | 26 ++++++++++++++------------ fs/ceph/super.h | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-)