diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 8aa8d7fe74d7c529c7a10a7f2deedbe89ac0e168..cfc0ab915d0329bbac509f7390994019c546dc8c 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1497,14 +1497,15 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) trace_btrfs_sync_file(file, datasync); - ret = filemap_write_and_wait_range(inode->i_mapping, start, end); - if (ret) - return ret; mutex_lock(&inode->i_mutex); - /* we wait first, since the writeback may change the inode */ + /* + * we wait first, since the writeback may change the inode, also wait + * ordered range does a filemape_write_and_wait_range which is why we + * don't do it above like other file systems. + */ root->log_batch++; - btrfs_wait_ordered_range(inode, 0, (u64)-1); + btrfs_wait_ordered_range(inode, start, end); root->log_batch++; /*