From d487720ea8109a676955d8ff9d1f007d52bfa54f Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Tue, 5 Jun 2001 15:59:54 +0000 Subject: [PATCH] linux-dentry-cache-another-try-20010605 to fix a problem where invalid negative data is cached as well as some efficiency --- src/afs/LINUX/osi_vnodeops.c | 42 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index c13010992..8091be9f5 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -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); } -- 2.39.5