On Wed, Oct 23, 2019 at 06:51:02PM +0200, David Sterba wrote: > On Fri, Oct 11, 2019 at 09:03:54AM -0400, Josef Bacik wrote: > > --- 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; > > + loff_t i_size = i_size_read(inode); > > int ret = 0; > > struct page **pages = NULL; > > unsigned long nr_pages; > > @@ -488,7 +489,13 @@ 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. > > + */ > > + actual_end = min_t(u64, i_size, end + 1); > > Ping. This is not a future proof fix, please update the changelog and > code according to the reply I sent. The vfs i_size_read patch is being ignored so I guess we're on our own. I have postponed last weeks pull request so I'll add this patch on top and send in a day or two. The READ_ONCE will be simulated by barrier()s, I've verified the assembly and actually that's alwo what read once does among other things.