]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/lockd/host.c
V4L/DVB (4729): Fix VIDIOC_G_FMT for NTSC in cx25840.
[linux-2.6-omap-h63xx.git] / fs / lockd / host.c
index 1bf384307d15ee1833f0498b7f119271d23144fc..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,11 +460,15 @@ __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);
 
-               if (!nlm_cmp_addr(&nsm->sm_addr, sin))
+               if (hostname && nsm_use_hostnames) {
+                       if (strlen(nsm->sm_name) != hostname_len
+                        || memcmp(nsm->sm_name, hostname, hostname_len))
+                               continue;
+               } else if (!nlm_cmp_addr(&nsm->sm_addr, sin))
                        continue;
                atomic_inc(&nsm->sm_count);
                goto out;
@@ -484,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;
 }
 
@@ -503,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);
        }
 }