aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd/host.c')
-rw-r--r--fs/lockd/host.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index bcc21b05808a..481ce7ee1002 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -39,19 +39,23 @@ static void nlm_gc_hosts(void);
39 * Find an NLM server handle in the cache. If there is none, create it. 39 * Find an NLM server handle in the cache. If there is none, create it.
40 */ 40 */
41struct nlm_host * 41struct nlm_host *
42nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version) 42nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
43 const char *hostname, int hostname_len)
43{ 44{
44 return nlm_lookup_host(0, sin, proto, version); 45 return nlm_lookup_host(0, sin, proto, version,
46 hostname, hostname_len);
45} 47}
46 48
47/* 49/*
48 * Find an NLM client handle in the cache. If there is none, create it. 50 * Find an NLM client handle in the cache. If there is none, create it.
49 */ 51 */
50struct nlm_host * 52struct nlm_host *
51nlmsvc_lookup_host(struct svc_rqst *rqstp) 53nlmsvc_lookup_host(struct svc_rqst *rqstp,
54 const char *hostname, int hostname_len)
52{ 55{
53 return nlm_lookup_host(1, &rqstp->rq_addr, 56 return nlm_lookup_host(1, &rqstp->rq_addr,
54 rqstp->rq_prot, rqstp->rq_vers); 57 rqstp->rq_prot, rqstp->rq_vers,
58 hostname, hostname_len);
55} 59}
56 60
57/* 61/*
@@ -59,14 +63,20 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp)
59 */ 63 */
60struct nlm_host * 64struct nlm_host *
61nlm_lookup_host(int server, const struct sockaddr_in *sin, 65nlm_lookup_host(int server, const struct sockaddr_in *sin,
62 int proto, int version) 66 int proto, int version,
67 const char *hostname,
68 int hostname_len)
63{ 69{
64 struct nlm_host *host, **hp; 70 struct nlm_host *host, **hp;
65 u32 addr; 71 u32 addr;
66 int hash; 72 int hash;
67 73
68 dprintk("lockd: nlm_lookup_host(%08x, p=%d, v=%d)\n", 74 dprintk("lockd: nlm_lookup_host(%u.%u.%u.%u, p=%d, v=%d, my role=%s, name=%.*s)\n",
69 (unsigned)(sin? ntohl(sin->sin_addr.s_addr) : 0), proto, version); 75 NIPQUAD(sin->sin_addr.s_addr), proto, version,
76 server? "server" : "client",
77 hostname_len,
78 hostname? hostname : "<none>");
79
70 80
71 hash = NLM_ADDRHASH(sin->sin_addr.s_addr); 81 hash = NLM_ADDRHASH(sin->sin_addr.s_addr);
72 82
@@ -267,19 +277,22 @@ void nlm_release_host(struct nlm_host *host)
267void nlm_host_rebooted(const struct sockaddr_in *sin, const struct nlm_reboot *argp) 277void nlm_host_rebooted(const struct sockaddr_in *sin, const struct nlm_reboot *argp)
268{ 278{
269 struct nlm_host *host; 279 struct nlm_host *host;
280 int server;
270 281
271 /* Obtain the host pointer for this NFS server and try to 282 /* Obtain the host pointer for this NFS server and try to
272 * reclaim all locks we hold on this server. 283 * reclaim all locks we hold on this server.
273 */ 284 */
274 if ((argp->proto & 1)==0) { 285 server = (argp->proto & 1)? 1 : 0;
286 host = nlm_lookup_host(server, sin, argp->proto >> 1, argp->vers,
287 argp->mon, argp->len);
288 if (host == NULL)
289 return;
290
291 if (server == 0) {
275 /* We are client, he's the server: try to reclaim all locks. */ 292 /* We are client, he's the server: try to reclaim all locks. */
276 if ((host = nlmclnt_lookup_host(sin, argp->proto >> 1, argp->vers)) == NULL)
277 return;
278 nlmclnt_recovery(host, argp->state); 293 nlmclnt_recovery(host, argp->state);
279 } else { 294 } else {
280 /* He's the client, we're the server: delete all locks held by the client */ 295 /* He's the client, we're the server: delete all locks held by the client */
281 if ((host = nlm_lookup_host(1, sin, argp->proto >> 1, argp->vers)) == NULL)
282 return;
283 nlmsvc_free_host_resources(host); 296 nlmsvc_free_host_resources(host);
284 } 297 }
285 nlm_release_host(host); 298 nlm_release_host(host);