* [PATCH] knfsd: Remove NLM_HOST_MAX and associated logic.
[not found] <20080208130300.14320.patches@notabene>
@ 2008-02-08 2:03 ` NeilBrown
2008-02-08 3:55 ` J. Bruce Fields
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2008-02-08 2:03 UTC (permalink / raw)
To: J.Bruce, Fields, " <bfields; +Cc: linux-nfs, linux-kernel, Jeff Layton
Lockd caches information about hosts that have recently held locks it
expedite the taking of further locks.
It periodically discards this information for hosts that have not been
used for a few minutes.
lockd currently has a value NLM_HOST_MAX, and changes the 'garbage
collection' behaviour when the number of hosts exceeds this threshold.
However it's behaviour in strange an likely not what was intended.
When the number of hosts exceeds the max, it scans *less* often (every
2 minutes vs every minute) and allows unused host information to
remain around longer (5 minutes instead of 2).
Having this limit is of dubious value anyway, and we have not
suffered from the code not getting the limit right, so remove the
limit altogether. We go with the larger values (discard 5 minute old
hosts every 2 minutes) as that is probably safer.
Maybe the periodic garbage collection should be replace to with
'shrinker' handler so we just respond to memory pressure....
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./fs/lockd/host.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff .prev/fs/lockd/host.c ./fs/lockd/host.c
--- .prev/fs/lockd/host.c 2008-02-07 14:20:54.000000000 +1100
+++ ./fs/lockd/host.c 2008-02-08 12:54:28.000000000 +1100
@@ -19,12 +19,11 @@
#define NLMDBG_FACILITY NLMDBG_HOSTCACHE
-#define NLM_HOST_MAX 64
#define NLM_HOST_NRHASH 32
#define NLM_ADDRHASH(addr) (ntohl(addr) & (NLM_HOST_NRHASH-1))
#define NLM_HOST_REBIND (60 * HZ)
-#define NLM_HOST_EXPIRE ((nrhosts > NLM_HOST_MAX)? 300 * HZ : 120 * HZ)
-#define NLM_HOST_COLLECT ((nrhosts > NLM_HOST_MAX)? 120 * HZ : 60 * HZ)
+#define NLM_HOST_EXPIRE (300 * HZ)
+#define NLM_HOST_COLLECT (120 * HZ)
static struct hlist_head nlm_hosts[NLM_HOST_NRHASH];
static unsigned long next_gc;
@@ -142,9 +141,7 @@ nlm_lookup_host(int server, const struct
INIT_LIST_HEAD(&host->h_granted);
INIT_LIST_HEAD(&host->h_reclaim);
- if (++nrhosts > NLM_HOST_MAX)
- next_gc = 0;
-
+ nrhosts++;
out:
mutex_unlock(&nlm_host_mutex);
return host;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] knfsd: Remove NLM_HOST_MAX and associated logic.
2008-02-08 2:03 ` [PATCH] knfsd: Remove NLM_HOST_MAX and associated logic NeilBrown
@ 2008-02-08 3:55 ` J. Bruce Fields
0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2008-02-08 3:55 UTC (permalink / raw)
To: NeilBrown; +Cc: J.Bruce, Fields, linux-nfs, linux-kernel, Jeff Layton
On Fri, Feb 08, 2008 at 01:03:37PM +1100, NeilBrown wrote:
>
> Lockd caches information about hosts that have recently held locks it
> expedite the taking of further locks.
Applied, thanks!--b.
>
> It periodically discards this information for hosts that have not been
> used for a few minutes.
>
> lockd currently has a value NLM_HOST_MAX, and changes the 'garbage
> collection' behaviour when the number of hosts exceeds this threshold.
>
> However it's behaviour in strange an likely not what was intended.
> When the number of hosts exceeds the max, it scans *less* often (every
> 2 minutes vs every minute) and allows unused host information to
> remain around longer (5 minutes instead of 2).
>
> Having this limit is of dubious value anyway, and we have not
> suffered from the code not getting the limit right, so remove the
> limit altogether. We go with the larger values (discard 5 minute old
> hosts every 2 minutes) as that is probably safer.
>
> Maybe the periodic garbage collection should be replace to with
> 'shrinker' handler so we just respond to memory pressure....
>
> Acked-by: Jeff Layton <jlayton@redhat.com>
> Signed-off-by: Neil Brown <neilb@suse.de>
>
> ### Diffstat output
> ./fs/lockd/host.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff .prev/fs/lockd/host.c ./fs/lockd/host.c
> --- .prev/fs/lockd/host.c 2008-02-07 14:20:54.000000000 +1100
> +++ ./fs/lockd/host.c 2008-02-08 12:54:28.000000000 +1100
> @@ -19,12 +19,11 @@
>
>
> #define NLMDBG_FACILITY NLMDBG_HOSTCACHE
> -#define NLM_HOST_MAX 64
> #define NLM_HOST_NRHASH 32
> #define NLM_ADDRHASH(addr) (ntohl(addr) & (NLM_HOST_NRHASH-1))
> #define NLM_HOST_REBIND (60 * HZ)
> -#define NLM_HOST_EXPIRE ((nrhosts > NLM_HOST_MAX)? 300 * HZ : 120 * HZ)
> -#define NLM_HOST_COLLECT ((nrhosts > NLM_HOST_MAX)? 120 * HZ : 60 * HZ)
> +#define NLM_HOST_EXPIRE (300 * HZ)
> +#define NLM_HOST_COLLECT (120 * HZ)
>
> static struct hlist_head nlm_hosts[NLM_HOST_NRHASH];
> static unsigned long next_gc;
> @@ -142,9 +141,7 @@ nlm_lookup_host(int server, const struct
> INIT_LIST_HEAD(&host->h_granted);
> INIT_LIST_HEAD(&host->h_reclaim);
>
> - if (++nrhosts > NLM_HOST_MAX)
> - next_gc = 0;
> -
> + nrhosts++;
> out:
> mutex_unlock(&nlm_host_mutex);
> return host;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-08 3:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20080208130300.14320.patches@notabene>
2008-02-08 2:03 ` [PATCH] knfsd: Remove NLM_HOST_MAX and associated logic NeilBrown
2008-02-08 3:55 ` J. Bruce Fields
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox