pNFS: Actively set attributes as invalid if LAYOUTCOMMIT is outstanding
[deliverable/linux.git] / fs / nfs / inode.c
index 0e0500f2bb6b76dea3a3acd80d85daa9a0144250..bf4ec5ecc97e4571e3f971222c71f0519874682a 100644 (file)
@@ -282,6 +282,7 @@ nfs_init_locked(struct inode *inode, void *opaque)
        struct nfs_fattr        *fattr = desc->fattr;
 
        set_nfs_fileid(inode, fattr->fileid);
+       inode->i_mode = fattr->mode;
        nfs_copy_fh(NFS_FH(inode), desc->fh);
        return 0;
 }
@@ -661,9 +662,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
        trace_nfs_getattr_enter(inode);
        /* Flush out writes to the server in order to update c/mtime.  */
        if (S_ISREG(inode->i_mode)) {
-               inode_lock(inode);
-               err = nfs_sync_inode(inode);
-               inode_unlock(inode);
+               err = filemap_write_and_wait(inode->i_mapping);
                if (err)
                        goto out;
        }
@@ -1214,6 +1213,11 @@ static bool nfs_file_has_writers(struct nfs_inode *nfsi)
                        list)->mode & FMODE_WRITE) == FMODE_WRITE;
 }
 
+static bool nfs_file_has_buffered_writers(struct nfs_inode *nfsi)
+{
+       return nfs_file_has_writers(nfsi) && nfs_file_io_is_buffered(nfsi);
+}
+
 static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
@@ -1278,7 +1282,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
        if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
                return -EIO;
 
-       if (!nfs_file_has_writers(nfsi)) {
+       if (!nfs_file_has_buffered_writers(nfsi)) {
                /* Verify a few of the more important attributes */
                if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && inode->i_version != fattr->change_attr)
                        invalid |= NFS_INO_INVALID_ATTR | NFS_INO_REVAL_PAGECACHE;
@@ -1660,7 +1664,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        unsigned long invalid = 0;
        unsigned long now = jiffies;
        unsigned long save_cache_validity;
-       bool have_writers = nfs_file_has_writers(nfsi);
+       bool have_writers = nfs_file_has_buffered_writers(nfsi);
        bool cache_revalidated = true;
 
        dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n",
@@ -1710,6 +1714,11 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        /* Do atomic weak cache consistency updates */
        invalid |= nfs_wcc_update_inode(inode, fattr);
 
+       if (pnfs_layoutcommit_outstanding(inode)) {
+               nfsi->cache_validity |= save_cache_validity & NFS_INO_INVALID_ATTR;
+               cache_revalidated = false;
+       }
+
        /* More cache consistency checks */
        if (fattr->valid & NFS_ATTR_FATTR_CHANGE) {
                if (inode->i_version != fattr->change_attr) {
This page took 0.158387 seconds and 5 git commands to generate.