From: Trond Myklebust <trond.myklebust@primarydata.com>
Date: Sun, 28 Jan 2018 09:29:41 -0500
Subject: [PATCH] NFS: Fix a race between mmap() and O_DIRECT
Git-commit: e231c6879cfd44e4fffd384bb6dd7d313249a523
Patch-mainline: v4.16-rc1
References: git-fixes
When locking the file in order to do O_DIRECT on it, we must unmap
any mmapped ranges on the pagecache so that we can flush out the
dirty data.
Fixes: a5864c999de67 ("NFS: Do not serialise O_DIRECT reads and writes")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: stable@vger.kernel.org # v4.8+
Acked-by: NeilBrown <neilb@suse.com>
---
fs/nfs/io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/nfs/io.c
+++ b/fs/nfs/io.c
@@ -98,7 +98,7 @@ static void nfs_block_buffered(struct nf
{
if (!test_bit(NFS_INO_ODIRECT, &nfsi->flags)) {
set_bit(NFS_INO_ODIRECT, &nfsi->flags);
- nfs_wb_all(inode);
+ nfs_sync_mapping(inode->i_mapping);
}
}