From: Jan Kara <jack@suse.cz>
To: Jason Yan <yanaijie@huawei.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
ritesh.list@gmail.com, lczerner@redhat.com,
linux-ext4@vger.kernel.org
Subject: Re: [PATCH 12/13] ext4: factor out ext4_load_and_init_journal()
Date: Wed, 31 Aug 2022 14:05:09 +0200 [thread overview]
Message-ID: <20220831120509.4whig2d6yii7nkxc@quack3> (raw)
In-Reply-To: <20220830120411.2371968-13-yanaijie@huawei.com>
On Tue 30-08-22 20:04:10, Jason Yan wrote:
> This patch group the journal load and initialize code together and
> factor out ext4_load_and_init_journal(). This patch also removes the
> lable 'no_journal' which is not needed after refactor.
>
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/super.c | 157 +++++++++++++++++++++++++++---------------------
> 1 file changed, 88 insertions(+), 69 deletions(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 40f155543df0..95e70f0316db 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -4823,6 +4823,93 @@ static int ext4_group_desc_init(struct super_block *sb,
> return ret;
> }
>
> +static int ext4_load_and_init_journal(struct super_block *sb,
> + struct ext4_super_block *es,
> + struct ext4_fs_context *ctx)
> +{
> + struct ext4_sb_info *sbi = EXT4_SB(sb);
> + int err;
> +
> + err = ext4_load_journal(sb, es, ctx->journal_devnum);
> + if (err)
> + return err;
> +
> + if (ext4_has_feature_64bit(sb) &&
> + !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
> + JBD2_FEATURE_INCOMPAT_64BIT)) {
> + ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature");
> + goto out;
> + }
> +
> + if (!set_journal_csum_feature_set(sb)) {
> + ext4_msg(sb, KERN_ERR, "Failed to set journal checksum "
> + "feature set");
> + goto out;
> + }
> +
> + if (test_opt2(sb, JOURNAL_FAST_COMMIT) &&
> + !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
> + JBD2_FEATURE_INCOMPAT_FAST_COMMIT)) {
> + ext4_msg(sb, KERN_ERR,
> + "Failed to set fast commit journal feature");
> + goto out;
> + }
> +
> + /* We have now updated the journal if required, so we can
> + * validate the data journaling mode. */
> + switch (test_opt(sb, DATA_FLAGS)) {
> + case 0:
> + /* No mode set, assume a default based on the journal
> + * capabilities: ORDERED_DATA if the journal can
> + * cope, else JOURNAL_DATA
> + */
> + if (jbd2_journal_check_available_features
> + (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
> + set_opt(sb, ORDERED_DATA);
> + sbi->s_def_mount_opt |= EXT4_MOUNT_ORDERED_DATA;
> + } else {
> + set_opt(sb, JOURNAL_DATA);
> + sbi->s_def_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
> + }
> + break;
> +
> + case EXT4_MOUNT_ORDERED_DATA:
> + case EXT4_MOUNT_WRITEBACK_DATA:
> + if (!jbd2_journal_check_available_features
> + (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
> + ext4_msg(sb, KERN_ERR, "Journal does not support "
> + "requested data journaling mode");
> + goto out;
> + }
> + break;
> + default:
> + break;
> + }
> +
> + if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA &&
> + test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
> + ext4_msg(sb, KERN_ERR, "can't mount with "
> + "journal_async_commit in data=ordered mode");
> + goto out;
> + }
> +
> + set_task_ioprio(sbi->s_journal->j_task, ctx->journal_ioprio);
> +
> + sbi->s_journal->j_submit_inode_data_buffers =
> + ext4_journal_submit_inode_data_buffers;
> + sbi->s_journal->j_finish_inode_data_buffers =
> + ext4_journal_finish_inode_data_buffers;
> +
> + return 0;
> +
> +out:
> + /* flush s_error_work before journal destroy. */
> + flush_work(&sbi->s_error_work);
> + jbd2_journal_destroy(sbi->s_journal);
> + sbi->s_journal = NULL;
> + return err;
> +}
> +
> static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
> {
> struct buffer_head *bh;
> @@ -5182,7 +5269,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
> * root first: it may be modified in the journal!
> */
> if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) {
> - err = ext4_load_journal(sb, es, ctx->journal_devnum);
> + err = ext4_load_and_init_journal(sb, es, ctx);
> if (err)
> goto failed_mount3a;
> } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) &&
> @@ -5220,76 +5307,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
> clear_opt2(sb, JOURNAL_FAST_COMMIT);
> sbi->s_journal = NULL;
> needs_recovery = 0;
> - goto no_journal;
> }
>
> - if (ext4_has_feature_64bit(sb) &&
> - !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
> - JBD2_FEATURE_INCOMPAT_64BIT)) {
> - ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature");
> - goto failed_mount_wq;
> - }
> -
> - if (!set_journal_csum_feature_set(sb)) {
> - ext4_msg(sb, KERN_ERR, "Failed to set journal checksum "
> - "feature set");
> - goto failed_mount_wq;
> - }
> -
> - if (test_opt2(sb, JOURNAL_FAST_COMMIT) &&
> - !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
> - JBD2_FEATURE_INCOMPAT_FAST_COMMIT)) {
> - ext4_msg(sb, KERN_ERR,
> - "Failed to set fast commit journal feature");
> - goto failed_mount_wq;
> - }
> -
> - /* We have now updated the journal if required, so we can
> - * validate the data journaling mode. */
> - switch (test_opt(sb, DATA_FLAGS)) {
> - case 0:
> - /* No mode set, assume a default based on the journal
> - * capabilities: ORDERED_DATA if the journal can
> - * cope, else JOURNAL_DATA
> - */
> - if (jbd2_journal_check_available_features
> - (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
> - set_opt(sb, ORDERED_DATA);
> - sbi->s_def_mount_opt |= EXT4_MOUNT_ORDERED_DATA;
> - } else {
> - set_opt(sb, JOURNAL_DATA);
> - sbi->s_def_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
> - }
> - break;
> -
> - case EXT4_MOUNT_ORDERED_DATA:
> - case EXT4_MOUNT_WRITEBACK_DATA:
> - if (!jbd2_journal_check_available_features
> - (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
> - ext4_msg(sb, KERN_ERR, "Journal does not support "
> - "requested data journaling mode");
> - goto failed_mount_wq;
> - }
> - break;
> - default:
> - break;
> - }
> -
> - if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA &&
> - test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
> - ext4_msg(sb, KERN_ERR, "can't mount with "
> - "journal_async_commit in data=ordered mode");
> - goto failed_mount_wq;
> - }
> -
> - set_task_ioprio(sbi->s_journal->j_task, ctx->journal_ioprio);
> -
> - sbi->s_journal->j_submit_inode_data_buffers =
> - ext4_journal_submit_inode_data_buffers;
> - sbi->s_journal->j_finish_inode_data_buffers =
> - ext4_journal_finish_inode_data_buffers;
> -
> -no_journal:
> if (!test_opt(sb, NO_MBCACHE)) {
> sbi->s_ea_block_cache = ext4_xattr_create_cache();
> if (!sbi->s_ea_block_cache) {
> --
> 2.31.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2022-08-31 12:05 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 12:03 [PATCH 00/13] some refactor of __ext4_fill_super() Jason Yan
2022-08-30 12:03 ` [PATCH 01/13] ext4: goto right label 'failed_mount3a' Jason Yan
2022-08-31 11:36 ` Jan Kara
2022-08-30 12:04 ` [PATCH 02/13] ext4: remove cantfind_ext4 error handler Jason Yan
2022-08-31 11:41 ` Jan Kara
2022-09-01 7:42 ` Jason Yan
2022-08-30 12:04 ` [PATCH 03/13] ext4: factor out ext4_set_def_opts() Jason Yan
2022-08-31 11:44 ` Jan Kara
2022-08-30 12:04 ` [PATCH 04/13] ext4: factor out ext4_handle_clustersize() Jason Yan
2022-08-31 11:46 ` Jan Kara
2022-08-30 12:04 ` [PATCH 05/13] ext4: factor out ext4_fast_commit_init() Jason Yan
2022-08-31 11:47 ` Jan Kara
2022-08-30 12:04 ` [PATCH 06/13] ext4: factor out ext4_inode_info_init() Jason Yan
2022-08-31 11:49 ` Jan Kara
2022-08-30 12:04 ` [PATCH 07/13] ext4: factor out ext4_encoding_init() Jason Yan
2022-08-31 11:50 ` Jan Kara
2022-08-30 12:04 ` [PATCH 08/13] ext4: factor out ext4_handle_csum() Jason Yan
2022-08-31 11:52 ` Jan Kara
2022-09-01 7:56 ` Jason Yan
2022-08-30 12:04 ` [PATCH 09/13] ext4: factor out ext4_compat_feature_check() Jason Yan
2022-08-31 11:55 ` Jan Kara
2022-09-01 7:58 ` Jason Yan
2022-08-30 12:04 ` [PATCH 10/13] ext4: factor out ext4_geometry_check() Jason Yan
2022-08-31 11:57 ` Jan Kara
2022-08-30 12:04 ` [PATCH 11/13] ext4: factor out ext4_group_desc_init() and ext4_group_desc_free() Jason Yan
2022-08-31 12:00 ` Jan Kara
2022-08-30 12:04 ` [PATCH 12/13] ext4: factor out ext4_load_and_init_journal() Jason Yan
2022-08-31 12:05 ` Jan Kara [this message]
2022-08-30 12:04 ` [PATCH 13/13] ext4: factor out ext4_journal_data_check() Jason Yan
2022-08-31 12:06 ` Jan Kara
2022-09-01 7:59 ` Jason Yan
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=20220831120509.4whig2d6yii7nkxc@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yanaijie@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).