All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Yan <yanaijie@huawei.com>
To: <tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
	<ritesh.list@gmail.com>, <lczerner@redhat.com>,
	<linux-ext4@vger.kernel.org>
Cc: Jason Yan <yanaijie@huawei.com>
Subject: [PATCH v2 06/13] ext4: factor out ext4_inode_info_init()
Date: Sat, 3 Sep 2022 11:01:49 +0800	[thread overview]
Message-ID: <20220903030156.770313-7-yanaijie@huawei.com> (raw)
In-Reply-To: <20220903030156.770313-1-yanaijie@huawei.com>

Factor out ext4_inode_info_init(). No functional change.

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

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3d58c2d889d5..f8806226b796 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4448,6 +4448,79 @@ static void ext4_fast_commit_init(struct super_block *sb)
 	sbi->s_fc_replay_state.fc_modified_inodes_used = 0;
 }
 
+static int ext4_inode_info_init(struct super_block *sb,
+				struct ext4_super_block *es,
+				int blocksize)
+{
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+
+	if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
+		sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
+		sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO;
+	} else {
+		sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
+		sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
+		if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) {
+			ext4_msg(sb, KERN_ERR, "invalid first ino: %u",
+				 sbi->s_first_ino);
+			return -EINVAL;
+		}
+		if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
+		    (!is_power_of_2(sbi->s_inode_size)) ||
+		    (sbi->s_inode_size > blocksize)) {
+			ext4_msg(sb, KERN_ERR,
+			       "unsupported inode size: %d",
+			       sbi->s_inode_size);
+			ext4_msg(sb, KERN_ERR, "blocksize: %d", blocksize);
+			return -EINVAL;
+		}
+		/*
+		 * i_atime_extra is the last extra field available for
+		 * [acm]times in struct ext4_inode. Checking for that
+		 * field should suffice to ensure we have extra space
+		 * for all three.
+		 */
+		if (sbi->s_inode_size >= offsetof(struct ext4_inode, i_atime_extra) +
+			sizeof(((struct ext4_inode *)0)->i_atime_extra)) {
+			sb->s_time_gran = 1;
+			sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX;
+		} else {
+			sb->s_time_gran = NSEC_PER_SEC;
+			sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX;
+		}
+		sb->s_time_min = EXT4_TIMESTAMP_MIN;
+	}
+
+	if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
+		sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
+			EXT4_GOOD_OLD_INODE_SIZE;
+		if (ext4_has_feature_extra_isize(sb)) {
+			unsigned v, max = (sbi->s_inode_size -
+					   EXT4_GOOD_OLD_INODE_SIZE);
+
+			v = le16_to_cpu(es->s_want_extra_isize);
+			if (v > max) {
+				ext4_msg(sb, KERN_ERR,
+					 "bad s_want_extra_isize: %d", v);
+				return -EINVAL;
+			}
+			if (sbi->s_want_extra_isize < v)
+				sbi->s_want_extra_isize = v;
+
+			v = le16_to_cpu(es->s_min_extra_isize);
+			if (v > max) {
+				ext4_msg(sb, KERN_ERR,
+					 "bad s_min_extra_isize: %d", v);
+				return -EINVAL;
+			}
+			if (sbi->s_want_extra_isize < v)
+				sbi->s_want_extra_isize = v;
+		}
+	}
+
+	return 0;
+}
+
 static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 {
 	struct buffer_head *bh, **group_desc;
@@ -4590,68 +4663,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	if (blocksize == PAGE_SIZE)
 		set_opt(sb, DIOREAD_NOLOCK);
 
-	if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
-		sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
-		sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO;
-	} else {
-		sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
-		sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
-		if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) {
-			ext4_msg(sb, KERN_ERR, "invalid first ino: %u",
-				 sbi->s_first_ino);
-			goto failed_mount;
-		}
-		if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
-		    (!is_power_of_2(sbi->s_inode_size)) ||
-		    (sbi->s_inode_size > blocksize)) {
-			ext4_msg(sb, KERN_ERR,
-			       "unsupported inode size: %d",
-			       sbi->s_inode_size);
-			ext4_msg(sb, KERN_ERR, "blocksize: %d", blocksize);
-			goto failed_mount;
-		}
-		/*
-		 * i_atime_extra is the last extra field available for
-		 * [acm]times in struct ext4_inode. Checking for that
-		 * field should suffice to ensure we have extra space
-		 * for all three.
-		 */
-		if (sbi->s_inode_size >= offsetof(struct ext4_inode, i_atime_extra) +
-			sizeof(((struct ext4_inode *)0)->i_atime_extra)) {
-			sb->s_time_gran = 1;
-			sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX;
-		} else {
-			sb->s_time_gran = NSEC_PER_SEC;
-			sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX;
-		}
-		sb->s_time_min = EXT4_TIMESTAMP_MIN;
-	}
-	if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
-		sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
-			EXT4_GOOD_OLD_INODE_SIZE;
-		if (ext4_has_feature_extra_isize(sb)) {
-			unsigned v, max = (sbi->s_inode_size -
-					   EXT4_GOOD_OLD_INODE_SIZE);
-
-			v = le16_to_cpu(es->s_want_extra_isize);
-			if (v > max) {
-				ext4_msg(sb, KERN_ERR,
-					 "bad s_want_extra_isize: %d", v);
-				goto failed_mount;
-			}
-			if (sbi->s_want_extra_isize < v)
-				sbi->s_want_extra_isize = v;
-
-			v = le16_to_cpu(es->s_min_extra_isize);
-			if (v > max) {
-				ext4_msg(sb, KERN_ERR,
-					 "bad s_min_extra_isize: %d", v);
-				goto failed_mount;
-			}
-			if (sbi->s_want_extra_isize < v)
-				sbi->s_want_extra_isize = v;
-		}
-	}
+	if (ext4_inode_info_init(sb, es, blocksize))
+		goto failed_mount;
 
 	err = parse_apply_sb_mount_options(sb, ctx);
 	if (err < 0)
-- 
2.31.1


  parent reply	other threads:[~2022-09-03  2:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-03  3:01 [PATCH v2 00/13] some refactor of __ext4_fill_super() Jason Yan
2022-09-03  3:01 ` [PATCH v2 01/13] ext4: goto right label 'failed_mount3a' Jason Yan
2022-09-08  8:39   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 02/13] ext4: remove cantfind_ext4 error handler Jason Yan
2022-09-08  8:40   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 03/13] ext4: factor out ext4_set_def_opts() Jason Yan
2022-09-08  8:44   ` Ritesh Harjani (IBM)
2022-09-12  2:20     ` Jason Yan
2022-09-03  3:01 ` [PATCH v2 04/13] ext4: factor out ext4_handle_clustersize() Jason Yan
2022-09-08  8:45   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 05/13] ext4: factor out ext4_fast_commit_init() Jason Yan
2022-09-08  8:45   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` Jason Yan [this message]
2022-09-08  8:46   ` [PATCH v2 06/13] ext4: factor out ext4_inode_info_init() Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 07/13] ext4: factor out ext4_encoding_init() Jason Yan
2022-09-08  8:56   ` Ritesh Harjani (IBM)
2022-09-12  2:30     ` Jason Yan
2022-09-12  3:12       ` Jason Yan
2022-09-03  3:01 ` [PATCH v2 08/13] ext4: factor out ext4_init_metadata_csum() Jason Yan
2022-09-08  8:57   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 09/13] ext4: factor out ext4_check_feature_compatibility() Jason Yan
2022-09-08  8:58   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 10/13] ext4: factor out ext4_geometry_check() Jason Yan
2022-09-08  9:00   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 11/13] ext4: factor out ext4_group_desc_init() and ext4_group_desc_free() Jason Yan
2022-09-08  9:03   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 12/13] ext4: factor out ext4_load_and_init_journal() Jason Yan
2022-09-08  9:04   ` Ritesh Harjani (IBM)
2022-09-03  3:01 ` [PATCH v2 13/13] ext4: factor out ext4_journal_data_mode_check() Jason Yan
2022-09-08  9:06   ` Ritesh Harjani (IBM)

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=20220903030156.770313-7-yanaijie@huawei.com \
    --to=yanaijie@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.