diff mbox series

[v2,05/13] ext4: factor out ext4_fast_commit_init()

Message ID 20220903030156.770313-6-yanaijie@huawei.com
State Superseded
Headers show
Series some refactor of __ext4_fill_super() | expand

Commit Message

Jason Yan Sept. 3, 2022, 3:01 a.m. UTC
Factor out ext4_fast_commit_init(). No functional change.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/super.c | 43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)

Comments

Ritesh Harjani (IBM) Sept. 8, 2022, 8:45 a.m. UTC | #1
On 22/09/03 11:01AM, Jason Yan wrote:
> Factor out ext4_fast_commit_init(). No functional change.
> 
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
>  fs/ext4/super.c | 43 +++++++++++++++++++++++++------------------
>  1 file changed, 25 insertions(+), 18 deletions(-)

Nice cleanups. 

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 09b3c51d472b..3d58c2d889d5 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -4424,6 +4424,30 @@ static int ext4_handle_clustersize(struct super_block *sb, int blocksize)
>  	return 0;
>  }
>  
> +static void ext4_fast_commit_init(struct super_block *sb)
> +{
> +	struct ext4_sb_info *sbi = EXT4_SB(sb);
> +
> +	/* Initialize fast commit stuff */
> +	atomic_set(&sbi->s_fc_subtid, 0);
> +	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);
> +	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);
> +	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);
> +	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
> +	sbi->s_fc_bytes = 0;
> +	ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
> +	sbi->s_fc_ineligible_tid = 0;
> +	spin_lock_init(&sbi->s_fc_lock);
> +	memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
> +	sbi->s_fc_replay_state.fc_regions = NULL;
> +	sbi->s_fc_replay_state.fc_regions_size = 0;
> +	sbi->s_fc_replay_state.fc_regions_used = 0;
> +	sbi->s_fc_replay_state.fc_regions_valid = 0;
> +	sbi->s_fc_replay_state.fc_modified_inodes = NULL;
> +	sbi->s_fc_replay_state.fc_modified_inodes_size = 0;
> +	sbi->s_fc_replay_state.fc_modified_inodes_used = 0;
> +}
> +
>  static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
>  {
>  	struct buffer_head *bh, **group_desc;
> @@ -5059,24 +5083,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
>  	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
>  	mutex_init(&sbi->s_orphan_lock);
>  
> -	/* Initialize fast commit stuff */
> -	atomic_set(&sbi->s_fc_subtid, 0);
> -	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);
> -	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);
> -	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);
> -	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
> -	sbi->s_fc_bytes = 0;
> -	ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
> -	sbi->s_fc_ineligible_tid = 0;
> -	spin_lock_init(&sbi->s_fc_lock);
> -	memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
> -	sbi->s_fc_replay_state.fc_regions = NULL;
> -	sbi->s_fc_replay_state.fc_regions_size = 0;
> -	sbi->s_fc_replay_state.fc_regions_used = 0;
> -	sbi->s_fc_replay_state.fc_regions_valid = 0;
> -	sbi->s_fc_replay_state.fc_modified_inodes = NULL;
> -	sbi->s_fc_replay_state.fc_modified_inodes_size = 0;
> -	sbi->s_fc_replay_state.fc_modified_inodes_used = 0;
> +	ext4_fast_commit_init(sb);
>  
>  	sb->s_root = NULL;
>  
> -- 
> 2.31.1
>
diff mbox series

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 09b3c51d472b..3d58c2d889d5 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4424,6 +4424,30 @@  static int ext4_handle_clustersize(struct super_block *sb, int blocksize)
 	return 0;
 }
 
+static void ext4_fast_commit_init(struct super_block *sb)
+{
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+
+	/* Initialize fast commit stuff */
+	atomic_set(&sbi->s_fc_subtid, 0);
+	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);
+	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);
+	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);
+	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
+	sbi->s_fc_bytes = 0;
+	ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
+	sbi->s_fc_ineligible_tid = 0;
+	spin_lock_init(&sbi->s_fc_lock);
+	memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
+	sbi->s_fc_replay_state.fc_regions = NULL;
+	sbi->s_fc_replay_state.fc_regions_size = 0;
+	sbi->s_fc_replay_state.fc_regions_used = 0;
+	sbi->s_fc_replay_state.fc_regions_valid = 0;
+	sbi->s_fc_replay_state.fc_modified_inodes = NULL;
+	sbi->s_fc_replay_state.fc_modified_inodes_size = 0;
+	sbi->s_fc_replay_state.fc_modified_inodes_used = 0;
+}
+
 static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 {
 	struct buffer_head *bh, **group_desc;
@@ -5059,24 +5083,7 @@  static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
 	mutex_init(&sbi->s_orphan_lock);
 
-	/* Initialize fast commit stuff */
-	atomic_set(&sbi->s_fc_subtid, 0);
-	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);
-	INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);
-	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);
-	INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
-	sbi->s_fc_bytes = 0;
-	ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
-	sbi->s_fc_ineligible_tid = 0;
-	spin_lock_init(&sbi->s_fc_lock);
-	memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
-	sbi->s_fc_replay_state.fc_regions = NULL;
-	sbi->s_fc_replay_state.fc_regions_size = 0;
-	sbi->s_fc_replay_state.fc_regions_used = 0;
-	sbi->s_fc_replay_state.fc_regions_valid = 0;
-	sbi->s_fc_replay_state.fc_modified_inodes = NULL;
-	sbi->s_fc_replay_state.fc_modified_inodes_size = 0;
-	sbi->s_fc_replay_state.fc_modified_inodes_used = 0;
+	ext4_fast_commit_init(sb);
 
 	sb->s_root = NULL;