[OpenAFS-devel] locking for osi_clear_inode on linux

chas williams chas@cmf.nrl.navy.mil
Fri, 10 Aug 2001 07:12:26 -0400


i think this was missed from a patch i sent a while back to cleanup
the iput() of afs inodes.  i think the lock(vc->lock) needs to be in
osi_clear_inode() since osi_clear_inode is called a bit more often
than afs_delete_inode().  however, this like just might be uneeded
since no one has seen any problems apparently.

Index: osi_vfsops.c
===================================================================
RCS file: /afs/cmf/project/cvsroot/openafs/src/afs/LINUX/osi_vfsops.c,v
retrieving revision 1.1.1.5
retrieving revision 1.8
diff -u -r1.1.1.5 -r1.8
--- osi_vfsops.c	2001/07/28 17:06:16	1.1.1.5
+++ osi_vfsops.c	2001/07/28 20:43:42	1.8
@@ -244,9 +244,7 @@
     struct vcache *vc = (struct vcache*)ip;
 
     AFS_GLOCK();
-    ObtainWriteLock(&vc->lock, 504);
     osi_clear_inode(ip);
-    ReleaseWriteLock(&vc->lock);
     AFS_GUNLOCK();
 }
 
Index: osi_misc.c
===================================================================
RCS file: /afs/cmf/project/cvsroot/openafs/src/afs/LINUX/osi_misc.c,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 osi_misc.c
--- osi_misc.c	2001/07/28 17:06:14	1.1.1.6
+++ osi_misc.c	2001/08/10 10:59:28
@@ -338,7 +338,9 @@
 #endif
         printf("afs_put_inode: ino %d (0x%x) has count %d\n", ip->i_ino, ip);
 
+    ObtainWriteLock(&vc->lock, 504);
     afs_InactiveVCache(vc, credp);
+    ReleaseWriteLock(&vc->lock);
 #if defined(AFS_LINUX24_ENV)
     atomic_set(&ip->i_count, 0);
 #else
@@ -378,12 +380,10 @@
 	if (!ip->i_count)
 #endif
 	    osi_clear_inode(ip);
-        AFS_GUNLOCK();
     }
-    else { 
-        AFS_GUNLOCK();
+    else
 	iput(ip);
-    }
+    AFS_GUNLOCK();
 }
 
 /* check_bad_parent() : Checks if this dentry's vcache is a root vcache