Skip to content

Commit db9345d

Browse files
JasonYanHwtytso
authored andcommitted
ext4: factor out ext4_hash_info_init()
Factor out ext4_hash_info_init() to simplify __ext4_fill_super(). No functional change. Signed-off-by: Jason Yan <yanaijie@huawei.com> Link: https://lore.kernel.org/r/20230323140517.1070239-2-yanaijie@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent d0ab836 commit db9345d

1 file changed

Lines changed: 30 additions & 20 deletions

File tree

fs/ext4/super.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5024,6 +5024,35 @@ static int ext4_load_super(struct super_block *sb, ext4_fsblk_t *lsb,
50245024
return ret;
50255025
}
50265026

5027+
static void ext4_hash_info_init(struct super_block *sb)
5028+
{
5029+
struct ext4_sb_info *sbi = EXT4_SB(sb);
5030+
struct ext4_super_block *es = sbi->s_es;
5031+
unsigned int i;
5032+
5033+
for (i = 0; i < 4; i++)
5034+
sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
5035+
5036+
sbi->s_def_hash_version = es->s_def_hash_version;
5037+
if (ext4_has_feature_dir_index(sb)) {
5038+
i = le32_to_cpu(es->s_flags);
5039+
if (i & EXT2_FLAGS_UNSIGNED_HASH)
5040+
sbi->s_hash_unsigned = 3;
5041+
else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) {
5042+
#ifdef __CHAR_UNSIGNED__
5043+
if (!sb_rdonly(sb))
5044+
es->s_flags |=
5045+
cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH);
5046+
sbi->s_hash_unsigned = 3;
5047+
#else
5048+
if (!sb_rdonly(sb))
5049+
es->s_flags |=
5050+
cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
5051+
#endif
5052+
}
5053+
}
5054+
}
5055+
50275056
static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
50285057
{
50295058
struct ext4_super_block *es = NULL;
@@ -5179,26 +5208,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
51795208
sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
51805209
sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
51815210

5182-
for (i = 0; i < 4; i++)
5183-
sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
5184-
sbi->s_def_hash_version = es->s_def_hash_version;
5185-
if (ext4_has_feature_dir_index(sb)) {
5186-
i = le32_to_cpu(es->s_flags);
5187-
if (i & EXT2_FLAGS_UNSIGNED_HASH)
5188-
sbi->s_hash_unsigned = 3;
5189-
else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) {
5190-
#ifdef __CHAR_UNSIGNED__
5191-
if (!sb_rdonly(sb))
5192-
es->s_flags |=
5193-
cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH);
5194-
sbi->s_hash_unsigned = 3;
5195-
#else
5196-
if (!sb_rdonly(sb))
5197-
es->s_flags |=
5198-
cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
5199-
#endif
5200-
}
5201-
}
5211+
ext4_hash_info_init(sb);
52025212

52035213
if (ext4_handle_clustersize(sb))
52045214
goto failed_mount;

0 commit comments

Comments
 (0)