@@ -2099,9 +2099,14 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* extent completion for adjacent ranges, and assertion failures during
* hole detection. Do this while holding the inode lock, to avoid races
* with other tasks.
+ *
+ * Also set the range to full if the NO_HOLES feature is not enabled.
+ * This is to avoid missing file extent items representing holes after
+ * replaying the log.
*/
if (test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
- &BTRFS_I(inode)->runtime_flags)) {
+ &BTRFS_I(inode)->runtime_flags) ||
+ !btrfs_fs_incompat(fs_info, NO_HOLES)) {
start = 0;
end = LLONG_MAX;
}