]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4: factor out ext4_hash_info_init()
authorJason Yan <yanaijie@huawei.com>
Thu, 8 Jan 2026 15:04:28 +0000 (12:04 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:12 +0000 (13:10 +0100)
commit db9345d9e6f075e1ec26afadf744078ead935fec upstream.

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>
Stable-dep-of: a2187431c395 ("ext4: fix error message when rejecting the default hash")
[cascardo: conflicts due to other parts of ext4_fill_super having been factored out]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/super.c

index 9a061c75030546bfc6839ea7a505db6dba79e0ae..b2f892e3b1afb7ceb25a97b583106d117229465b 100644 (file)
@@ -3897,6 +3897,35 @@ static void ext4_setup_csum_trigger(struct super_block *sb,
        sbi->s_journal_triggers[type].tr_triggers.t_frozen = trigger;
 }
 
+static void ext4_hash_info_init(struct super_block *sb)
+{
+       struct ext4_sb_info *sbi = EXT4_SB(sb);
+       struct ext4_super_block *es = sbi->s_es;
+       unsigned int i;
+
+       for (i = 0; i < 4; i++)
+               sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
+
+       sbi->s_def_hash_version = es->s_def_hash_version;
+       if (ext4_has_feature_dir_index(sb)) {
+               i = le32_to_cpu(es->s_flags);
+               if (i & EXT2_FLAGS_UNSIGNED_HASH)
+                       sbi->s_hash_unsigned = 3;
+               else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) {
+#ifdef __CHAR_UNSIGNED__
+                       if (!sb_rdonly(sb))
+                               es->s_flags |=
+                                       cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH);
+                       sbi->s_hash_unsigned = 3;
+#else
+                       if (!sb_rdonly(sb))
+                               es->s_flags |=
+                                       cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
+#endif
+               }
+       }
+}
+
 static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 {
        struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev);
@@ -4415,26 +4444,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
        sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
        sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
 
-       for (i = 0; i < 4; i++)
-               sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
-       sbi->s_def_hash_version = es->s_def_hash_version;
-       if (ext4_has_feature_dir_index(sb)) {
-               i = le32_to_cpu(es->s_flags);
-               if (i & EXT2_FLAGS_UNSIGNED_HASH)
-                       sbi->s_hash_unsigned = 3;
-               else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) {
-#ifdef __CHAR_UNSIGNED__
-                       if (!sb_rdonly(sb))
-                               es->s_flags |=
-                                       cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH);
-                       sbi->s_hash_unsigned = 3;
-#else
-                       if (!sb_rdonly(sb))
-                               es->s_flags |=
-                                       cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
-#endif
-               }
-       }
+       ext4_hash_info_init(sb);
 
        /* Handle clustersize */
        clustersize = BLOCK_SIZE << le32_to_cpu(es->s_log_cluster_size);