From: Linus Torvalds Date: Wed, 18 Oct 2017 18:51:50 +0000 (-0400) Subject: Merge tag 'xfs-4.14-fixes-6' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=73d3393ada4f70fa3df5639c8d438f2f034c0ecb;p=openwrt%2Fstaging%2Fblogic.git Merge tag 'xfs-4.14-fixes-6' of git://git./fs/xfs/xfs-linux Pull xfs fixes from Darrick Wong: - fix some more CONFIG_XFS_RT related build problems - fix data loss when writeback at eof races eofblocks gc and loses - invalidate page cache after fs finishes a dio write - remove dirty page state when invalidating pages so releasepage does the right thing when handed a dirty page * tag 'xfs-4.14-fixes-6' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: move two more RT specific functions into CONFIG_XFS_RT xfs: trim writepage mapping to within eof fs: invalidate page cache after end_io() in dio completion xfs: cancel dirty pages on invalidation --- 73d3393ada4f70fa3df5639c8d438f2f034c0ecb diff --cc fs/direct-io.c index 563254869e2f,19ac3fe57deb..b53e66d9abd7 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@@ -271,9 -272,13 +278,14 @@@ static ssize_t dio_complete(struct dio * of the write was an mmap'ed region of the file we're writing. Either * one is a pretty crazy thing to do, so we don't support it 100%. If * this invalidation fails, tough, the write still worked... + * + * And this page cache invalidation has to be after dio->end_io(), as + * some filesystems convert unwritten extents to real allocations in + * end_io() when necessary, otherwise a racing buffer read would cache + * zeros from unwritten extents. */ - if (ret > 0 && dio->op == REQ_OP_WRITE && + if (flags & DIO_COMPLETE_INVALIDATE && + ret > 0 && dio->op == REQ_OP_WRITE && dio->inode->i_mapping->nrpages) { err = invalidate_inode_pages2_range(dio->inode->i_mapping, offset >> PAGE_SHIFT,