From: Zhang Yi <yi.zhang@huaweicloud.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, willy@infradead.org, tytso@mit.edu,
adilger.kernel@dilger.ca, yi.zhang@huawei.com,
libaokun1@huawei.com, yukuai3@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH v2 4/8] ext4/jbd2: convert jbd2_journal_blocks_per_page() to support large folio
Date: Tue, 20 May 2025 20:46:51 +0800 [thread overview]
Message-ID: <924cfe2c-318c-493f-89a5-10849bfc7a00@huaweicloud.com> (raw)
In-Reply-To: <ht54j6bvjmiqt62xmcveqlo7bmrunqs4ji7wikfteftdjijzek@7tz5gpejaoen>
On 2025/5/20 4:16, Jan Kara wrote:
> On Mon 12-05-25 14:33:15, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.com>
>>
>> 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>
> ...
>> @@ -2657,9 +2657,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);
>> }
>
> FWIW this will result in us reserving some 10k transaction credits for 1k
> blocksize with maximum 2M folio size. That is going to create serious
> pressure on the journalling machinery. For now I guess we are fine
Oooh, indeed, you are right, thanks a lot for pointing this out. As you
mentioned in patch 5, the credits calculation I proposed was incorrect,
I thought it wouldn't require too many credits.
I believe it is risky to mount a filesystem with a small journal space
and a large number of block groups. For example, if we build an image
with a 1K block size and a 1MB journal on a 20GB disk (which contains
2,540 groups), it will require 2,263 credits, exceeding the available
journal space.
For now, I'm going to disable large folio support on the filesystem with
limited journal space. i.e., when the return value of
ext4_writepage_trans_blocks() is greater than
jbd2_max_user_trans_buffers(journal) / 2, ext4_should_enable_large_folio()
return false, thoughts?
> but
> eventually we should rewrite how credits for writing out folio are computed
> to reduce this massive overestimation. It will be a bit tricky but we could
> always reserve credits for one / couple of extents and try to extend the
> transaction if we need more. The tricky part is to do the partial folio
> writeout in case we cannot extend the transaction...
>
Yes, this is a feasible solution; however, I prefer to promote the iomap
conversion in the long run.
Thanks,
Yi.
next prev parent reply other threads:[~2025-05-20 12:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 6:33 [PATCH v2 0/8] ext4: enable large folio for regular files Zhang Yi
2025-05-12 6:33 ` [PATCH v2 1/8] ext4: make ext4_mpage_readpages() support large folios Zhang Yi
2025-05-20 10:41 ` Ojaswin Mujoo
2025-05-12 6:33 ` [PATCH v2 2/8] ext4: make regular file's buffered write path " Zhang Yi
2025-05-12 6:33 ` [PATCH v2 3/8] ext4: make __ext4_block_zero_page_range() support large folio Zhang Yi
2025-05-20 10:41 ` Ojaswin Mujoo
2025-05-12 6:33 ` [PATCH v2 4/8] ext4/jbd2: convert jbd2_journal_blocks_per_page() to " Zhang Yi
2025-05-19 20:16 ` Jan Kara
2025-05-20 12:46 ` Zhang Yi [this message]
2025-05-21 10:31 ` Jan Kara
2025-05-12 6:33 ` [PATCH v2 5/8] ext4: correct the journal credits calculations of allocating blocks Zhang Yi
2025-05-19 2:48 ` Zhang Yi
2025-05-19 15:48 ` Theodore Ts'o
2025-05-20 13:04 ` Zhang Yi
2025-05-19 20:24 ` Jan Kara
2025-05-20 12:53 ` Zhang Yi
2025-05-12 6:33 ` [PATCH v2 6/8] ext4: make the writeback path support large folios Zhang Yi
2025-05-20 10:42 ` Ojaswin Mujoo
2025-05-12 6:33 ` [PATCH v2 7/8] ext4: make online defragmentation " Zhang Yi
2025-05-12 6:33 ` [PATCH v2 8/8] ext4: enable large folio for regular file Zhang Yi
2025-05-16 9:05 ` kernel test robot
2025-05-20 10:48 ` Ojaswin Mujoo
2025-06-25 8:14 ` Lai, Yi
2025-06-25 13:15 ` Theodore Ts'o
2025-06-26 3:35 ` Lai, Yi
2025-06-26 11:29 ` D, Suneeth
2025-06-26 13:26 ` Zhang Yi
2025-06-26 14:56 ` Theodore Ts'o
2025-07-03 14:13 ` Zhang Yi
2025-05-16 11:48 ` [PATCH v2 0/8] ext4: enable large folio for regular files Ojaswin Mujoo
2025-05-19 1:19 ` Zhang Yi
2025-05-19 11:02 ` Ojaswin Mujoo
2025-05-19 20:33 ` Jan Kara
2025-05-20 13:09 ` Zhang Yi
2025-05-20 10:37 ` Ojaswin Mujoo
2025-05-20 13:41 ` Zhang Yi
2025-05-20 14:40 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=924cfe2c-318c-493f-89a5-10849bfc7a00@huaweicloud.com \
--to=yi.zhang@huaweicloud.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).