f2fs: Pass a folio to make_empty_dir()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 31 Mar 2025 20:11:48 +0000 (21:11 +0100)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 28 Apr 2025 15:26:38 +0000 (15:26 +0000)
Pass the folio into make_empty_dir() and then into
f2fs_get_new_data_folio().  Removes a call to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c
fs/f2fs/dir.c
fs/f2fs/f2fs.h

index e7bb105c889de122744cb0f314a9a777401436b6..13999bca1cfcf72da6117314bc5734399514048f 100644 (file)
@@ -1338,11 +1338,11 @@ struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
  *
  * Also, caller should grab and release a rwsem by calling f2fs_lock_op() and
  * f2fs_unlock_op().
- * Note that, ipage is set only by make_empty_dir, and if any error occur,
- * ipage should be released by this function.
+ * Note that, ifolio is set only by make_empty_dir, and if any error occur,
+ * ifolio should be released by this function.
  */
 struct folio *f2fs_get_new_data_folio(struct inode *inode,
-               struct page *ipage, pgoff_t index, bool new_i_size)
+               struct folio *ifolio, pgoff_t index, bool new_i_size)
 {
        struct address_space *mapping = inode->i_mapping;
        struct folio *folio;
@@ -1352,20 +1352,20 @@ struct folio *f2fs_get_new_data_folio(struct inode *inode,
        folio = f2fs_grab_cache_folio(mapping, index, true);
        if (IS_ERR(folio)) {
                /*
-                * before exiting, we should make sure ipage will be released
+                * before exiting, we should make sure ifolio will be released
                 * if any error occur.
                 */
-               f2fs_put_page(ipage, 1);
+               f2fs_folio_put(ifolio, true);
                return ERR_PTR(-ENOMEM);
        }
 
-       set_new_dnode(&dn, inode, ipage, NULL, 0);
+       set_new_dnode(&dn, inode, &ifolio->page, NULL, 0);
        err = f2fs_reserve_block(&dn, index);
        if (err) {
                f2fs_folio_put(folio, true);
                return ERR_PTR(err);
        }
-       if (!ipage)
+       if (!ifolio)
                f2fs_put_dnode(&dn);
 
        if (folio_test_uptodate(folio))
@@ -1378,8 +1378,8 @@ struct folio *f2fs_get_new_data_folio(struct inode *inode,
        } else {
                f2fs_folio_put(folio, true);
 
-               /* if ipage exists, blkaddr should be NEW_ADDR */
-               f2fs_bug_on(F2FS_I_SB(inode), ipage);
+               /* if ifolio exists, blkaddr should be NEW_ADDR */
+               f2fs_bug_on(F2FS_I_SB(inode), ifolio);
                folio = f2fs_get_lock_data_folio(inode, index, true);
                if (IS_ERR(folio))
                        return folio;
index 5fffa18871b0165aade0921a4bf0b1305e93d871..34dba1b6db0339b8b1c549fa44bec295053259d8 100644 (file)
@@ -492,16 +492,16 @@ void f2fs_do_make_empty_dir(struct inode *inode, struct inode *parent,
 }
 
 static int make_empty_dir(struct inode *inode,
-               struct inode *parent, struct page *page)
+               struct inode *parent, struct folio *folio)
 {
        struct folio *dentry_folio;
        struct f2fs_dentry_block *dentry_blk;
        struct f2fs_dentry_ptr d;
 
        if (f2fs_has_inline_dentry(inode))
-               return f2fs_make_empty_inline_dir(inode, parent, page);
+               return f2fs_make_empty_inline_dir(inode, parent, &folio->page);
 
-       dentry_folio = f2fs_get_new_data_folio(inode, page, 0, true);
+       dentry_folio = f2fs_get_new_data_folio(inode, folio, 0, true);
        if (IS_ERR(dentry_folio))
                return PTR_ERR(dentry_folio);
 
@@ -529,7 +529,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir,
                if (S_ISDIR(inode->i_mode)) {
                        /* in order to handle error case */
                        folio_get(folio);
-                       err = make_empty_dir(inode, dir, &folio->page);
+                       err = make_empty_dir(inode, dir, folio);
                        if (err) {
                                folio_lock(folio);
                                goto put_error;
index 2a26d511900658df661a2740aab9e8f5afbaf003..a83305188981e8c40208729a382d7f29ec3c36b1 100644 (file)
@@ -3969,7 +3969,7 @@ struct folio *f2fs_find_data_folio(struct inode *inode, pgoff_t index,
 struct folio *f2fs_get_lock_data_folio(struct inode *inode, pgoff_t index,
                        bool for_write);
 struct folio *f2fs_get_new_data_folio(struct inode *inode,
-                       struct page *ipage, pgoff_t index, bool new_i_size);
+                       struct folio *ifolio, pgoff_t index, bool new_i_size);
 int f2fs_do_write_data_page(struct f2fs_io_info *fio);
 int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag);
 int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,