]> err.no Git - linux-2.6/blobdiff - fs/lockd/host.c
Merge branch 'audit.b32' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[linux-2.6] / fs / lockd / host.c
index a1423c66df04b4eb33cbe97f1c0ed150af799cfa..fb24a97303458f1b282f81111895c105e2c0399f 100644 (file)
@@ -103,8 +103,8 @@ nlm_lookup_host(int server, const struct sockaddr_in *sin,
                        continue;
 
                /* See if we have an NSM handle for this client */
-               if (!nsm && (nsm = host->h_nsmhandle) != 0)
-                       atomic_inc(&nsm->sm_count);
+               if (!nsm)
+                       nsm = host->h_nsmhandle;
 
                if (host->h_proto != proto)
                        continue;
@@ -120,6 +120,8 @@ nlm_lookup_host(int server, const struct sockaddr_in *sin,
                nlm_get_host(host);
                goto out;
        }
+       if (nsm)
+               atomic_inc(&nsm->sm_count);
 
        host = NULL;
 
@@ -436,7 +438,7 @@ nlm_gc_hosts(void)
  * Manage NSM handles
  */
 static LIST_HEAD(nsm_handles);
-static DECLARE_MUTEX(nsm_sema);
+static DEFINE_MUTEX(nsm_mutex);
 
 static struct nsm_handle *
 __nsm_find(const struct sockaddr_in *sin,
@@ -458,7 +460,7 @@ __nsm_find(const struct sockaddr_in *sin,
                return NULL;
        }
 
-       down(&nsm_sema);
+       mutex_lock(&nsm_mutex);
        list_for_each(pos, &nsm_handles) {
                nsm = list_entry(pos, struct nsm_handle, sm_link);
 
@@ -488,7 +490,8 @@ __nsm_find(const struct sockaddr_in *sin,
                list_add(&nsm->sm_link, &nsm_handles);
        }
 
-out:   up(&nsm_sema);
+out:
+       mutex_unlock(&nsm_mutex);
        return nsm;
 }
 
@@ -507,11 +510,11 @@ nsm_release(struct nsm_handle *nsm)
        if (!nsm)
                return;
        if (atomic_dec_and_test(&nsm->sm_count)) {
-               down(&nsm_sema);
+               mutex_lock(&nsm_mutex);
                if (atomic_read(&nsm->sm_count) == 0) {
                        list_del(&nsm->sm_link);
                        kfree(nsm);
                }
-               up(&nsm_sema);
+               mutex_unlock(&nsm_mutex);
        }
 }