[OpenAFS-devel] the linux .__afsXXXX problem

chas williams chas@cmf.nrl.navy.mil
Fri, 05 Jul 2002 14:10:03 -0400


well i believe i see the problem.  some debugging shows that i_count 
doesnt seem to behave correctly for CUnlinked files:

afs_remove renamed unlinked file to .__afsCBD9
afs_remove marked d0ab6838 CUnlinked
osi_iput:  CUnlinked d0ab6838  ip->i_count = 2
osi_iput:  CUnlinked d0ab6838  ip->i_count = 2
osi_iput:  CUnlinked d0ab6838  ip->i_count = 2
osi_iput:  CUnlinked d0ab6838  ip->i_count = 3
osi_iput:  CUnlinked d0ab6838  ip->i_count = 3

i dont know what is incrementing i_count.  this could probably be
tracked down (and i will try to do that later), however a quick fix
seem to be afs_remunlink()'ing when afs_dentry_iput() is called. 
its my belief that afs_dentry_iput() is called when a dentry is
no longer in use  -- despite what i_count says.  something 
like the attached.  testers/comments/suggestions welcome.

Index: osi_vnodeops.c
===================================================================
RCS file: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v
retrieving revision 1.43
diff -u -d -b -w -r1.43 osi_vnodeops.c
--- osi_vnodeops.c	2002/06/30 06:39:12	1.43
+++ osi_vnodeops.c	2002/07/05 18:06:49
@@ -917,6 +917,17 @@
 /* afs_dentry_iput */
 static void afs_dentry_iput(struct dentry *dp, struct inode *ip)
 {
+    if ((ITOAFS(ip))->states & CUnlinked) {
+        printk("afs_dentry_iput:  %p CUnlinked %s i_count %d\n", ip, dp->d_name, atomic_read(&ip->i_count));
+
+        if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) {
+            avc->states |= CUnlinkedDel;
+        } else {
+            AFS_GLOCK();
+            afs_remunlink(avc, 1);
+            AFS_GUNLOCK();
+	}
+    }
     osi_iput(ip);
 }