]> Pileus Git - ~andy/linux/blobdiff - fs/lockd/host.c
Merge branch 'devel'
[~andy/linux] / fs / lockd / host.c
index 572601e98dcdec6d6d88da33ec0b757bd8b7d3f4..f23750db16508f96a31d45d1821e8e56b452868a 100644 (file)
@@ -34,18 +34,20 @@ static DEFINE_MUTEX(nlm_host_mutex);
 
 static void                    nlm_gc_hosts(void);
 static struct nsm_handle *     __nsm_find(const struct sockaddr_in *,
-                                       const char *, int, int);
+                                       const char *, unsigned int, int);
 static struct nsm_handle *     nsm_find(const struct sockaddr_in *sin,
                                         const char *hostname,
-                                        int hostname_len);
+                                        unsigned int hostname_len);
 
 /*
  * Common host lookup routine for server & client
  */
-static struct nlm_host *
-nlm_lookup_host(int server, const struct sockaddr_in *sin,
-               int proto, int version, const char *hostname,
-               int hostname_len, const struct sockaddr_in *ssin)
+static struct nlm_host *nlm_lookup_host(int server,
+                                       const struct sockaddr_in *sin,
+                                       int proto, u32 version,
+                                       const char *hostname,
+                                       unsigned int hostname_len,
+                                       const struct sockaddr_in *ssin)
 {
        struct hlist_head *chain;
        struct hlist_node *pos;
@@ -54,7 +56,7 @@ nlm_lookup_host(int server, const struct sockaddr_in *sin,
        int             hash;
 
        dprintk("lockd: nlm_lookup_host("NIPQUAD_FMT"->"NIPQUAD_FMT
-                       ", p=%d, v=%d, my role=%s, name=%.*s)\n",
+                       ", p=%d, v=%u, my role=%s, name=%.*s)\n",
                        NIPQUAD(ssin->sin_addr.s_addr),
                        NIPQUAD(sin->sin_addr.s_addr), proto, version,
                        server? "server" : "client",
@@ -174,9 +176,10 @@ nlm_destroy_host(struct nlm_host *host)
 /*
  * Find an NLM server handle in the cache. If there is none, create it.
  */
-struct nlm_host *
-nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
-                       const char *hostname, int hostname_len)
+struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin,
+                                    int proto, u32 version,
+                                    const char *hostname,
+                                    unsigned int hostname_len)
 {
        struct sockaddr_in ssin = {0};
 
@@ -189,7 +192,7 @@ nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
  */
 struct nlm_host *
 nlmsvc_lookup_host(struct svc_rqst *rqstp,
-                       const char *hostname, int hostname_len)
+                       const char *hostname, unsigned int hostname_len)
 {
        struct sockaddr_in ssin = {0};
 
@@ -242,10 +245,18 @@ nlm_bind_host(struct nlm_host *host)
                        .program        = &nlm_program,
                        .version        = host->h_version,
                        .authflavor     = RPC_AUTH_UNIX,
-                       .flags          = (RPC_CLNT_CREATE_HARDRTRY |
+                       .flags          = (RPC_CLNT_CREATE_NOPING |
                                           RPC_CLNT_CREATE_AUTOBIND),
                };
 
+               /*
+                * lockd retries server side blocks automatically so we want
+                * those to be soft RPC calls. Client side calls need to be
+                * hard RPC tasks.
+                */
+               if (!host->h_server)
+                       args.flags |= RPC_CLNT_CREATE_HARDRTRY;
+
                clnt = rpc_create(&args);
                if (!IS_ERR(clnt))
                        host->h_rpcclnt = clnt;
@@ -307,7 +318,8 @@ void nlm_release_host(struct nlm_host *host)
  * Release all resources held by that peer.
  */
 void nlm_host_rebooted(const struct sockaddr_in *sin,
-                               const char *hostname, int hostname_len,
+                               const char *hostname,
+                               unsigned int hostname_len,
                                u32 new_state)
 {
        struct hlist_head *chain;
@@ -377,8 +389,13 @@ nlm_shutdown_hosts(void)
        /* First, make all hosts eligible for gc */
        dprintk("lockd: nuking all hosts...\n");
        for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
-               hlist_for_each_entry(host, pos, chain, h_hash)
+               hlist_for_each_entry(host, pos, chain, h_hash) {
                        host->h_expires = jiffies - 1;
+                       if (host->h_rpcclnt) {
+                               rpc_shutdown_client(host->h_rpcclnt);
+                               host->h_rpcclnt = NULL;
+                       }
+               }
        }
 
        /* Then, perform a garbage collection pass */
@@ -449,7 +466,7 @@ static DEFINE_MUTEX(nsm_mutex);
 
 static struct nsm_handle *
 __nsm_find(const struct sockaddr_in *sin,
-               const char *hostname, int hostname_len,
+               const char *hostname, unsigned int hostname_len,
                int create)
 {
        struct nsm_handle *nsm = NULL;
@@ -503,7 +520,8 @@ out:
 }
 
 static struct nsm_handle *
-nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len)
+nsm_find(const struct sockaddr_in *sin, const char *hostname,
+        unsigned int hostname_len)
 {
        return __nsm_find(sin, hostname, hostname_len, 1);
 }