aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-03 07:53:39 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-03 07:53:39 +0100
commit44c94100b6fa83488337fe639eb7baba7dd93a91 (patch)
treeffc60bdfe3a3f2f20359d2a7df8389f3ecf51d82 /fs/btrfs/file.c
parent77df6d8d7298fd3fae12a646fd368fdcdb86152c (diff)
parent2595646791c319cadfdbf271563aac97d0843dc7 (diff)
downloadkernel_replicant_linux-44c94100b6fa83488337fe639eb7baba7dd93a91.tar.gz
kernel_replicant_linux-44c94100b6fa83488337fe639eb7baba7dd93a91.tar.bz2
kernel_replicant_linux-44c94100b6fa83488337fe639eb7baba7dd93a91.zip
Merge 4.20-rc5 into usb-next
We need the USB fixes into usb-next. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a3c22e16509b..58e93bce3036 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2089,6 +2089,30 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
atomic_inc(&root->log_batch);
/*
+ * Before we acquired the inode's lock, someone may have dirtied more
+ * pages in the target range. We need to make sure that writeback for
+ * any such pages does not start while we are logging the inode, because
+ * if it does, any of the following might happen when we are not doing a
+ * full inode sync:
+ *
+ * 1) We log an extent after its writeback finishes but before its
+ * checksums are added to the csum tree, leading to -EIO errors
+ * when attempting to read the extent after a log replay.
+ *
+ * 2) We can end up logging an extent before its writeback finishes.
+ * Therefore after the log replay we will have a file extent item
+ * pointing to an unwritten extent (and no data checksums as well).
+ *
+ * So trigger writeback for any eventual new dirty pages and then we
+ * wait for all ordered extents to complete below.
+ */
+ ret = start_ordered_ops(inode, start, end);
+ if (ret) {
+ inode_unlock(inode);
+ goto out;
+ }
+
+ /*
* We have to do this here to avoid the priority inversion of waiting on
* IO of a lower priority task while holding a transaciton open.
*/