[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230810101016.jed6k7egldi3w5bv@quack3>
Date: Thu, 10 Aug 2023 12:10:16 +0200
From: Jan Kara <jack@...e.cz>
To: Zhang Yi <yi.zhang@...weicloud.com>
Cc: linux-ext4@...r.kernel.org, tytso@....edu,
adilger.kernel@...ger.ca, jack@...e.cz, yi.zhang@...wei.com,
yukuai3@...wei.com
Subject: Re: [PATCH v2 07/12] jbd2: add fast_commit space check
On Thu 10-08-23 16:54:12, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@...wei.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@...wei.com>
Just one small note below. With that fixed feel free to add:
Reviewed-by: Jan Kara <jack@...e.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@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists