Commit 38478b24e37587f1c4fedf8ac070ca54f052ed28

Authored by Trond Myklebust
1 parent f1bb0b92ba

NFS: More page cache revalidation fixups

Whenever the directory changes, we want to make sure that we always
invalidate its page cache. Fix up update_changeattr() and
nfs_mark_for_revalidate() so that they do so.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 2 changed files with 10 additions and 6 deletions Side-by-side Diff

... ... @@ -185,15 +185,15 @@
185 185 spin_unlock(&clp->cl_lock);
186 186 }
187 187  
188   -static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinfo)
  188 +static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
189 189 {
190   - struct nfs_inode *nfsi = NFS_I(inode);
  190 + struct nfs_inode *nfsi = NFS_I(dir);
191 191  
192   - spin_lock(&inode->i_lock);
193   - nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
  192 + spin_lock(&dir->i_lock);
  193 + nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
194 194 if (cinfo->before == nfsi->change_attr && cinfo->atomic)
195 195 nfsi->change_attr = cinfo->after;
196   - spin_unlock(&inode->i_lock);
  196 + spin_unlock(&dir->i_lock);
197 197 }
198 198  
199 199 struct nfs4_opendata {
include/linux/nfs_fs.h
... ... @@ -234,8 +234,12 @@
234 234  
235 235 static inline void nfs_mark_for_revalidate(struct inode *inode)
236 236 {
  237 + struct nfs_inode *nfsi = NFS_I(inode);
  238 +
237 239 spin_lock(&inode->i_lock);
238   - NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS;
  240 + nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS;
  241 + if (S_ISDIR(inode->i_mode))
  242 + nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
239 243 spin_unlock(&inode->i_lock);
240 244 }
241 245