Get a folio instead of a page and use it throughout.  Also put the folio
before checking the error so we only have to do it once.  Saves two
hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <wi...@infradead.org>
---
 fs/f2fs/dir.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index a24f04fc9073..2334995c9f9b 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -1041,7 +1041,6 @@ static int f2fs_readdir(struct file *file, struct 
dir_context *ctx)
        struct inode *inode = file_inode(file);
        unsigned long npages = dir_blocks(inode);
        struct f2fs_dentry_block *dentry_blk = NULL;
-       struct page *dentry_page = NULL;
        struct file_ra_state *ra = &file->f_ra;
        loff_t start_pos = ctx->pos;
        unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
@@ -1065,6 +1064,7 @@ static int f2fs_readdir(struct file *file, struct 
dir_context *ctx)
        }
 
        for (; n < npages; ctx->pos = n * NR_DENTRY_IN_BLOCK) {
+               struct folio *dentry_folio;
                pgoff_t next_pgofs;
 
                /* allow readdir() to be interrupted */
@@ -1079,9 +1079,9 @@ static int f2fs_readdir(struct file *file, struct 
dir_context *ctx)
                        page_cache_sync_readahead(inode->i_mapping, ra, file, n,
                                min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));
 
-               dentry_page = f2fs_find_data_page(inode, n, &next_pgofs);
-               if (IS_ERR(dentry_page)) {
-                       err = PTR_ERR(dentry_page);
+               dentry_folio = f2fs_find_data_folio(inode, n, &next_pgofs);
+               if (IS_ERR(dentry_folio)) {
+                       err = PTR_ERR(dentry_folio);
                        if (err == -ENOENT) {
                                err = 0;
                                n = next_pgofs;
@@ -1091,18 +1091,15 @@ static int f2fs_readdir(struct file *file, struct 
dir_context *ctx)
                        }
                }
 
-               dentry_blk = page_address(dentry_page);
+               dentry_blk = folio_address(dentry_folio);
 
                make_dentry_ptr_block(inode, &d, dentry_blk);
 
                err = f2fs_fill_dentries(ctx, &d,
                                n * NR_DENTRY_IN_BLOCK, &fstr);
-               if (err) {
-                       f2fs_put_page(dentry_page, 0);
+               f2fs_folio_put(dentry_folio, false);
+               if (err)
                        break;
-               }
-
-               f2fs_put_page(dentry_page, 0);
 
                n++;
        }
-- 
2.47.2



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to