diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-28 11:38:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-28 11:38:20 -0500 |
commit | 121b018f8c74b4e0ba81b4b8ee73a82db3f24b7b (patch) | |
tree | e24661e4183017aa0b4dcb40a6b035359e19f4ad /fs/btrfs/file.c | |
parent | 5b26f7180cdb3406404e6da78741e4e57f9a999e (diff) | |
parent | 42a657f57628402c73237547f0134e083e2f6764 (diff) |
Merge tag 'for-4.20-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba:
"Some of these bugs are being hit during testing so we'd like to get
them merged, otherwise there are usual stability fixes for stable
trees"
* tag 'for-4.20-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: relocation: set trans to be NULL after ending transaction
Btrfs: fix race between enabling quotas and subvolume creation
Btrfs: send, fix infinite loop due to directory rename dependencies
Btrfs: ensure path name is null terminated at btrfs_control_ioctl
Btrfs: fix rare chances for data loss when doing a fast fsync
btrfs: Always try all copies when reading extent buffers
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 24 |
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) | |||
2089 | atomic_inc(&root->log_batch); | 2089 | atomic_inc(&root->log_batch); |
2090 | 2090 | ||
2091 | /* | 2091 | /* |
2092 | * Before we acquired the inode's lock, someone may have dirtied more | ||
2093 | * pages in the target range. We need to make sure that writeback for | ||
2094 | * any such pages does not start while we are logging the inode, because | ||
2095 | * if it does, any of the following might happen when we are not doing a | ||
2096 | * full inode sync: | ||
2097 | * | ||
2098 | * 1) We log an extent after its writeback finishes but before its | ||
2099 | * checksums are added to the csum tree, leading to -EIO errors | ||
2100 | * when attempting to read the extent after a log replay. | ||
2101 | * | ||
2102 | * 2) We can end up logging an extent before its writeback finishes. | ||
2103 | * Therefore after the log replay we will have a file extent item | ||
2104 | * pointing to an unwritten extent (and no data checksums as well). | ||
2105 | * | ||
2106 | * So trigger writeback for any eventual new dirty pages and then we | ||
2107 | * wait for all ordered extents to complete below. | ||
2108 | */ | ||
2109 | ret = start_ordered_ops(inode, start, end); | ||
2110 | if (ret) { | ||
2111 | inode_unlock(inode); | ||
2112 | goto out; | ||
2113 | } | ||
2114 | |||
2115 | /* | ||
2092 | * We have to do this here to avoid the priority inversion of waiting on | 2116 | * We have to do this here to avoid the priority inversion of waiting on |
2093 | * IO of a lower priority task while holding a transaciton open. | 2117 | * IO of a lower priority task while holding a transaciton open. |
2094 | */ | 2118 | */ |