[OpenAFS-devel] OpenAFS Memcache patch for Linux 2.4

Derek Atkins warlord@MIT.EDU
07 Mar 2002 14:15:12 -0500


I got memcache working on Linux 2.4.  It's quite literally a two-line
fix to get it to work.  The first patch (to osi_misc.c) is the actual
memcache fix.  The second patch (to osi_alloc.c) is already in the
openafs sources, but I include it here for the bugs@mit people.

The problem is that on 2.4 the 'code' variable is over-written during
the path walk, such that by the time it's checking if the inode
exists, code is already '0'.  But if the inode does not exist, code
should be ENOENT to show that the file does not exist.

-derek

Index: src/afs/LINUX/osi_misc.c
===================================================================
RCS file: /afs/dev.mit.edu/source/repository/third/openafs/src/afs/LINUX/osi_misc.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 osi_misc.c
--- osi_misc.c	2002/01/31 21:34:03	1.1.1.1
+++ osi_misc.c	2002/03/07 18:48:44
@@ -51,7 +51,8 @@
 	if (nd.dentry->d_inode) {
 	    *dpp = dget(nd.dentry);
 	    code = 0;
-	}
+	} else
+	  code = ENOENT;
 	path_release(&nd);
     }
 #else

Index: src/afs/LINUX/osi_alloc.c
===================================================================
RCS file: /afs/dev.mit.edu/source/repository/third/openafs/src/afs/LINUX/osi_alloc.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 osi_alloc.c
--- osi_alloc.c	2002/01/31 21:33:25	1.1.1.1
+++ osi_alloc.c	2002/03/06 04:32:28
@@ -290,7 +290,9 @@
 	allocator_init = 1; /* initialization complete */
     }
 
+    up(&afs_linux_alloc_sem);
     new = linux_alloc(asize); /* get a chunk of memory of size asize */
+    down(&afs_linux_alloc_sem);
     if (!new) {
 	printf("afs_osi_Alloc: Can't vmalloc %d bytes.\n", asize);
 	goto error;
@@ -320,8 +322,11 @@
     return MEMADDR(new);
 
   free_error:
-    if (new)
+    if (new) {
+        up(&afs_linux_alloc_sem);
         linux_free(new);
+	down(&afs_linux_alloc_sem);
+    }
     new = NULL;
     goto error;
 
-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available