From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 05/12] lockd: encapsulate nlm_hosts table variables in one structure
Date: Wed, 5 Nov 2008 17:41:09 -0500 [thread overview]
Message-ID: <20081105224109.GN1455@fieldses.org> (raw)
In-Reply-To: <5C259444-2EA3-489E-9FC9-5983DDE74950@oracle.com>
On Wed, Nov 05, 2008 at 05:25:40PM -0500, Chuck Lever wrote:
> On Nov 5, 2008, at 3:06 PM, J. Bruce Fields wrote:
>> This will simplify splitting these variables into client and server
>> sides.
>>
>> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
>> ---
>> fs/lockd/host.c | 46 ++++++++++++++++++++++++++--------------------
>> 1 files changed, 26 insertions(+), 20 deletions(-)
>>
>> diff --git a/fs/lockd/host.c b/fs/lockd/host.c
>> index 1a1adb9..199ca8c 100644
>> --- a/fs/lockd/host.c
>> +++ b/fs/lockd/host.c
>> @@ -26,10 +26,16 @@
>> #define NLM_HOST_EXPIRE (300 * HZ)
>> #define NLM_HOST_COLLECT (120 * HZ)
>>
>> -static struct hlist_head nlm_hosts[NLM_HOST_NRHASH];
>> +struct host_table {
>> + struct hlist_head ht_chains[NLM_HOST_NRHASH];
>> + int ht_num;
>> + struct mutex ht_mutex;
>> +};
>> +
>> +static struct host_table nlm_hosts = {
>> + .ht_mutex = __MUTEX_INITIALIZER(nlm_hosts.ht_mutex)
>> +};
>> static unsigned long next_gc;
>
> I also moved next_gc into the host_table struct in my version of these
> patches. Do we want to garbage collect the client and server host
> caches separately? I'm not sure.
I always figured we should get rid of the garbage collection entirely.
--b.
>
>>
>> -static int nrhosts;
>> -static DEFINE_MUTEX(nlm_host_mutex);
>>
>> static void nlm_gc_hosts(void);
>> static struct nsm_handle *nsm_find(const struct sockaddr *sap,
>> @@ -140,7 +146,7 @@ static struct nlm_host *nlm_lookup_host(struct
>> nlm_lookup_host_info *ni)
>> struct nlm_host *host;
>> struct nsm_handle *nsm;
>>
>> - mutex_lock(&nlm_host_mutex);
>> + mutex_lock(&nlm_hosts.ht_mutex);
>>
>> if (time_after_eq(jiffies, next_gc))
>> nlm_gc_hosts();
>> @@ -152,7 +158,7 @@ static struct nlm_host *nlm_lookup_host(struct
>> nlm_lookup_host_info *ni)
>> * different NLM rpc_clients into one single nlm_host object.
>> * This would allow us to have one nlm_host per address.
>> */
>> - chain = &nlm_hosts[nlm_hash_address(ni->sap)];
>> + chain = &nlm_hosts.ht_chains[nlm_hash_address(ni->sap)];
>> hlist_for_each_entry(host, pos, chain, h_hash) {
>> if (!nlm_cmp_addr(nlm_addr(host), ni->sap))
>> continue;
>> @@ -218,7 +224,7 @@ static struct nlm_host *nlm_lookup_host(struct
>> nlm_lookup_host_info *ni)
>> INIT_LIST_HEAD(&host->h_granted);
>> INIT_LIST_HEAD(&host->h_reclaim);
>>
>> - nrhosts++;
>> + nlm_hosts.ht_num++;
>>
>> nlm_display_address((struct sockaddr *)&host->h_addr,
>> host->h_addrbuf, sizeof(host->h_addrbuf));
>> @@ -229,7 +235,7 @@ static struct nlm_host *nlm_lookup_host(struct
>> nlm_lookup_host_info *ni)
>> host->h_name);
>>
>> out:
>> - mutex_unlock(&nlm_host_mutex);
>> + mutex_unlock(&nlm_hosts.ht_mutex);
>> return host;
>> }
>>
>> @@ -498,8 +504,8 @@ void nlm_host_rebooted(const struct sockaddr_in
>> *sin,
>> * lock for this.
>> * To avoid processing a host several times, we match the nsmstate.
>> */
>> -again: mutex_lock(&nlm_host_mutex);
>> - for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; +
>> +chain) {
>> +again: mutex_lock(&nlm_hosts.ht_mutex);
>> + for (chain = nlm_hosts.ht_chains; chain < nlm_hosts.ht_chains +
>> NLM_HOST_NRHASH; ++chain) {
>> hlist_for_each_entry(host, pos, chain, h_hash) {
>> if (host->h_nsmhandle == nsm
>> && host->h_nsmstate != new_state) {
>> @@ -507,7 +513,7 @@ again: mutex_lock(&nlm_host_mutex);
>> host->h_state++;
>>
>> nlm_get_host(host);
>> - mutex_unlock(&nlm_host_mutex);
>> + mutex_unlock(&nlm_hosts.ht_mutex);
>>
>> if (host->h_server) {
>> /* We're server for this guy, just ditch
>> @@ -524,7 +530,7 @@ again: mutex_lock(&nlm_host_mutex);
>> }
>> }
>>
>> - mutex_unlock(&nlm_host_mutex);
>> + mutex_unlock(&nlm_hosts.ht_mutex);
>> }
>>
>> /*
>> @@ -539,11 +545,11 @@ nlm_shutdown_hosts(void)
>> struct nlm_host *host;
>>
>> dprintk("lockd: shutting down host module\n");
>> - mutex_lock(&nlm_host_mutex);
>> + mutex_lock(&nlm_hosts.ht_mutex);
>>
>> /* First, make all hosts eligible for gc */
>> dprintk("lockd: nuking all hosts...\n");
>> - for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; +
>> +chain) {
>> + for (chain = nlm_hosts.ht_chains; chain < nlm_hosts.ht_chains +
>> NLM_HOST_NRHASH; ++chain) {
>> hlist_for_each_entry(host, pos, chain, h_hash) {
>> host->h_expires = jiffies - 1;
>> if (host->h_rpcclnt) {
>> @@ -555,13 +561,13 @@ nlm_shutdown_hosts(void)
>>
>> /* Then, perform a garbage collection pass */
>> nlm_gc_hosts();
>> - mutex_unlock(&nlm_host_mutex);
>> + mutex_unlock(&nlm_hosts.ht_mutex);
>>
>> /* complain if any hosts are left */
>> - if (nrhosts) {
>> + if (nlm_hosts.ht_num) {
>> printk(KERN_WARNING "lockd: couldn't shutdown host module!\n");
>> - dprintk("lockd: %d hosts left:\n", nrhosts);
>> - for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; +
>> +chain) {
>> + dprintk("lockd: %d hosts left:\n", nlm_hosts.ht_num);
>> + for (chain = nlm_hosts.ht_chains; chain < nlm_hosts.ht_chains +
>> NLM_HOST_NRHASH; ++chain) {
>> hlist_for_each_entry(host, pos, chain, h_hash) {
>> dprintk(" %s (cnt %d use %d exp %ld)\n",
>> host->h_name, atomic_read(&host->h_count),
>> @@ -584,7 +590,7 @@ nlm_gc_hosts(void)
>> struct nlm_host *host;
>>
>> dprintk("lockd: host garbage collection\n");
>> - for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; +
>> +chain) {
>> + for (chain = nlm_hosts.ht_chains; chain < nlm_hosts.ht_chains +
>> NLM_HOST_NRHASH; ++chain) {
>> hlist_for_each_entry(host, pos, chain, h_hash)
>> host->h_inuse = 0;
>> }
>> @@ -592,7 +598,7 @@ nlm_gc_hosts(void)
>> /* Mark all hosts that hold locks, blocks or shares */
>> nlmsvc_mark_resources();
>>
>> - for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; +
>> +chain) {
>> + for (chain = nlm_hosts.ht_chains; chain < nlm_hosts.ht_chains +
>> NLM_HOST_NRHASH; ++chain) {
>> hlist_for_each_entry_safe(host, pos, next, chain, h_hash) {
>> if (atomic_read(&host->h_count) || host->h_inuse
>> || time_before(jiffies, host->h_expires)) {
>> @@ -605,7 +611,7 @@ nlm_gc_hosts(void)
>> hlist_del_init(&host->h_hash);
>>
>> nlm_destroy_host(host);
>> - nrhosts--;
>> + nlm_hosts.ht_num--;
>> }
>> }
>>
>> --
>> 1.5.5.rc1
>>
>
> --
> Chuck Lever
> chuck[dot]lever[at]oracle[dot]com
>
>
>
next prev parent reply other threads:[~2008-11-05 22:41 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 17:28 [PATCH 00/13] kernel server-side IPv6 support Chuck Lever
[not found] ` <20081105172351.7330.50739.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-11-05 17:28 ` [PATCH 01/13] lockd: Enable NLM use of AF_INET6 Chuck Lever
2008-11-05 17:28 ` [PATCH 02/13] NFSD: Add documenting comments for nfsctl interface Chuck Lever
2008-11-05 17:28 ` [PATCH 03/13] NFSD: Add helper functions for __write_ports() Chuck Lever
2008-11-05 17:28 ` [PATCH 04/13] NFSD: Refactor __write_ports() Chuck Lever
2008-11-05 17:28 ` [PATCH 05/13] NFSD: Prevent a buffer overflow in svc_xprt_names() Chuck Lever
2008-11-05 17:29 ` [PATCH 06/13] SUNRPC: pass buffer size to svc_addsock() and svc_sock_names() Chuck Lever
2008-11-05 17:29 ` [PATCH 07/13] SUNRPC: Switch one_sock_name() to use snprintf() Chuck Lever
2008-11-05 17:29 ` [PATCH 08/13] SUNRPC: Support AF_INET6 in one_sock_name() Chuck Lever
2008-11-05 17:29 ` [PATCH 09/13] SUNRPC: Clean up one_sock_name() Chuck Lever
2008-11-05 17:29 ` [PATCH 10/13] NFSD: Support AF_INET6 in svc_addsock() function Chuck Lever
2008-11-05 17:29 ` [PATCH 11/13] NFS: Move NFS client's IP address parser to nfs_common/ Chuck Lever
2008-11-05 17:29 ` [PATCH 12/13] NFSD: Support IPv6 addresses in write_failover_ip() Chuck Lever
2008-11-05 17:29 ` [PATCH 13/13] NFSD: Enable NFS server use of AF_INET6 Chuck Lever
2008-11-05 20:06 ` [PATCH 01/12] lockd: fix inconsistent use of nsm_use_hostnames J. Bruce Fields
2008-11-05 20:06 ` [PATCH 02/12] lockd: kill redundant host->h_server check J. Bruce Fields
2008-11-05 20:06 ` [PATCH 03/12] lockd: fix nsm_unmonitor return value J. Bruce Fields
2008-11-05 20:06 ` [PATCH 04/12] lockd: unmonitor only when last host goes away J. Bruce Fields
2008-11-05 20:06 ` [PATCH 05/12] lockd: encapsulate nlm_hosts table variables in one structure J. Bruce Fields
2008-11-05 20:06 ` [PATCH 06/12] lockd: define host_for_each{_safe} macros J. Bruce Fields
2008-11-05 20:06 ` [PATCH 07/12] lockd: reorganize nlm_host_rebooted J. Bruce Fields
2008-11-05 20:06 ` [PATCH 08/12] lockd: move debugging warning into a separate function J. Bruce Fields
2008-11-05 20:06 ` [PATCH 09/12] lockd: move garbage collection loop into " J. Bruce Fields
2008-11-05 20:06 ` [PATCH 10/12] lockd: move immediate host expiry " J. Bruce Fields
2008-11-05 20:06 ` [PATCH 11/12] lockd: split client and server host lists J. Bruce Fields
2008-11-05 20:06 ` [PATCH 12/12] lockd: remove redundant rpc_shutdown_client() J. Bruce Fields
2008-11-06 12:17 ` Jeff Layton
[not found] ` <20081106071733.6d4983ce@barsoom .rdu.redhat.com>
[not found] ` <20081106071733.6d4983ce-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2008-11-06 14:32 ` Chuck Lever
2008-11-06 14:51 ` Jeff Layton
2008-11-06 22:10 ` J. Bruce Fields
2008-11-06 22:21 ` Chuck Lever
2008-11-06 22:22 ` J. Bruce Fields
2008-11-06 22:25 ` Jeff Layton
2008-11-05 22:33 ` [PATCH 10/12] lockd: move immediate host expiry into separate function Chuck Lever
2008-11-05 22:29 ` [PATCH 07/12] lockd: reorganize nlm_host_rebooted Chuck Lever
2008-11-05 22:25 ` [PATCH 05/12] lockd: encapsulate nlm_hosts table variables in one structure Chuck Lever
2008-11-05 22:41 ` J. Bruce Fields [this message]
2008-11-05 23:11 ` Trond Myklebust
[not found] ` <1225926710.16857.94.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-05 23:21 ` J. Bruce Fields
2008-11-05 22:22 ` [PATCH 04/12] lockd: unmonitor only when last host goes away Chuck Lever
2008-11-05 22:14 ` [PATCH 03/12] lockd: fix nsm_unmonitor return value Chuck Lever
2008-11-05 22:10 ` [PATCH 01/12] lockd: fix inconsistent use of nsm_use_hostnames Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081105224109.GN1455@fieldses.org \
--to=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.