aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2016-06-25 17:24:46 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2016-07-05 19:11:06 -0400
commit651b0e702981304f77091b82870a01480705f4fe (patch)
tree27c5134920cb995716b419e9b6a4635e03b639c9 /fs/nfs
parentbe527494e02b89e03485955b30de6c1e976a07eb (diff)
NFS: Do not aggressively cache file attributes in the case of O_DIRECT
A file that is open for O_DIRECT is by definition not obeying close-to-open cache consistency semantics, so let's not cache the attributes too aggressively either. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/inode.c9
-rw-r--r--fs/nfs/internal.h5
2 files changed, 12 insertions, 2 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 0e0500f2bb6b..7688436b19ba 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1214,6 +1214,11 @@ static bool nfs_file_has_writers(struct nfs_inode *nfsi)
1214 list)->mode & FMODE_WRITE) == FMODE_WRITE; 1214 list)->mode & FMODE_WRITE) == FMODE_WRITE;
1215} 1215}
1216 1216
1217static bool nfs_file_has_buffered_writers(struct nfs_inode *nfsi)
1218{
1219 return nfs_file_has_writers(nfsi) && nfs_file_io_is_buffered(nfsi);
1220}
1221
1217static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) 1222static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1218{ 1223{
1219 struct nfs_inode *nfsi = NFS_I(inode); 1224 struct nfs_inode *nfsi = NFS_I(inode);
@@ -1278,7 +1283,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
1278 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) 1283 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
1279 return -EIO; 1284 return -EIO;
1280 1285
1281 if (!nfs_file_has_writers(nfsi)) { 1286 if (!nfs_file_has_buffered_writers(nfsi)) {
1282 /* Verify a few of the more important attributes */ 1287 /* Verify a few of the more important attributes */
1283 if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && inode->i_version != fattr->change_attr) 1288 if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && inode->i_version != fattr->change_attr)
1284 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_REVAL_PAGECACHE; 1289 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_REVAL_PAGECACHE;
@@ -1660,7 +1665,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1660 unsigned long invalid = 0; 1665 unsigned long invalid = 0;
1661 unsigned long now = jiffies; 1666 unsigned long now = jiffies;
1662 unsigned long save_cache_validity; 1667 unsigned long save_cache_validity;
1663 bool have_writers = nfs_file_has_writers(nfsi); 1668 bool have_writers = nfs_file_has_buffered_writers(nfsi);
1664 bool cache_revalidated = true; 1669 bool cache_revalidated = true;
1665 1670
1666 dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n", 1671 dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n",
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 159b64ede82a..01dccf18da0a 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -419,6 +419,11 @@ extern void nfs_end_io_write(struct inode *inode);
419extern void nfs_start_io_direct(struct inode *inode); 419extern void nfs_start_io_direct(struct inode *inode);
420extern void nfs_end_io_direct(struct inode *inode); 420extern void nfs_end_io_direct(struct inode *inode);
421 421
422static inline bool nfs_file_io_is_buffered(struct nfs_inode *nfsi)
423{
424 return test_bit(NFS_INO_ODIRECT, &nfsi->flags) == 0;
425}
426
422/* namespace.c */ 427/* namespace.c */
423#define NFS_PATH_CANONICAL 1 428#define NFS_PATH_CANONICAL 1
424extern char *nfs_path(char **p, struct dentry *dentry, 429extern char *nfs_path(char **p, struct dentry *dentry,