Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38372
b: refs/heads/master
c: db4e4c9
h: refs/heads/master
v: v3
  • Loading branch information
Olaf Kirch authored and Linus Torvalds committed Oct 4, 2006
1 parent 0fbd715 commit 6579b2d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cf712c24d72341effcfd28330b83b49f77cb627b
refs/heads/master: db4e4c9a9e741ee812e1febf5e386d6a24218a71
5 changes: 4 additions & 1 deletion trunk/fs/lockd/clntproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
{
struct rpc_clnt *client = NFS_CLIENT(inode);
struct sockaddr_in addr;
struct nfs_server *nfssrv = NFS_SERVER(inode);
struct nlm_host *host;
struct nlm_rqst *call;
sigset_t oldset;
Expand All @@ -166,7 +167,9 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
}

rpc_peeraddr(client, (struct sockaddr *) &addr, sizeof(addr));
host = nlmclnt_lookup_host(&addr, client->cl_xprt->prot, vers);
host = nlmclnt_lookup_host(&addr, client->cl_xprt->prot, vers,
nfssrv->nfs_client->cl_hostname,
strlen(nfssrv->nfs_client->cl_hostname));
if (host == NULL)
return -ENOLCK;

Expand Down
37 changes: 25 additions & 12 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,44 @@ static void nlm_gc_hosts(void);
* 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)
nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
const char *hostname, int hostname_len)
{
return nlm_lookup_host(0, sin, proto, version);
return nlm_lookup_host(0, sin, proto, version,
hostname, hostname_len);
}

/*
* Find an NLM client handle in the cache. If there is none, create it.
*/
struct nlm_host *
nlmsvc_lookup_host(struct svc_rqst *rqstp)
nlmsvc_lookup_host(struct svc_rqst *rqstp,
const char *hostname, int hostname_len)
{
return nlm_lookup_host(1, &rqstp->rq_addr,
rqstp->rq_prot, rqstp->rq_vers);
rqstp->rq_prot, rqstp->rq_vers,
hostname, hostname_len);
}

/*
* Common host lookup routine for server & client
*/
struct nlm_host *
nlm_lookup_host(int server, const struct sockaddr_in *sin,
int proto, int version)
int proto, int version,
const char *hostname,
int hostname_len)
{
struct nlm_host *host, **hp;
u32 addr;
int hash;

dprintk("lockd: nlm_lookup_host(%08x, p=%d, v=%d)\n",
(unsigned)(sin? ntohl(sin->sin_addr.s_addr) : 0), proto, version);
dprintk("lockd: nlm_lookup_host(%u.%u.%u.%u, p=%d, v=%d, my role=%s, name=%.*s)\n",
NIPQUAD(sin->sin_addr.s_addr), proto, version,
server? "server" : "client",
hostname_len,
hostname? hostname : "<none>");


hash = NLM_ADDRHASH(sin->sin_addr.s_addr);

Expand Down Expand Up @@ -267,19 +277,22 @@ void nlm_release_host(struct nlm_host *host)
void nlm_host_rebooted(const struct sockaddr_in *sin, const struct nlm_reboot *argp)
{
struct nlm_host *host;
int server;

/* Obtain the host pointer for this NFS server and try to
* reclaim all locks we hold on this server.
*/
if ((argp->proto & 1)==0) {
server = (argp->proto & 1)? 1 : 0;
host = nlm_lookup_host(server, sin, argp->proto >> 1, argp->vers,
argp->mon, argp->len);
if (host == NULL)
return;

if (server == 0) {
/* We are client, he's the server: try to reclaim all locks. */
if ((host = nlmclnt_lookup_host(sin, argp->proto >> 1, argp->vers)) == NULL)
return;
nlmclnt_recovery(host, argp->state);
} else {
/* He's the client, we're the server: delete all locks held by the client */
if ((host = nlm_lookup_host(1, sin, argp->proto >> 1, argp->vers)) == NULL)
return;
nlmsvc_free_host_resources(host);
}
nlm_release_host(host);
Expand Down
6 changes: 4 additions & 2 deletions trunk/fs/lockd/svc4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
return nlm_lck_denied_nolocks;

/* Obtain host handle */
if (!(host = nlmsvc_lookup_host(rqstp))
if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
|| (argp->monitor && nsm_monitor(host) < 0))
goto no_locks;
*hostp = host;
Expand Down Expand Up @@ -260,7 +260,9 @@ static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *a
struct nlm_rqst *call;
int stat;

host = nlmsvc_lookup_host(rqstp);
host = nlmsvc_lookup_host(rqstp,
argp->lock.caller,
argp->lock.len);
if (host == NULL)
return rpc_system_err;

Expand Down
3 changes: 2 additions & 1 deletion trunk/fs/lockd/svclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file,
struct nlm_rqst *call = NULL;

/* Create host handle for callback */
host = nlmsvc_lookup_host(rqstp);
host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
if (host == NULL)
return NULL;

Expand Down Expand Up @@ -451,6 +451,7 @@ nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
(long long)conflock->fl.fl_start,
(long long)conflock->fl.fl_end);
conflock->caller = "somehost"; /* FIXME */
conflock->len = strlen(conflock->caller);
conflock->oh.len = 0; /* don't return OH info */
conflock->svid = conflock->fl.fl_pid;
return nlm_lck_denied;
Expand Down
6 changes: 4 additions & 2 deletions trunk/fs/lockd/svcproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
return nlm_lck_denied_nolocks;

/* Obtain host handle */
if (!(host = nlmsvc_lookup_host(rqstp))
if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
|| (argp->monitor && nsm_monitor(host) < 0))
goto no_locks;
*hostp = host;
Expand Down Expand Up @@ -287,7 +287,9 @@ static int nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *ar
struct nlm_rqst *call;
int stat;

host = nlmsvc_lookup_host(rqstp);
host = nlmsvc_lookup_host(rqstp,
argp->lock.caller,
argp->lock.len);
if (host == NULL)
return rpc_system_err;

Expand Down
6 changes: 3 additions & 3 deletions trunk/include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ int nlmclnt_reclaim(struct nlm_host *, struct file_lock *);
/*
* Host cache
*/
struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int);
struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *);
struct nlm_host * nlm_lookup_host(int server, const struct sockaddr_in *, int, int);
struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int);
struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int);
struct nlm_host * nlm_lookup_host(int server, const struct sockaddr_in *, int, int, const char *, int);
struct rpc_clnt * nlm_bind_host(struct nlm_host *);
void nlm_rebind_host(struct nlm_host *);
struct nlm_host * nlm_get_host(struct nlm_host *);
Expand Down

0 comments on commit 6579b2d

Please sign in to comment.