@@ -4007,12 +4007,12 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
4007
4007
4008
4008
/* If there are blocks to remove, do it */
4009
4009
if (stop_block > first_block ) {
4010
+ ext4_lblk_t hole_len = stop_block - first_block ;
4010
4011
4011
4012
down_write (& EXT4_I (inode )-> i_data_sem );
4012
4013
ext4_discard_preallocations (inode );
4013
4014
4014
- ext4_es_remove_extent (inode , first_block ,
4015
- stop_block - first_block );
4015
+ ext4_es_remove_extent (inode , first_block , hole_len );
4016
4016
4017
4017
if (ext4_test_inode_flag (inode , EXT4_INODE_EXTENTS ))
4018
4018
ret = ext4_ext_remove_space (inode , first_block ,
@@ -4021,6 +4021,8 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
4021
4021
ret = ext4_ind_remove_space (handle , inode , first_block ,
4022
4022
stop_block );
4023
4023
4024
+ ext4_es_insert_extent (inode , first_block , hole_len , ~0 ,
4025
+ EXTENT_STATUS_HOLE );
4024
4026
up_write (& EXT4_I (inode )-> i_data_sem );
4025
4027
}
4026
4028
ext4_fc_track_range (handle , inode , first_block , stop_block );
0 commit comments