]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - fs/lockd/host.c
NLM: Fix "kernel BUG at fs/lockd/host.c:417!" or ".../host.c:283!"
[mv-sheeva.git] / fs / lockd / host.c
index 77ec21a808db4a440f99c05d14bc6b4800127926..b7c99bfb3da6dcb9897a85b201f1a2212b03bace 100644 (file)
@@ -53,8 +53,6 @@ struct nlm_lookup_host_info {
        const u32               version;        /* NLM version to search for */
        const char              *hostname;      /* remote's hostname */
        const size_t            hostname_len;   /* it's length */
-       const struct sockaddr   *src_sap;       /* our address (optional) */
-       const size_t            src_len;        /* it's length */
        const int               noresvport;     /* use non-priv port */
 };
 
@@ -162,75 +160,6 @@ out:
        return host;
 }
 
-/*
- * Common host lookup routine for server & client
- */
-static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
-{
-       struct hlist_head *chain;
-       struct hlist_node *pos;
-       struct nlm_host *host;
-       struct nsm_handle *nsm = NULL;
-
-       mutex_lock(&nlm_host_mutex);
-
-       if (time_after_eq(jiffies, next_gc))
-               nlm_gc_hosts();
-
-       /* We may keep several nlm_host objects for a peer, because each
-        * nlm_host is identified by
-        * (address, protocol, version, server/client)
-        * We could probably simplify this a little by putting all those
-        * different NLM rpc_clients into one single nlm_host object.
-        * This would allow us to have one nlm_host per address.
-        */
-       chain = &nlm_server_hosts[nlm_hash_address(ni->sap)];
-       hlist_for_each_entry(host, pos, chain, h_hash) {
-               if (!rpc_cmp_addr(nlm_addr(host), ni->sap))
-                       continue;
-
-               /* See if we have an NSM handle for this client */
-               if (!nsm)
-                       nsm = host->h_nsmhandle;
-
-               if (host->h_proto != ni->protocol)
-                       continue;
-               if (host->h_version != ni->version)
-                       continue;
-               if (host->h_server != ni->server)
-                       continue;
-               if (ni->server && ni->src_len != 0 &&
-                   !rpc_cmp_addr(nlm_srcaddr(host), ni->src_sap))
-                       continue;
-
-               /* Move to head of hash chain. */
-               hlist_del(&host->h_hash);
-               hlist_add_head(&host->h_hash, chain);
-
-               nlm_get_host(host);
-               dprintk("lockd: nlm_lookup_host found host %s (%s)\n",
-                               host->h_name, host->h_addrbuf);
-               goto out;
-       }
-
-       host = nlm_alloc_host(ni, nsm);
-       if (unlikely(host == NULL))
-               goto out;
-
-       memcpy(nlm_srcaddr(host), ni->src_sap, ni->src_len);
-       host->h_srcaddrlen = ni->src_len;
-       hlist_add_head(&host->h_hash, chain);
-
-       nrhosts++;
-
-       dprintk("lockd: nlm_lookup_host created host %s\n",
-                       host->h_name);
-
-out:
-       mutex_unlock(&nlm_host_mutex);
-       return host;
-}
-
 /*
  * Destroy an nlm_host and free associated resources
  *
@@ -393,6 +322,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
        struct sockaddr_in6 sin6 = {
                .sin6_family    = AF_INET6,
        };
+       struct sockaddr *src_sap;
+       size_t src_len = rqstp->rq_addrlen;
        struct nlm_lookup_host_info ni = {
                .server         = 1,
                .sap            = svc_addr(rqstp),
@@ -401,7 +332,6 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
                .version        = rqstp->rq_vers,
                .hostname       = hostname,
                .hostname_len   = hostname_len,
-               .src_len        = rqstp->rq_addrlen,
        };
 
        dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__,
@@ -413,11 +343,11 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
        switch (ni.sap->sa_family) {
        case AF_INET:
                sin.sin_addr.s_addr = rqstp->rq_daddr.addr.s_addr;
-               ni.src_sap = (struct sockaddr *)&sin;
+               src_sap = (struct sockaddr *)&sin;
                break;
        case AF_INET6:
                ipv6_addr_copy(&sin6.sin6_addr, &rqstp->rq_daddr.addr6);
-               ni.src_sap = (struct sockaddr *)&sin6;
+               src_sap = (struct sockaddr *)&sin6;
                break;
        default:
                dprintk("lockd: %s failed; unrecognized address family\n",
@@ -441,7 +371,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
                        continue;
                if (host->h_version != ni.version)
                        continue;
-               if (!rpc_cmp_addr(nlm_srcaddr(host), ni.src_sap))
+               if (!rpc_cmp_addr(nlm_srcaddr(host), src_sap))
                        continue;
 
                /* Move to head of hash chain. */
@@ -458,8 +388,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
        if (unlikely(host == NULL))
                goto out;
 
-       memcpy(nlm_srcaddr(host), ni.src_sap, ni.src_len);
-       host->h_srcaddrlen = ni.src_len;
+       memcpy(nlm_srcaddr(host), src_sap, src_len);
+       host->h_srcaddrlen = src_len;
        hlist_add_head(&host->h_hash, chain);
        nrhosts++;
 
@@ -590,7 +520,7 @@ static struct nlm_host *next_host_state(struct hlist_head *cache,
                                        struct nsm_handle *nsm,
                                        const struct nlm_reboot *info)
 {
-       struct nlm_host *host = NULL;
+       struct nlm_host *host;
        struct hlist_head *chain;
        struct hlist_node *pos;
 
@@ -603,12 +533,12 @@ static struct nlm_host *next_host_state(struct hlist_head *cache,
 
                        nlm_get_host(host);
                        mutex_unlock(&nlm_host_mutex);
-                       goto out;
+                       return host;
                }
        }
-out:
+
        mutex_unlock(&nlm_host_mutex);
-       return host;
+       return NULL;
 }
 
 /**