linux-dentry-cache-another-try-20010605
authorChas Williams <chas@cmf.nrl.navy.mil>
Tue, 5 Jun 2001 15:59:54 +0000 (15:59 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 5 Jun 2001 15:59:54 +0000 (15:59 +0000)
to fix a problem where invalid negative data is cached as well as some efficiency

src/afs/LINUX/osi_vnodeops.c

index c130109..8091be9 100644 (file)
@@ -687,8 +687,27 @@ static int afs_linux_dentry_revalidate(struct dentry *dp, int flags)
 static int afs_linux_dentry_revalidate(struct dentry *dp)
 #endif
 {
-    /* Force revalidation as this may be a different client than the
-       one which caused an entry to get cached */
+    int code;
+    cred_t *credp;
+    struct vrequest treq;
+    struct inode *ip = (struct inode *)dp->d_inode;
+    
+    unsigned long timeout = 3*HZ; /* 3 seconds */
+    
+    if (!(flags & LOOKUP_CONTINUE)) {
+       long diff = CURRENT_TIME - dp->d_parent->d_inode->i_mtime;
+       
+       if (diff < 15*60)
+           timeout = 0;
+    }
+    
+    if (time_after(jiffies, dp->d_time + timeout))
+       goto out_bad;
+    
+ out_valid:
+    return 1;
+    
+ out_bad:
     return 0;
 }
 
@@ -769,9 +788,7 @@ int afs_linux_create(struct inode *dip, struct dentry *dp, int mode)
 #endif
 
        dp->d_op = afs_dops;
-        /* This DV is probably wrong, unfortunately, Perhaps we should 
-           VerifyVCache the directory  */
-        dp->d_time=hgetlo(((struct vcache *)dip)->m.DataVersion);
+       dp->d_time = jiffies;
        d_instantiate(dp, ip);
     }
 
@@ -818,8 +835,7 @@ int afs_linux_lookup(struct inode *dip, struct dentry *dp)
            ip->i_op = &afs_symlink_iops;
 #endif
     }
-    /* directory ought to be stat'd here.... */
-    dp->d_time=hgetlo(((struct vcache *)dip)->m.DataVersion);
+    dp->d_time = jiffies;
     dp->d_op = afs_dops;
     d_add(dp, (struct inode*)vcp);
 
@@ -886,9 +902,7 @@ int afs_linux_unlink(struct inode *dip, struct dentry *dp)
     if (!code) {
        d_delete(dp);
        if (putback) {
-           /* This DV is probably wrong, unfortunately, Perhaps we should 
-              VerifyVCache the directory  */
-            dp->d_time=hgetlo(((struct vcache *)dip)->m.DataVersion);
+           dp->d_time = jiffies;
            d_add(dp, NULL); /* means definitely does _not_ exist */
     }
     }
@@ -938,9 +952,7 @@ int afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode)
        tvcp->v.v_fop = &afs_dir_fops;
 #endif
        dp->d_op = afs_dops;
-        /* This DV is probably wrong, unfortunately, Perhaps we should 
-           VerifyVCache the directory  */
-        dp->d_time=hgetlo(((struct vcache *)dip)->m.DataVersion);
+       dp->d_time = jiffies;
        d_instantiate(dp, (struct inode*)tvcp);
     }
     AFS_GUNLOCK();
@@ -1002,9 +1014,7 @@ int afs_linux_rename(struct inode *oldip, struct dentry *olddp,
 
     if (!code) {
         /* update time so it doesn't expire immediately */
-        /* This DV is probably wrong, unfortunately, Perhaps we should 
-           VerifyVCache the directory  */
-        newdp->d_time=hgetlo(((struct vcache *)newdp->d_parent->d_inode)->m.DataVersion);
+       newdp->d_time = jiffies;
        d_move(olddp, newdp);
     }