@@ -4852,9 +4852,8 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
4852
4852
return ERR_PTR (ret );
4853
4853
}
4854
4854
4855
- static int ext4_inode_blocks_set (handle_t * handle ,
4856
- struct ext4_inode * raw_inode ,
4857
- struct ext4_inode_info * ei )
4855
+ static int ext4_inode_blocks_set (struct ext4_inode * raw_inode ,
4856
+ struct ext4_inode_info * ei )
4858
4857
{
4859
4858
struct inode * inode = & (ei -> vfs_inode );
4860
4859
u64 i_blocks = READ_ONCE (inode -> i_blocks );
@@ -4957,37 +4956,16 @@ static void ext4_update_other_inodes_time(struct super_block *sb,
4957
4956
rcu_read_unlock ();
4958
4957
}
4959
4958
4960
- /*
4961
- * Post the struct inode info into an on-disk inode location in the
4962
- * buffer-cache. This gobbles the caller's reference to the
4963
- * buffer_head in the inode location struct.
4964
- *
4965
- * The caller must have write access to iloc->bh.
4966
- */
4967
- static int ext4_do_update_inode (handle_t * handle ,
4968
- struct inode * inode ,
4969
- struct ext4_iloc * iloc )
4959
+ static int ext4_fill_raw_inode (struct inode * inode , struct ext4_inode * raw_inode )
4970
4960
{
4971
- struct ext4_inode * raw_inode = ext4_raw_inode (iloc );
4972
4961
struct ext4_inode_info * ei = EXT4_I (inode );
4973
- struct buffer_head * bh = iloc -> bh ;
4974
- struct super_block * sb = inode -> i_sb ;
4975
- int err = 0 , block ;
4976
- int need_datasync = 0 , set_large_file = 0 ;
4977
4962
uid_t i_uid ;
4978
4963
gid_t i_gid ;
4979
4964
projid_t i_projid ;
4965
+ int block ;
4966
+ int err ;
4980
4967
4981
- spin_lock (& ei -> i_raw_lock );
4982
-
4983
- /*
4984
- * For fields not tracked in the in-memory inode, initialise them
4985
- * to zero for new inodes.
4986
- */
4987
- if (ext4_test_inode_state (inode , EXT4_STATE_NEW ))
4988
- memset (raw_inode , 0 , EXT4_SB (inode -> i_sb )-> s_inode_size );
4989
-
4990
- err = ext4_inode_blocks_set (handle , raw_inode , ei );
4968
+ err = ext4_inode_blocks_set (raw_inode , ei );
4991
4969
4992
4970
raw_inode -> i_mode = cpu_to_le16 (inode -> i_mode );
4993
4971
i_uid = i_uid_read (inode );
@@ -5029,16 +5007,8 @@ static int ext4_do_update_inode(handle_t *handle,
5029
5007
raw_inode -> i_file_acl_high =
5030
5008
cpu_to_le16 (ei -> i_file_acl >> 32 );
5031
5009
raw_inode -> i_file_acl_lo = cpu_to_le32 (ei -> i_file_acl );
5032
- if (READ_ONCE (ei -> i_disksize ) != ext4_isize (inode -> i_sb , raw_inode )) {
5033
- ext4_isize_set (raw_inode , ei -> i_disksize );
5034
- need_datasync = 1 ;
5035
- }
5036
- if (ei -> i_disksize > 0x7fffffffULL ) {
5037
- if (!ext4_has_feature_large_file (sb ) ||
5038
- EXT4_SB (sb )-> s_es -> s_rev_level ==
5039
- cpu_to_le32 (EXT4_GOOD_OLD_REV ))
5040
- set_large_file = 1 ;
5041
- }
5010
+ ext4_isize_set (raw_inode , ei -> i_disksize );
5011
+
5042
5012
raw_inode -> i_generation = cpu_to_le32 (inode -> i_generation );
5043
5013
if (S_ISCHR (inode -> i_mode ) || S_ISBLK (inode -> i_mode )) {
5044
5014
if (old_valid_dev (inode -> i_rdev )) {
@@ -5078,6 +5048,45 @@ static int ext4_do_update_inode(handle_t *handle,
5078
5048
raw_inode -> i_projid = cpu_to_le32 (i_projid );
5079
5049
5080
5050
ext4_inode_csum_set (inode , raw_inode , ei );
5051
+ return err ;
5052
+ }
5053
+
5054
+ /*
5055
+ * Post the struct inode info into an on-disk inode location in the
5056
+ * buffer-cache. This gobbles the caller's reference to the
5057
+ * buffer_head in the inode location struct.
5058
+ *
5059
+ * The caller must have write access to iloc->bh.
5060
+ */
5061
+ static int ext4_do_update_inode (handle_t * handle ,
5062
+ struct inode * inode ,
5063
+ struct ext4_iloc * iloc )
5064
+ {
5065
+ struct ext4_inode * raw_inode = ext4_raw_inode (iloc );
5066
+ struct ext4_inode_info * ei = EXT4_I (inode );
5067
+ struct buffer_head * bh = iloc -> bh ;
5068
+ struct super_block * sb = inode -> i_sb ;
5069
+ int err ;
5070
+ int need_datasync = 0 , set_large_file = 0 ;
5071
+
5072
+ spin_lock (& ei -> i_raw_lock );
5073
+
5074
+ /*
5075
+ * For fields not tracked in the in-memory inode, initialise them
5076
+ * to zero for new inodes.
5077
+ */
5078
+ if (ext4_test_inode_state (inode , EXT4_STATE_NEW ))
5079
+ memset (raw_inode , 0 , EXT4_SB (inode -> i_sb )-> s_inode_size );
5080
+
5081
+ if (READ_ONCE (ei -> i_disksize ) != ext4_isize (inode -> i_sb , raw_inode ))
5082
+ need_datasync = 1 ;
5083
+ if (ei -> i_disksize > 0x7fffffffULL ) {
5084
+ if (!ext4_has_feature_large_file (sb ) ||
5085
+ EXT4_SB (sb )-> s_es -> s_rev_level == cpu_to_le32 (EXT4_GOOD_OLD_REV ))
5086
+ set_large_file = 1 ;
5087
+ }
5088
+
5089
+ err = ext4_fill_raw_inode (inode , raw_inode );
5081
5090
spin_unlock (& ei -> i_raw_lock );
5082
5091
if (err ) {
5083
5092
EXT4_ERROR_INODE (inode , "corrupted inode contents" );
0 commit comments