From: Jan Kara <jack@suse.cz>
To: Zhang Yi <yi.zhang@huaweicloud.com>
Cc: Jan Kara <jack@suse.cz>,
linux-ext4@vger.kernel.org, tytso@mit.edu,
adilger.kernel@dilger.ca, yi.zhang@huawei.com,
chengzhihao1@huawei.com, yukuai3@huawei.com
Subject: Re: [PATCH 07/12] jbd2: add fast_commit space check
Date: Mon, 7 Aug 2023 15:33:14 +0200 [thread overview]
Message-ID: <20230807133314.sjkpdrluvvzgpotx@quack3> (raw)
In-Reply-To: <d23c42ce-32d1-79c3-63b2-0bfbc3af924c@huaweicloud.com>
On Mon 07-08-23 18:53:09, Zhang Yi wrote:
> On 2023/8/3 22:38, Jan Kara wrote:
> > On Tue 04-07-23 21:42:28, 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 zero, and also the leftover normal journal size should
> >> never less than JBD2_MIN_JOURNAL_BLOCKS. Add a check into the
> >> journal_check_superblock() and drop the pointless branch when
> >> initializing in-memory fastcommit parameters.
> >>
> >> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> >
> > Some comments below.
> >
> >
> >> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> >> index efdb8db3c06e..210b532a3673 100644
> >> --- a/fs/jbd2/journal.c
> >> +++ b/fs/jbd2/journal.c
> >> @@ -1392,6 +1392,18 @@ static int journal_check_superblock(journal_t *journal)
> >> return err;
> >> }
> >>
> >> + if (jbd2_has_feature_fast_commit(journal)) {
> >> + int num_fc_blks = be32_to_cpu(sb->s_num_fc_blks);
> >> +
> >> + if (!num_fc_blks ||
> >> + (be32_to_cpu(sb->s_maxlen) - num_fc_blks <
> >> + JBD2_MIN_JOURNAL_BLOCKS)) {
> >> + printk(KERN_ERR "JBD2: Invalid fast commit size %d\n",
> >> + num_fc_blks);
> >> + return err;
> >> + }
> >
> > This is wrong sb->s_num_fc_blks == 0 means that the fast-commit area should
> > have the default size of 256 blocks. At least that's how it behaves
> > currently and we should not change the behavior.
>
> Thanks for the review and correcting me. I missed the fc_debug_force
> mount option, this option enable fast commit feature without init
> sb->s_num_fc_blks to disk, so it could left over an unclean image with
> fast_commit feature but sb->s_num_fc_blks is still zero. And the mke2fs
> could also set sb->s_num_fc_blks to 0.
Yes.
> > Similarly if the number of fastcommit blocks was too big (i.e. there was
> > not enough space left for ordinary journal), we effectively silently
> > disable fastcommit and you break this behavior in this patch.
> >
>
> If the fastcommit is too big, jbd2_journal_initialize_fast_commit()
> will detect this corruption and refuse to mount.
>
> [ 1213.810719] JBD2: Cannot enable fast commits.
> [ 1213.812282] EXT4-fs (pmem1): Failed to set fast commit journal feature
>
> It only silently disable fastcommit while recovering the journal, but it
> doesn't seem to make much sense, because the journal->j_last is likely to
> be wrong (not point to the correct end of normal journal range) and will
> probably lead to incorrect recovery. It seems better to report the error
> and exit as early as possible. So I suppose we could keep this "too big"
> check in journal_check_superblock(). How does that sound ?
Ah, you are right. So let's keep the "space for journal too small" check as
you suggest.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-08-07 13:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 13:42 [PATCH 00/12] ext4,jbd2: cleanup journal load and initialization process Zhang Yi
2023-07-04 13:42 ` [PATCH 01/12] jbd2: move load_superblock() dependent functions Zhang Yi
2023-08-03 14:07 ` Jan Kara
2023-07-04 13:42 ` [PATCH 02/12] jbd2: move load_superblock() into journal_init_common() Zhang Yi
2023-08-03 14:13 ` Jan Kara
2023-07-04 13:42 ` [PATCH 03/12] jbd2: don't load superblock in jbd2_journal_check_used_features() Zhang Yi
2023-08-03 14:14 ` Jan Kara
2023-07-04 13:42 ` [PATCH 04/12] jbd2: checking valid features early in journal_get_superblock() Zhang Yi
2023-08-03 14:18 ` Jan Kara
2023-07-04 13:42 ` [PATCH 05/12] jbd2: open code jbd2_verify_csum_type() helper Zhang Yi
2023-08-03 14:19 ` Jan Kara
2023-07-04 13:42 ` [PATCH 06/12] jbd2: cleanup load_superblock() Zhang Yi
2023-08-03 14:28 ` Jan Kara
2023-07-04 13:42 ` [PATCH 07/12] jbd2: add fast_commit space check Zhang Yi
2023-08-03 14:38 ` Jan Kara
2023-08-07 10:53 ` Zhang Yi
2023-08-07 13:33 ` Jan Kara [this message]
2023-07-04 13:42 ` [PATCH 08/12] jbd2: cleanup journal_init_common() Zhang Yi
2023-08-03 15:48 ` Jan Kara
2023-07-04 13:42 ` [PATCH 09/12] jbd2: drop useless error tag in jbd2_journal_wipe() Zhang Yi
2023-08-03 15:49 ` Jan Kara
2023-07-04 13:42 ` [PATCH 10/12] jbd2: jbd2_journal_init_{dev,inode} return proper error return value Zhang Yi
2023-08-03 15:56 ` Jan Kara
2023-07-04 13:42 ` [PATCH 11/12] ext4: cleanup ext4_get_dev_journal() and ext4_get_journal() Zhang Yi
2023-08-03 16:14 ` Jan Kara
2023-08-07 11:36 ` Zhang Yi
2023-07-04 13:42 ` [PATCH 12/12] ext4: ext4_get_{dev}_journal return proper error value Zhang Yi
2023-08-03 16:19 ` Jan Kara
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=20230807133314.sjkpdrluvvzgpotx@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=chengzhihao1@huawei.com \
--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