Commit d7cf8dd01289b3c64057e38d34c2857f6633d52c

Authored by Trond Myklebust
1 parent a8ce4a8f37

NFSv4: Allow attribute caching with 'noac' mounts if client holds a delegation

If the server has given us a delegation on a file, we _know_ that we can
cache the attribute information even when the user has specified 'noac'.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 2 changed files with 18 additions and 9 deletions Side-by-side Diff

... ... @@ -161,14 +161,17 @@
161 161 struct nfs_server *server = NFS_SERVER(inode);
162 162 struct nfs_inode *nfsi = NFS_I(inode);
163 163  
164   - if (server->flags & NFS_MOUNT_NOAC)
165   - goto force_reval;
  164 + if (nfs_have_delegated_attributes(inode))
  165 + goto out_noreval;
  166 +
166 167 if (filp->f_flags & O_DIRECT)
167 168 goto force_reval;
168   - if (nfsi->npages != 0)
169   - return 0;
170   - if (!(nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode))
171   - return 0;
  169 + if (nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE)
  170 + goto force_reval;
  171 + if (nfs_attribute_timeout(inode))
  172 + goto force_reval;
  173 +out_noreval:
  174 + return 0;
172 175 force_reval:
173 176 return __nfs_revalidate_inode(server, inode);
174 177 }
... ... @@ -742,9 +742,14 @@
742 742 {
743 743 struct nfs_inode *nfsi = NFS_I(inode);
744 744  
  745 + return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
  746 +}
  747 +
  748 +static int nfs_attribute_cache_expired(struct inode *inode)
  749 +{
745 750 if (nfs_have_delegated_attributes(inode))
746 751 return 0;
747   - return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
  752 + return nfs_attribute_timeout(inode);
748 753 }
749 754  
750 755 /**
... ... @@ -757,7 +762,7 @@
757 762 int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
758 763 {
759 764 if (!(NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATTR)
760   - && !nfs_attribute_timeout(inode))
  765 + && !nfs_attribute_cache_expired(inode))
761 766 return NFS_STALE(inode) ? -ESTALE : 0;
762 767 return __nfs_revalidate_inode(server, inode);
763 768 }
... ... @@ -794,7 +799,8 @@
794 799 int ret = 0;
795 800  
796 801 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE)
797   - || nfs_attribute_timeout(inode) || NFS_STALE(inode)) {
  802 + || nfs_attribute_cache_expired(inode)
  803 + || NFS_STALE(inode)) {
798 804 ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
799 805 if (ret < 0)
800 806 goto out;