@@ -1886,6 +1886,13 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1886
1886
}
1887
1887
sbi -> s_commit_interval = HZ * arg ;
1888
1888
} else if (token == Opt_debug_want_extra_isize ) {
1889
+ if ((arg & 1 ) ||
1890
+ (arg < 4 ) ||
1891
+ (arg > (sbi -> s_inode_size - EXT4_GOOD_OLD_INODE_SIZE ))) {
1892
+ ext4_msg (sb , KERN_ERR ,
1893
+ "Invalid want_extra_isize %d" , arg );
1894
+ return -1 ;
1895
+ }
1889
1896
sbi -> s_want_extra_isize = arg ;
1890
1897
} else if (token == Opt_max_batch_time ) {
1891
1898
sbi -> s_max_batch_time = arg ;
@@ -3540,40 +3547,6 @@ int ext4_calculate_overhead(struct super_block *sb)
3540
3547
return 0 ;
3541
3548
}
3542
3549
3543
- static void ext4_clamp_want_extra_isize (struct super_block * sb )
3544
- {
3545
- struct ext4_sb_info * sbi = EXT4_SB (sb );
3546
- struct ext4_super_block * es = sbi -> s_es ;
3547
- unsigned def_extra_isize = sizeof (struct ext4_inode ) -
3548
- EXT4_GOOD_OLD_INODE_SIZE ;
3549
-
3550
- if (sbi -> s_inode_size == EXT4_GOOD_OLD_INODE_SIZE ) {
3551
- sbi -> s_want_extra_isize = 0 ;
3552
- return ;
3553
- }
3554
- if (sbi -> s_want_extra_isize < 4 ) {
3555
- sbi -> s_want_extra_isize = def_extra_isize ;
3556
- if (ext4_has_feature_extra_isize (sb )) {
3557
- if (sbi -> s_want_extra_isize <
3558
- le16_to_cpu (es -> s_want_extra_isize ))
3559
- sbi -> s_want_extra_isize =
3560
- le16_to_cpu (es -> s_want_extra_isize );
3561
- if (sbi -> s_want_extra_isize <
3562
- le16_to_cpu (es -> s_min_extra_isize ))
3563
- sbi -> s_want_extra_isize =
3564
- le16_to_cpu (es -> s_min_extra_isize );
3565
- }
3566
- }
3567
- /* Check if enough inode space is available */
3568
- if ((sbi -> s_want_extra_isize > sbi -> s_inode_size ) ||
3569
- (EXT4_GOOD_OLD_INODE_SIZE + sbi -> s_want_extra_isize >
3570
- sbi -> s_inode_size )) {
3571
- sbi -> s_want_extra_isize = def_extra_isize ;
3572
- ext4_msg (sb , KERN_INFO ,
3573
- "required extra inode space not available" );
3574
- }
3575
- }
3576
-
3577
3550
static void ext4_set_resv_clusters (struct super_block * sb )
3578
3551
{
3579
3552
ext4_fsblk_t resv_clusters ;
@@ -3781,6 +3754,68 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3781
3754
*/
3782
3755
sbi -> s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT ;
3783
3756
3757
+ if (le32_to_cpu (es -> s_rev_level ) == EXT4_GOOD_OLD_REV ) {
3758
+ sbi -> s_inode_size = EXT4_GOOD_OLD_INODE_SIZE ;
3759
+ sbi -> s_first_ino = EXT4_GOOD_OLD_FIRST_INO ;
3760
+ } else {
3761
+ sbi -> s_inode_size = le16_to_cpu (es -> s_inode_size );
3762
+ sbi -> s_first_ino = le32_to_cpu (es -> s_first_ino );
3763
+ if (sbi -> s_first_ino < EXT4_GOOD_OLD_FIRST_INO ) {
3764
+ ext4_msg (sb , KERN_ERR , "invalid first ino: %u" ,
3765
+ sbi -> s_first_ino );
3766
+ goto failed_mount ;
3767
+ }
3768
+ if ((sbi -> s_inode_size < EXT4_GOOD_OLD_INODE_SIZE ) ||
3769
+ (!is_power_of_2 (sbi -> s_inode_size )) ||
3770
+ (sbi -> s_inode_size > blocksize )) {
3771
+ ext4_msg (sb , KERN_ERR ,
3772
+ "unsupported inode size: %d" ,
3773
+ sbi -> s_inode_size );
3774
+ goto failed_mount ;
3775
+ }
3776
+ /*
3777
+ * i_atime_extra is the last extra field available for
3778
+ * [acm]times in struct ext4_inode. Checking for that
3779
+ * field should suffice to ensure we have extra space
3780
+ * for all three.
3781
+ */
3782
+ if (sbi -> s_inode_size >= offsetof(struct ext4_inode , i_atime_extra ) +
3783
+ sizeof (((struct ext4_inode * )0 )-> i_atime_extra )) {
3784
+ sb -> s_time_gran = 1 ;
3785
+ sb -> s_time_max = EXT4_EXTRA_TIMESTAMP_MAX ;
3786
+ } else {
3787
+ sb -> s_time_gran = NSEC_PER_SEC ;
3788
+ sb -> s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX ;
3789
+ }
3790
+ sb -> s_time_min = EXT4_TIMESTAMP_MIN ;
3791
+ }
3792
+ if (sbi -> s_inode_size > EXT4_GOOD_OLD_INODE_SIZE ) {
3793
+ sbi -> s_want_extra_isize = sizeof (struct ext4_inode ) -
3794
+ EXT4_GOOD_OLD_INODE_SIZE ;
3795
+ if (ext4_has_feature_extra_isize (sb )) {
3796
+ unsigned v , max = (sbi -> s_inode_size -
3797
+ EXT4_GOOD_OLD_INODE_SIZE );
3798
+
3799
+ v = le16_to_cpu (es -> s_want_extra_isize );
3800
+ if (v > max ) {
3801
+ ext4_msg (sb , KERN_ERR ,
3802
+ "bad s_want_extra_isize: %d" , v );
3803
+ goto failed_mount ;
3804
+ }
3805
+ if (sbi -> s_want_extra_isize < v )
3806
+ sbi -> s_want_extra_isize = v ;
3807
+
3808
+ v = le16_to_cpu (es -> s_min_extra_isize );
3809
+ if (v > max ) {
3810
+ ext4_msg (sb , KERN_ERR ,
3811
+ "bad s_min_extra_isize: %d" , v );
3812
+ goto failed_mount ;
3813
+ }
3814
+ if (sbi -> s_want_extra_isize < v )
3815
+ sbi -> s_want_extra_isize = v ;
3816
+ }
3817
+ }
3818
+
3784
3819
if (sbi -> s_es -> s_mount_opts [0 ]) {
3785
3820
char * s_mount_opts = kstrndup (sbi -> s_es -> s_mount_opts ,
3786
3821
sizeof (sbi -> s_es -> s_mount_opts ),
@@ -4019,42 +4054,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
4019
4054
has_huge_files );
4020
4055
sb -> s_maxbytes = ext4_max_size (sb -> s_blocksize_bits , has_huge_files );
4021
4056
4022
- if (le32_to_cpu (es -> s_rev_level ) == EXT4_GOOD_OLD_REV ) {
4023
- sbi -> s_inode_size = EXT4_GOOD_OLD_INODE_SIZE ;
4024
- sbi -> s_first_ino = EXT4_GOOD_OLD_FIRST_INO ;
4025
- } else {
4026
- sbi -> s_inode_size = le16_to_cpu (es -> s_inode_size );
4027
- sbi -> s_first_ino = le32_to_cpu (es -> s_first_ino );
4028
- if (sbi -> s_first_ino < EXT4_GOOD_OLD_FIRST_INO ) {
4029
- ext4_msg (sb , KERN_ERR , "invalid first ino: %u" ,
4030
- sbi -> s_first_ino );
4031
- goto failed_mount ;
4032
- }
4033
- if ((sbi -> s_inode_size < EXT4_GOOD_OLD_INODE_SIZE ) ||
4034
- (!is_power_of_2 (sbi -> s_inode_size )) ||
4035
- (sbi -> s_inode_size > blocksize )) {
4036
- ext4_msg (sb , KERN_ERR ,
4037
- "unsupported inode size: %d" ,
4038
- sbi -> s_inode_size );
4039
- goto failed_mount ;
4040
- }
4041
- /*
4042
- * i_atime_extra is the last extra field available for [acm]times in
4043
- * struct ext4_inode. Checking for that field should suffice to ensure
4044
- * we have extra space for all three.
4045
- */
4046
- if (sbi -> s_inode_size >= offsetof(struct ext4_inode , i_atime_extra ) +
4047
- sizeof (((struct ext4_inode * )0 )-> i_atime_extra )) {
4048
- sb -> s_time_gran = 1 ;
4049
- sb -> s_time_max = EXT4_EXTRA_TIMESTAMP_MAX ;
4050
- } else {
4051
- sb -> s_time_gran = NSEC_PER_SEC ;
4052
- sb -> s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX ;
4053
- }
4054
-
4055
- sb -> s_time_min = EXT4_TIMESTAMP_MIN ;
4056
- }
4057
-
4058
4057
sbi -> s_desc_size = le16_to_cpu (es -> s_desc_size );
4059
4058
if (ext4_has_feature_64bit (sb )) {
4060
4059
if (sbi -> s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
@@ -4503,8 +4502,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
4503
4502
} else if (ret )
4504
4503
goto failed_mount4a ;
4505
4504
4506
- ext4_clamp_want_extra_isize (sb );
4507
-
4508
4505
ext4_set_resv_clusters (sb );
4509
4506
4510
4507
err = ext4_setup_system_zone (sb );
@@ -5292,8 +5289,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
5292
5289
goto restore_opts ;
5293
5290
}
5294
5291
5295
- ext4_clamp_want_extra_isize (sb );
5296
-
5297
5292
if ((old_opts .s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM ) ^
5298
5293
test_opt (sb , JOURNAL_CHECKSUM )) {
5299
5294
ext4_msg (sb , KERN_ERR , "changing journal_checksum "
0 commit comments