@@ -4007,12 +4007,12 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
40074007
40084008 /* If there are blocks to remove, do it */
40094009 if (stop_block > first_block ) {
4010+ ext4_lblk_t hole_len = stop_block - first_block ;
40104011
40114012 down_write (& EXT4_I (inode )-> i_data_sem );
40124013 ext4_discard_preallocations (inode );
40134014
4014- ext4_es_remove_extent (inode , first_block ,
4015- stop_block - first_block );
4015+ ext4_es_remove_extent (inode , first_block , hole_len );
40164016
40174017 if (ext4_test_inode_flag (inode , EXT4_INODE_EXTENTS ))
40184018 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)
40214021 ret = ext4_ind_remove_space (handle , inode , first_block ,
40224022 stop_block );
40234023
4024+ ext4_es_insert_extent (inode , first_block , hole_len , ~0 ,
4025+ EXTENT_STATUS_HOLE );
40244026 up_write (& EXT4_I (inode )-> i_data_sem );
40254027 }
40264028 ext4_fc_track_range (handle , inode , first_block , stop_block );
0 commit comments