From: Jan Kara <jack@suse.cz>
To: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com
Subject: Re: [PATCH 4/5] jbd2: factor out journal initialization from journal_get_superblock()
Date: Mon, 13 Mar 2023 12:12:53 +0100 [thread overview]
Message-ID: <20230313111253.2eoplgfhcgbaqri2@quack3> (raw)
In-Reply-To: <20230310125206.2867822-5-chengzhihao1@huawei.com>
On Fri 10-03-23 20:52:05, Zhihao Cheng wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> Current journal_get_superblock() couple journal superblock checking and
> partial journal initialization, factor out initialization part from it
> to make things clear.
>
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
> fs/jbd2/journal.c | 52 ++++++++++++++++++++---------------------------
> 1 file changed, 22 insertions(+), 30 deletions(-)
The patch looks mostly good. Just one style nit below.
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index b991d5c21d16..cd94d068b4e6 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -1921,26 +1921,15 @@ static int journal_get_superblock(journal_t *journal)
> printk(KERN_WARNING "JBD2: no valid journal superblock found\n");
> goto out;
> }
> -
> - switch(be32_to_cpu(sb->s_header.h_blocktype)) {
> - case JBD2_SUPERBLOCK_V1:
> - journal->j_format_version = 1;
> - break;
> - case JBD2_SUPERBLOCK_V2:
> - journal->j_format_version = 2;
> - break;
> - default:
> + if (be32_to_cpu(sb->s_header.h_blocktype) != JBD2_SUPERBLOCK_V1 &&
> + be32_to_cpu(sb->s_header.h_blocktype) != JBD2_SUPERBLOCK_V2) {
> printk(KERN_WARNING "JBD2: unrecognised superblock format ID\n");
> goto out;
> }
> -
> - if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len)
> - journal->j_total_len = be32_to_cpu(sb->s_maxlen);
> - else if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) {
> + if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) {
> printk(KERN_WARNING "JBD2: journal file too short\n");
> goto out;
> }
> -
Please keep this empty line here. It actually makes the code more readable,
separating logically different checks. Same with three empty lines below...
> if (be32_to_cpu(sb->s_first) == 0 ||
> be32_to_cpu(sb->s_first) >= journal->j_total_len) {
> printk(KERN_WARNING
> @@ -1956,7 +1945,6 @@ static int journal_get_superblock(journal_t *journal)
> "at the same time!\n");
> goto out;
> }
> -
> if (jbd2_journal_has_csum_v2or3_feature(journal) &&
> jbd2_has_feature_checksum(journal)) {
> /* Can't have checksum v1 and v2 on at the same time! */
> @@ -1964,12 +1952,10 @@ static int journal_get_superblock(journal_t *journal)
> "at the same time!\n");
> goto out;
> }
> -
> if (!jbd2_verify_csum_type(journal, sb)) {
> printk(KERN_ERR "JBD2: Unknown checksum type\n");
> goto out;
> }
> -
> /* Load the checksum driver */
> if (jbd2_journal_has_csum_v2or3_feature(journal)) {
> journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
Otherwise the patch looks good.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-03-13 11:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 12:52 [PATCH 0/5] ext4: Fix stale buffer loading from last failed Zhihao Cheng
2023-03-10 12:52 ` [PATCH 1/5] ext4: Fix reusing stale buffer heads from last failed mounting Zhihao Cheng
2023-03-13 10:51 ` Jan Kara
2023-03-13 12:43 ` Tudor Ambarus
2023-03-10 12:52 ` [PATCH 2/5] jbd2: remove unused feature macros Zhihao Cheng
2023-03-13 10:52 ` Jan Kara
2023-03-10 12:52 ` [PATCH 3/5] jbd2: switch to check format version in superblock directly Zhihao Cheng
2023-03-13 10:57 ` Jan Kara
2023-03-10 12:52 ` [PATCH 4/5] jbd2: factor out journal initialization from journal_get_superblock() Zhihao Cheng
2023-03-13 11:12 ` Jan Kara [this message]
2023-03-13 12:48 ` Zhang Yi
2023-03-10 12:52 ` [PATCH 5/5] jbd2: remove j_format_version Zhihao Cheng
2023-03-13 11:13 ` 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=20230313111253.2eoplgfhcgbaqri2@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=chengzhihao1@huawei.com \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yi.zhang@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