diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-11 06:23:37 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-11 06:23:37 +0100 |
commit | f0cb9b5dfd1a6014349354e63768500a860cad53 (patch) | |
tree | b18478292c622b7cfbc4f49dc52e1f3816ac1b99 /fs/btrfs/inode.c | |
parent | b79967a27f347d39a6e0b85b49bd11963cacf5c1 (diff) | |
parent | 31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c (diff) | |
download | linux-f0cb9b5dfd1a6014349354e63768500a860cad53.tar.bz2 |
Merge 5.4-rc7 into staging-next
We want the staging fixes in here, and it resolves some merge issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c3f386b7cc0b..c6dc4dd16cf7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -474,6 +474,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk) u64 start = async_chunk->start; u64 end = async_chunk->end; u64 actual_end; + u64 i_size; int ret = 0; struct page **pages = NULL; unsigned long nr_pages; @@ -488,7 +489,19 @@ static noinline int compress_file_range(struct async_chunk *async_chunk) inode_should_defrag(BTRFS_I(inode), start, end, end - start + 1, SZ_16K); - actual_end = min_t(u64, i_size_read(inode), end + 1); + /* + * We need to save i_size before now because it could change in between + * us evaluating the size and assigning it. This is because we lock and + * unlock the page in truncate and fallocate, and then modify the i_size + * later on. + * + * The barriers are to emulate READ_ONCE, remove that once i_size_read + * does that for us. + */ + barrier(); + i_size = i_size_read(inode); + barrier(); + actual_end = min_t(u64, i_size, end + 1); again: will_compress = 0; nr_pages = (end >> PAGE_SHIFT) - (start >> PAGE_SHIFT) + 1; |