kernel - Fix global counter used in lockf assertions
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 18 Nov 2010 17:20:23 +0000 (09:20 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 18 Nov 2010 17:45:33 +0000 (09:45 -0800)
* lockf elements can be accessed MP.

* This may fix the 'panic: assertion: lf_global_counter>=0 in lf_destroy_range'
  panic.

Reported-by: Peter Avalos <peter@theshell.com>
sys/kern/kern_lockf.c

index f660b20..33cecf0 100644 (file)
@@ -812,7 +812,7 @@ lf_alloc_range(void)
        struct lockf_range *range;
 
 #ifdef INVARIANTS
        struct lockf_range *range;
 
 #ifdef INVARIANTS
-       lf_global_counter++;
+       atomic_add_int(&lf_global_counter, 1);
 #endif
        range = kmalloc(sizeof(struct lockf_range), M_LOCKF, M_WAITOK);
        range->lf_owner = NULL;
 #endif
        range = kmalloc(sizeof(struct lockf_range), M_LOCKF, M_WAITOK);
        range->lf_owner = NULL;
@@ -853,8 +853,8 @@ lf_destroy_range(struct lockf_range *range)
                  range->lf_start, range->lf_end);
        kfree(range, M_LOCKF);
 #ifdef INVARIANTS
                  range->lf_start, range->lf_end);
        kfree(range, M_LOCKF);
 #ifdef INVARIANTS
-       lf_global_counter--;
-       KKASSERT(lf_global_counter>=0);
+       atomic_add_int(&lf_global_counter, -1);
+       KKASSERT(lf_global_counter >= 0);
 #endif
 }
 
 #endif
 }