Linux: use DEFINE_MUTEX for afs_linux_alloc_sem on newer kernels
authorAlejandro R. Sedeño <asedeno@mit.edu>
Fri, 5 Nov 2010 21:24:43 +0000 (17:24 -0400)
committerDerrick Brashear <shadow@dementia.org>
Tue, 9 Nov 2010 18:46:32 +0000 (10:46 -0800)
DECLARE_MUTEX is gone as of 2.6.37; afs_global_lock switches from
DECLARE_MUTEX to DEFINE_MUTEX at 2.6.16, so do the same here.

Change-Id: If2ea5e1d3b5406c631cade1128425b5be79ffd4a
Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Reviewed-on: http://gerrit.openafs.org/3273
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/afs/LINUX/osi_alloc.c

index 99256e4..7b9c929 100644 (file)
@@ -271,7 +271,11 @@ get_hash_stats(void)
 
 /************** Linux memory allocator interface functions **********/
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+DEFINE_MUTEX(afs_linux_alloc_sem);
+#else
 DECLARE_MUTEX(afs_linux_alloc_sem);
+#endif
 
 void *
 osi_linux_alloc(unsigned int asize, int drop_glock)
@@ -286,7 +290,7 @@ osi_linux_alloc(unsigned int asize, int drop_glock)
        return new;
     }
 
-    down(&afs_linux_alloc_sem);
+    mutex_lock(&afs_linux_alloc_sem);
 
     /* allocator hasn't been initialized yet */
     if (allocator_init == 0) {
@@ -316,7 +320,7 @@ osi_linux_alloc(unsigned int asize, int drop_glock)
        get_hash_stats();
     }
   error:
-    up(&afs_linux_alloc_sem);
+    mutex_unlock(&afs_linux_alloc_sem);
     return MEMADDR(new);
 
   free_error:
@@ -336,7 +340,7 @@ osi_linux_free(void *addr)
 {
     struct osi_linux_mem lmem, *lmp;
 
-    down(&afs_linux_alloc_sem);
+    mutex_lock(&afs_linux_alloc_sem);
 
     lmem.chunk = addr;
     /* remove this chunk from our hash table */
@@ -351,7 +355,7 @@ osi_linux_free(void *addr)
        BUG();
     }
 
-    up(&afs_linux_alloc_sem);
+    mutex_unlock(&afs_linux_alloc_sem);
 }
 
 /* osi_linux_free_afs_memory() - free all chunks of memory allocated.
@@ -359,7 +363,7 @@ osi_linux_free(void *addr)
 void
 osi_linux_free_afs_memory(void)
 {
-    down(&afs_linux_alloc_sem);
+    mutex_lock(&afs_linux_alloc_sem);
 
     if (allocator_init) {
        /* iterate through all elements in the hash table and free both 
@@ -376,7 +380,7 @@ osi_linux_free_afs_memory(void)
        /* change the state so that the allocator is now uninitialized. */
        allocator_init = 0;
     }
-    up(&afs_linux_alloc_sem);
+    mutex_unlock(&afs_linux_alloc_sem);
 }
 
 /* osi_linux_verify_alloced_memory(): verify all chunks of alloced memory in
@@ -385,7 +389,7 @@ osi_linux_free_afs_memory(void)
 void
 osi_linux_verify_alloced_memory()
 {
-    down(&afs_linux_alloc_sem);
+    mutex_lock(&afs_linux_alloc_sem);
 
     /* count of times hash_verify was called. reset it to 0 before iteration */
     afs_linux_hash_verify_count = 0;
@@ -400,7 +404,7 @@ osi_linux_verify_alloced_memory()
             afs_linux_hash_verify_count - afs_linux_cur_allocs);
     }
 
-    up(&afs_linux_alloc_sem);
+    mutex_unlock(&afs_linux_alloc_sem);
     return;
 }