]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4/jbd2: convert jbd2_journal_blocks_per_page() to support large folio
authorZhang Yi <yi.zhang@huawei.com>
Mon, 12 May 2025 06:33:15 +0000 (14:33 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 May 2025 14:31:12 +0000 (10:31 -0400)
jbd2_journal_blocks_per_page() returns the number of blocks in a single
page. Rename it to jbd2_journal_blocks_per_folio() and make it returns
the number of blocks in the largest folio, preparing for the calculation
of journal credits blocks when allocating blocks within a large folio in
the writeback path.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20250512063319.3539411-5-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4_jbd2.h
fs/ext4/inode.c
fs/jbd2/journal.c
include/linux/jbd2.h

index 3221714d9901a62f51ce4865d72f96102d22a1b2..63d17c5201b56e6e29b211959bc547febe464300 100644 (file)
@@ -319,10 +319,10 @@ static inline int ext4_journal_ensure_credits(handle_t *handle, int credits,
                                revoke_creds, 0);
 }
 
-static inline int ext4_journal_blocks_per_page(struct inode *inode)
+static inline int ext4_journal_blocks_per_folio(struct inode *inode)
 {
        if (EXT4_JOURNAL(inode) != NULL)
-               return jbd2_journal_blocks_per_page(inode);
+               return jbd2_journal_blocks_per_folio(inode);
        return 0;
 }
 
index 3596090f728a7ce73d1af424f981acc4c5e99343..3a46f2822cf02f6dd57a96ddf4a18bb5febce4e6 100644 (file)
@@ -2406,7 +2406,7 @@ update_disksize:
  */
 static int ext4_da_writepages_trans_blocks(struct inode *inode)
 {
-       int bpp = ext4_journal_blocks_per_page(inode);
+       int bpp = ext4_journal_blocks_per_folio(inode);
 
        return ext4_meta_trans_blocks(inode,
                                MAX_WRITEPAGES_EXTENT_LEN + bpp - 1, bpp);
@@ -2484,7 +2484,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
        ext4_lblk_t lblk;
        struct buffer_head *head;
        handle_t *handle = NULL;
-       int bpp = ext4_journal_blocks_per_page(mpd->inode);
+       int bpp = ext4_journal_blocks_per_folio(mpd->inode);
 
        if (mpd->wbc->sync_mode == WB_SYNC_ALL || mpd->wbc->tagged_writepages)
                tag = PAGECACHE_TAG_TOWRITE;
@@ -5883,7 +5883,7 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
  */
 int ext4_writepage_trans_blocks(struct inode *inode)
 {
-       int bpp = ext4_journal_blocks_per_page(inode);
+       int bpp = ext4_journal_blocks_per_folio(inode);
        int ret;
 
        ret = ext4_meta_trans_blocks(inode, bpp, bpp);
index bfaa14bb10490a95dfe8d967a16f8cd730072732..9700b5ea6f33c5917e12889121539af9a7fbaf94 100644 (file)
@@ -83,7 +83,7 @@ EXPORT_SYMBOL(jbd2_log_wait_commit);
 EXPORT_SYMBOL(jbd2_journal_start_commit);
 EXPORT_SYMBOL(jbd2_journal_force_commit_nested);
 EXPORT_SYMBOL(jbd2_journal_wipe);
-EXPORT_SYMBOL(jbd2_journal_blocks_per_page);
+EXPORT_SYMBOL(jbd2_journal_blocks_per_folio);
 EXPORT_SYMBOL(jbd2_journal_invalidate_folio);
 EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
 EXPORT_SYMBOL(jbd2_journal_force_commit);
@@ -2655,9 +2655,10 @@ void jbd2_journal_ack_err(journal_t *journal)
        write_unlock(&journal->j_state_lock);
 }
 
-int jbd2_journal_blocks_per_page(struct inode *inode)
+int jbd2_journal_blocks_per_folio(struct inode *inode)
 {
-       return 1 << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+       return 1 << (PAGE_SHIFT + mapping_max_folio_order(inode->i_mapping) -
+                    inode->i_sb->s_blocksize_bits);
 }
 
 /*
index 023e8abdb99a77ef250cc7a1bad800738cdf3547..ebbcdab474d51e1cd82c070ba2a938d428a9f4c4 100644 (file)
@@ -1723,7 +1723,7 @@ static inline int tid_geq(tid_t x, tid_t y)
        return (difference >= 0);
 }
 
-extern int jbd2_journal_blocks_per_page(struct inode *inode);
+extern int jbd2_journal_blocks_per_folio(struct inode *inode);
 extern size_t journal_tag_bytes(journal_t *journal);
 
 static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)