Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 229193
b: refs/heads/master
c: 8ea6ecc
h: refs/heads/master
i:
  229191: 734eec4
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Dec 16, 2010
1 parent bbe08de commit 4987994
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 15 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: 7db836d4a427c3c64406b00b6d8d745d6335d72a
refs/heads/master: 8ea6ecc8b0759756a766c05dc7c98c51ec90de37
4 changes: 2 additions & 2 deletions trunk/fs/lockd/clntlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ EXPORT_SYMBOL_GPL(nlmclnt_init);
*/
void nlmclnt_done(struct nlm_host *host)
{
nlm_release_host(host);
nlmclnt_release_host(host);
lockd_down();
}
EXPORT_SYMBOL_GPL(nlmclnt_done);
Expand Down Expand Up @@ -273,7 +273,7 @@ reclaimer(void *ptr)
spin_unlock(&nlm_blocked_lock);

/* Release host handle after use */
nlm_release_host(host);
nlmclnt_release_host(host);
lockd_down();
return 0;
}
6 changes: 3 additions & 3 deletions trunk/fs/lockd/clntproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void nlm_put_lockowner(struct nlm_lockowner *lockowner)
return;
list_del(&lockowner->list);
spin_unlock(&lockowner->host->h_lock);
nlm_release_host(lockowner->host);
nlmclnt_release_host(lockowner->host);
kfree(lockowner);
}

Expand Down Expand Up @@ -207,15 +207,15 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)
printk("nlm_alloc_call: failed, waiting for memory\n");
schedule_timeout_interruptible(5*HZ);
}
nlm_release_host(host);
nlmclnt_release_host(host);
return NULL;
}

void nlmclnt_release_call(struct nlm_rqst *call)
{
if (!atomic_dec_and_test(&call->a_count))
return;
nlm_release_host(call->a_host);
nlmclnt_release_host(call->a_host);
nlmclnt_release_lockargs(call);
kfree(call);
}
Expand Down
81 changes: 72 additions & 9 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define NLM_HOST_COLLECT (120 * HZ)

static struct hlist_head nlm_hosts[NLM_HOST_NRHASH];
static struct hlist_head nlm_client_hosts[NLM_HOST_NRHASH];

#define for_each_host(host, pos, chain, table) \
for ((chain) = (table); \
Expand Down Expand Up @@ -288,12 +289,76 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
.hostname_len = strlen(hostname),
.noresvport = noresvport,
};
struct hlist_head *chain;
struct hlist_node *pos;
struct nlm_host *host;
struct nsm_handle *nsm = NULL;

dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__,
(hostname ? hostname : "<none>"), version,
(protocol == IPPROTO_UDP ? "udp" : "tcp"));

return nlm_lookup_host(&ni);
mutex_lock(&nlm_host_mutex);

chain = &nlm_client_hosts[nlm_hash_address(sap)];
hlist_for_each_entry(host, pos, chain, h_hash) {
if (!rpc_cmp_addr(nlm_addr(host), sap))
continue;

/* Same address. Share an NSM handle if we already have one */
if (nsm == NULL)
nsm = host->h_nsmhandle;

if (host->h_proto != protocol)
continue;
if (host->h_version != version)
continue;

nlm_get_host(host);
dprintk("lockd: %s found host %s (%s)\n", __func__,
host->h_name, host->h_addrbuf);
goto out;
}

host = nlm_alloc_host(&ni, nsm);
if (unlikely(host == NULL))
goto out;

hlist_add_head(&host->h_hash, chain);
nrhosts++;

dprintk("lockd: %s created host %s (%s)\n", __func__,
host->h_name, host->h_addrbuf);

out:
mutex_unlock(&nlm_host_mutex);
return host;
}

/**
* nlmclnt_release_host - release client nlm_host
* @host: nlm_host to release
*
*/
void nlmclnt_release_host(struct nlm_host *host)
{
if (host == NULL)
return;

dprintk("lockd: release client host %s\n", host->h_name);

BUG_ON(atomic_read(&host->h_count) < 0);
BUG_ON(host->h_server);

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));

mutex_lock(&nlm_host_mutex);
nlm_destroy_host_locked(host);
mutex_unlock(&nlm_host_mutex);
}
}

/**
Expand Down Expand Up @@ -515,16 +580,14 @@ void nlm_host_rebooted(const struct nlm_reboot *info)
* To avoid processing a host several times, we match the nsmstate.
*/
while ((host = next_host_state(nlm_hosts, nsm, info)) != NULL) {
if (host->h_server) {
/* We're server for this guy, just ditch
* all the locks he held. */
nlmsvc_free_host_resources(host);
} else {
/* He's the server, initiate lock recovery. */
nlmclnt_recovery(host);
}
nlmsvc_free_host_resources(host);
nlm_release_host(host);
}
while ((host = next_host_state(nlm_client_hosts, nsm, info)) != NULL) {
nlmclnt_recovery(host);
nlmclnt_release_host(host);
}

nsm_release(nsm);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
const u32 version,
const char *hostname,
int noresvport);
void nlmclnt_release_host(struct nlm_host *);
struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
const char *hostname,
const size_t hostname_len);
Expand Down

0 comments on commit 4987994

Please sign in to comment.