git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git]
/
fs
/
lockd
/
host.c
diff --git
a/fs/lockd/host.c
b/fs/lockd/host.c
index
fc4f414
..
729ac42
100644
(file)
--- a/
fs/lockd/host.c
+++ b/
fs/lockd/host.c
@@
-16,6
+16,7
@@
#include <linux/sunrpc/svc.h>
#include <linux/lockd/lockd.h>
#include <linux/lockd/sm_inter.h>
#include <linux/sunrpc/svc.h>
#include <linux/lockd/lockd.h>
#include <linux/lockd/sm_inter.h>
+#include <linux/mutex.h>
#define NLMDBG_FACILITY NLMDBG_HOSTCACHE
#define NLMDBG_FACILITY NLMDBG_HOSTCACHE
@@
-30,7
+31,7
@@
static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH];
static unsigned long next_gc;
static int nrhosts;
static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH];
static unsigned long next_gc;
static int nrhosts;
-static DE
CLARE_MUTEX(nlm_host_sema
);
+static DE
FINE_MUTEX(nlm_host_mutex
);
static void nlm_gc_hosts(void);
static void nlm_gc_hosts(void);
@@
-71,7
+72,7
@@
nlm_lookup_host(int server, struct sockaddr_in *sin,
hash = NLM_ADDRHASH(sin->sin_addr.s_addr);
/* Lock hash table */
hash = NLM_ADDRHASH(sin->sin_addr.s_addr);
/* Lock hash table */
-
down(&nlm_host_sema
);
+
mutex_lock(&nlm_host_mutex
);
if (time_after_eq(jiffies, next_gc))
nlm_gc_hosts();
if (time_after_eq(jiffies, next_gc))
nlm_gc_hosts();
@@
-91,7
+92,7
@@
nlm_lookup_host(int server, struct sockaddr_in *sin,
nlm_hosts[hash] = host;
}
nlm_get_host(host);
nlm_hosts[hash] = host;
}
nlm_get_host(host);
-
up(&nlm_host_sema
);
+
mutex_unlock(&nlm_host_mutex
);
return host;
}
}
return host;
}
}
@@
-104,17
+105,12
@@
nlm_lookup_host(int server, struct sockaddr_in *sin,
memset(host, 0, sizeof(*host));
addr = sin->sin_addr.s_addr;
memset(host, 0, sizeof(*host));
addr = sin->sin_addr.s_addr;
- sprintf(host->h_name, "%d.%d.%d.%d",
- (unsigned char) (ntohl(addr) >> 24),
- (unsigned char) (ntohl(addr) >> 16),
- (unsigned char) (ntohl(addr) >> 8),
- (unsigned char) (ntohl(addr) >> 0));
+ sprintf(host->h_name, "%u.%u.%u.%u", NIPQUAD(addr));
host->h_addr = *sin;
host->h_addr.sin_port = 0; /* ouch! */
host->h_version = version;
host->h_proto = proto;
host->h_addr = *sin;
host->h_addr.sin_port = 0; /* ouch! */
host->h_version = version;
host->h_proto = proto;
- host->h_authflavor = RPC_AUTH_UNIX;
host->h_rpcclnt = NULL;
init_MUTEX(&host->h_sema);
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
host->h_rpcclnt = NULL;
init_MUTEX(&host->h_sema);
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
@@
-128,12
+124,14
@@
nlm_lookup_host(int server, struct sockaddr_in *sin,
nlm_hosts[hash] = host;
INIT_LIST_HEAD(&host->h_lockowners);
spin_lock_init(&host->h_lock);
nlm_hosts[hash] = host;
INIT_LIST_HEAD(&host->h_lockowners);
spin_lock_init(&host->h_lock);
+ INIT_LIST_HEAD(&host->h_granted);
+ INIT_LIST_HEAD(&host->h_reclaim);
if (++nrhosts > NLM_HOST_MAX)
next_gc = 0;
nohost:
if (++nrhosts > NLM_HOST_MAX)
next_gc = 0;
nohost:
-
up(&nlm_host_sema
);
+
mutex_unlock(&nlm_host_mutex
);
return host;
}
return host;
}
@@
-144,19
+142,19
@@
nlm_find_client(void)
* and return it
*/
int hash;
* and return it
*/
int hash;
-
down(&nlm_host_sema
);
+
mutex_lock(&nlm_host_mutex
);
for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) {
struct nlm_host *host, **hp;
for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) {
if (host->h_server &&
host->h_killed == 0) {
nlm_get_host(host);
for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) {
struct nlm_host *host, **hp;
for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) {
if (host->h_server &&
host->h_killed == 0) {
nlm_get_host(host);
-
up(&nlm_host_sema
);
+
mutex_unlock(&nlm_host_mutex
);
return host;
}
}
}
return host;
}
}
}
-
up(&nlm_host_sema
);
+
mutex_unlock(&nlm_host_mutex
);
return NULL;
}
return NULL;
}
@@
-178,12
+176,11
@@
nlm_bind_host(struct nlm_host *host)
/* If we've already created an RPC client, check whether
* RPC rebind is required
/* If we've already created an RPC client, check whether
* RPC rebind is required
- * Note: why keep rebinding if we're on a tcp connection?
*/
if ((clnt = host->h_rpcclnt) != NULL) {
xprt = clnt->cl_xprt;
*/
if ((clnt = host->h_rpcclnt) != NULL) {
xprt = clnt->cl_xprt;
- if (
!xprt->stream &&
time_after_eq(jiffies, host->h_nextrebind)) {
-
clnt->cl_port = 0
;
+ if (time_after_eq(jiffies, host->h_nextrebind)) {
+
rpc_force_rebind(clnt)
;
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
dprintk("lockd: next rebind in %ld jiffies\n",
host->h_nextrebind - jiffies);
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
dprintk("lockd: next rebind in %ld jiffies\n",
host->h_nextrebind - jiffies);
@@
-194,16
+191,15
@@
nlm_bind_host(struct nlm_host *host)
goto forgetit;
xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout);
goto forgetit;
xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout);
+ xprt->resvport = 1; /* NLM requires a reserved port */
- clnt = rpc_create_client(xprt, host->h_name, &nlm_program,
- host->h_version, host->h_authflavor);
- if (IS_ERR(clnt)) {
- xprt_destroy(xprt);
+ /* Existing NLM servers accept AUTH_UNIX only */
+ clnt = rpc_new_client(xprt, host->h_name, &nlm_program,
+ host->h_version, RPC_AUTH_UNIX);
+ if (IS_ERR(clnt))
goto forgetit;
goto forgetit;
- }
clnt->cl_autobind = 1; /* turn on pmap queries */
clnt->cl_autobind = 1; /* turn on pmap queries */
- xprt->nocong = 1; /* No congestion control for NLM */
- xprt->resvport = 1; /* NLM requires a reserved port */
+ clnt->cl_softrtry = 1; /* All queries are soft */
host->h_rpcclnt = clnt;
}
host->h_rpcclnt = clnt;
}
@@
-225,7
+221,7
@@
nlm_rebind_host(struct nlm_host *host)
{
dprintk("lockd: rebind host %s\n", host->h_name);
if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) {
{
dprintk("lockd: rebind host %s\n", host->h_name);
if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) {
-
host->h_rpcclnt->cl_port = 0
;
+
rpc_force_rebind(host->h_rpcclnt)
;
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
}
}
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
}
}
@@
-250,8
+246,12
@@
void nlm_release_host(struct nlm_host *host)
{
if (host != NULL) {
dprintk("lockd: release host %s\n", host->h_name);
{
if (host != NULL) {
dprintk("lockd: release host %s\n", host->h_name);
- atomic_dec(&host->h_count);
BUG_ON(atomic_read(&host->h_count) < 0);
BUG_ON(atomic_read(&host->h_count) < 0);
+ if (atomic_dec_and_test(&host->h_count)) {
+ BUG_ON(!list_empty(&host->h_lockowners));
+ BUG_ON(!list_empty(&host->h_granted));
+ BUG_ON(!list_empty(&host->h_reclaim));
+ }
}
}
}
}
@@
-266,7
+266,7
@@
nlm_shutdown_hosts(void)
int i;
dprintk("lockd: shutting down host module\n");
int i;
dprintk("lockd: shutting down host module\n");
-
down(&nlm_host_sema
);
+
mutex_lock(&nlm_host_mutex
);
/* First, make all hosts eligible for gc */
dprintk("lockd: nuking all hosts...\n");
/* First, make all hosts eligible for gc */
dprintk("lockd: nuking all hosts...\n");
@@
-277,7
+277,7
@@
nlm_shutdown_hosts(void)
/* Then, perform a garbage collection pass */
nlm_gc_hosts();
/* Then, perform a garbage collection pass */
nlm_gc_hosts();
-
up(&nlm_host_sema
);
+
mutex_unlock(&nlm_host_mutex
);
/* complain if any hosts are left */
if (nrhosts) {
/* complain if any hosts are left */
if (nrhosts) {
@@
-339,7
+339,6
@@
nlm_gc_hosts(void)
rpc_destroy_client(host->h_rpcclnt);
}
}
rpc_destroy_client(host->h_rpcclnt);
}
}
- BUG_ON(!list_empty(&host->h_lockowners));
kfree(host);
nrhosts--;
}
kfree(host);
nrhosts--;
}