diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 42634658815fdfce6c68ca02830d5226810a3a8d..864c08d08a353452edc957e75932cb91b2c19538 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2730,8 +2730,6 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode, extent_info->file_offset += replace_len; } - cur_offset = drop_args.drop_end; - ret = btrfs_update_inode(trans, root, inode); if (ret) break; @@ -2751,7 +2749,9 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode, BUG_ON(ret); /* shouldn't happen */ trans->block_rsv = rsv; - if (!extent_info) { + cur_offset = drop_args.drop_end; + len = end - cur_offset; + if (!extent_info && len) { ret = find_first_non_hole(inode, &cur_offset, &len); if (unlikely(ret < 0)) break;