@@ -59,6 +59,7 @@
#include "internal.h"
#include "iostat.h"
#include "pnfs.h"
+#include "fscache.h"
#define NFSDBG_FACILITY NFSDBG_VFS
@@ -967,6 +968,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
} else {
result = requested;
}
+ nfs_fscache_invalidate(inode, FSCACHE_INVAL_DIO_WRITE);
out_release:
nfs_direct_req_release(dreq);
out:
@@ -414,7 +414,7 @@ static void nfs_invalidate_page(struct page *page, unsigned int offset,
/* Cancel any unstarted writes on this page */
nfs_wb_page_cancel(page_file_mapping(page)->host, page);
wait_on_page_fscache(page);
- nfs_fscache_invalidate(page_file_mapping(page)->host);
+ nfs_fscache_invalidate(page_file_mapping(page)->host, 0);
}
/*
@@ -150,7 +150,7 @@ static inline void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *
/*
* Invalidate the contents of fscache for this inode. This will not sleep.
*/
-static inline void nfs_fscache_invalidate(struct inode *inode)
+static inline void nfs_fscache_invalidate(struct inode *inode, int flags)
{
struct nfs_fscache_inode_auxdata auxdata;
struct nfs_inode *nfsi = NFS_I(inode);
@@ -158,7 +158,7 @@ static inline void nfs_fscache_invalidate(struct inode *inode)
if (nfsi->fscache) {
nfs_fscache_update_auxdata(&auxdata, nfsi);
fscache_invalidate(nfsi->fscache, &auxdata,
- i_size_read(&nfsi->vfs_inode), 0);
+ i_size_read(&nfsi->vfs_inode), flags);
}
}
@@ -202,7 +202,7 @@ static inline int nfs_readpages_from_fscache(struct nfs_open_context *ctx,
static inline void nfs_read_completion_to_fscache(struct nfs_pgio_header *hdr,
unsigned long bytes) {}
-static inline void nfs_fscache_invalidate(struct inode *inode) {}
+static inline void nfs_fscache_invalidate(struct inode *inode, int flags) {}
static inline const char *nfs_server_fscache_state(struct nfs_server *server)
{
@@ -211,7 +211,7 @@ static void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
flags &= ~(NFS_INO_INVALID_DATA|NFS_INO_DATA_INVAL_DEFER);
nfsi->cache_validity |= flags;
if (flags & NFS_INO_INVALID_DATA)
- nfs_fscache_invalidate(inode);
+ nfs_fscache_invalidate(inode, 0);
}
/*
@@ -1179,7 +1179,7 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
nfsi->read_cache_jiffies = timestamp;
nfsi->attr_gencount = nfs_inc_attr_generation_counter();
nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE;
- nfs_fscache_invalidate(dir);
+ nfs_fscache_invalidate(dir, 0);
}
static void
@@ -290,7 +290,7 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
goto out;
i_size_write(inode, end);
NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_SIZE;
- nfs_fscache_invalidate(inode);
+ nfs_fscache_invalidate(inode, 0);
nfs_inc_stats(inode, NFSIOS_EXTENDWRITE);
out:
spin_unlock(&inode->i_lock);
We must call into fscache to invalidate when doing a direct write. This fixes issues seen with NFSv4.x when direct writes are followed by non-direct (buffered) reads. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> --- fs/nfs/direct.c | 2 ++ fs/nfs/file.c | 2 +- fs/nfs/fscache.h | 6 +++--- fs/nfs/inode.c | 2 +- fs/nfs/nfs4proc.c | 2 +- fs/nfs/write.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-)