From: Jan Kara <jack@suse.cz>
To: Zhang Yi <yi.zhang@huaweicloud.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com,
yukuai3@huawei.com
Subject: Re: [PATCH v2 07/12] jbd2: add fast_commit space check
Date: Thu, 10 Aug 2023 12:10:16 +0200 [thread overview]
Message-ID: <20230810101016.jed6k7egldi3w5bv@quack3> (raw)
In-Reply-To: <20230810085417.1501293-8-yi.zhang@huaweicloud.com>
On Thu 10-08-23 16:54:12, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> If JBD2_FEATURE_INCOMPAT_FAST_COMMIT bit is set, it means the journal
> have fast commit records need to recover, so the fast commit size
> should not be too large, and the leftover normal journal size should
> never less than JBD2_MIN_JOURNAL_BLOCKS. If it happens, the
> journal->j_last is likely to be wrong and will probably lead to
> incorrect journal recovery. So add a check into the
> journal_check_superblock(), and drop the pointless check when
> initializing the fastcommit parameters.
>
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Just one small note below. With that fixed feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
> @@ -1389,6 +1390,14 @@ static int journal_check_superblock(journal_t *journal)
> return err;
> }
>
> + num_fc_blks = jbd2_has_feature_fast_commit(journal) ?
> + jbd2_journal_get_num_fc_blks(sb) : 0;
> + if (be32_to_cpu(sb->s_maxlen) < JBD2_MIN_JOURNAL_BLOCKS + num_fc_blks) {
To avoid possible overflow of the right hand side, we should probably do
the check like:
if (be32_to_cpu(sb->s_maxlen) < JBD2_MIN_JOURNAL_BLOCKS ||
be32_to_cpu(sb->s_maxlen) - JBD2_MIN_JOURNAL_BLOCKS < num_fc_blks) {
...
}
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-08-10 10:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 8:54 [PATCH v2 00/12] ext4,jbd2: cleanup journal load and initialization process Zhang Yi
2023-08-10 8:54 ` [PATCH v2 01/12] jbd2: move load_superblock() dependent functions Zhang Yi
2023-08-10 8:54 ` [PATCH v2 02/12] jbd2: move load_superblock() into journal_init_common() Zhang Yi
2023-08-10 8:54 ` [PATCH v2 03/12] jbd2: don't load superblock in jbd2_journal_check_used_features() Zhang Yi
2023-08-10 8:54 ` [PATCH v2 04/12] jbd2: checking valid features early in journal_get_superblock() Zhang Yi
2023-08-10 8:54 ` [PATCH v2 05/12] jbd2: open code jbd2_verify_csum_type() helper Zhang Yi
2023-08-10 8:54 ` [PATCH v2 06/12] jbd2: cleanup load_superblock() Zhang Yi
2023-08-10 10:02 ` Jan Kara
2023-08-10 8:54 ` [PATCH v2 07/12] jbd2: add fast_commit space check Zhang Yi
2023-08-10 10:10 ` Jan Kara [this message]
2023-08-10 8:54 ` [PATCH v2 08/12] jbd2: cleanup journal_init_common() Zhang Yi
2023-08-10 8:54 ` [PATCH v2 09/12] jbd2: drop useless error tag in jbd2_journal_wipe() Zhang Yi
2023-08-10 8:54 ` [PATCH v2 10/12] jbd2: jbd2_journal_init_{dev,inode} return proper error return value Zhang Yi
2023-08-10 8:54 ` [PATCH v2 11/12] ext4: cleanup ext4_get_dev_journal() and ext4_get_journal() Zhang Yi
2023-08-10 10:20 ` Jan Kara
2023-08-10 8:54 ` [PATCH v2 12/12] ext4: ext4_get_{dev}_journal return proper error value Zhang Yi
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=20230810101016.jed6k7egldi3w5bv@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
--cc=yi.zhang@huaweicloud.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