diff options
author | Andy Adamson <andros@netapp.com> | 2009-04-03 01:28:18 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-04-03 20:41:17 -0400 |
commit | c3d06f9ce8544fecfe13e377d1e2c2e47fe18dbc (patch) | |
tree | f34acde5f484a8374065295e205921e1860da65c | |
parent | 074fe897536f095309c5aaffcf912952882ab2cb (diff) |
nfsd41: hard page limit for DRC
Use no more than 1/128th of the number of free pages at nfsd startup for the
v4.1 DRC.
This is an arbitrary default which should probably end up under the control
of an administrator.
Signed-off-by: Andy Adamson <andros@netapp.com>
[moved added fields in struct svc_serv under CONFIG_NFSD_V4_1]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[fix set_max_drc calculation of sv_drc_max_pages]
[moved NFSD_DRC_SIZE_SHIFT's declaration up in header file]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r-- | fs/nfsd/nfssvc.c | 23 | ||||
-rw-r--r-- | include/linux/nfsd/nfsd.h | 3 | ||||
-rw-r--r-- | include/linux/sunrpc/svc.h | 2 |
3 files changed, 28 insertions, 0 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index b5168d1898ec..b53a098e97a4 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/freezer.h> | 22 | #include <linux/freezer.h> |
23 | #include <linux/fs_struct.h> | 23 | #include <linux/fs_struct.h> |
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/swap.h> | ||
25 | 26 | ||
26 | #include <linux/sunrpc/types.h> | 27 | #include <linux/sunrpc/types.h> |
27 | #include <linux/sunrpc/stats.h> | 28 | #include <linux/sunrpc/stats.h> |
@@ -197,6 +198,26 @@ void nfsd_reset_versions(void) | |||
197 | } | 198 | } |
198 | } | 199 | } |
199 | 200 | ||
201 | /* | ||
202 | * Each session guarantees a negotiated per slot memory cache for replies | ||
203 | * which in turn consumes memory beyond the v2/v3/v4.0 server. A dedicated | ||
204 | * NFSv4.1 server might want to use more memory for a DRC than a machine | ||
205 | * with mutiple services. | ||
206 | * | ||
207 | * Impose a hard limit on the number of pages for the DRC which varies | ||
208 | * according to the machines free pages. This is of course only a default. | ||
209 | * | ||
210 | * For now this is a #defined shift which could be under admin control | ||
211 | * in the future. | ||
212 | */ | ||
213 | static void set_max_drc(void) | ||
214 | { | ||
215 | nfsd_serv->sv_drc_max_pages = nr_free_buffer_pages() | ||
216 | >> NFSD_DRC_SIZE_SHIFT; | ||
217 | nfsd_serv->sv_drc_pages_used = 0; | ||
218 | dprintk("%s svc_drc_max_pages %u\n", __func__, | ||
219 | nfsd_serv->sv_drc_max_pages); | ||
220 | } | ||
200 | 221 | ||
201 | int nfsd_create_serv(void) | 222 | int nfsd_create_serv(void) |
202 | { | 223 | { |
@@ -229,6 +250,8 @@ int nfsd_create_serv(void) | |||
229 | nfsd_last_thread, nfsd, THIS_MODULE); | 250 | nfsd_last_thread, nfsd, THIS_MODULE); |
230 | if (nfsd_serv == NULL) | 251 | if (nfsd_serv == NULL) |
231 | err = -ENOMEM; | 252 | err = -ENOMEM; |
253 | else | ||
254 | set_max_drc(); | ||
232 | 255 | ||
233 | do_gettimeofday(&nfssvc_boot); /* record boot time */ | 256 | do_gettimeofday(&nfssvc_boot); /* record boot time */ |
234 | return err; | 257 | return err; |
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h index ab9616d09204..1f063d495159 100644 --- a/include/linux/nfsd/nfsd.h +++ b/include/linux/nfsd/nfsd.h | |||
@@ -331,6 +331,9 @@ extern struct timeval nfssvc_boot; | |||
331 | #define NFSD_LEASE_TIME (nfs4_lease_time()) | 331 | #define NFSD_LEASE_TIME (nfs4_lease_time()) |
332 | #define NFSD_LAUNDROMAT_MINTIMEOUT 10 /* seconds */ | 332 | #define NFSD_LAUNDROMAT_MINTIMEOUT 10 /* seconds */ |
333 | 333 | ||
334 | /* The percent of nr_free_buffer_pages used by the V4.1 server DRC */ | ||
335 | #define NFSD_DRC_SIZE_SHIFT 7 | ||
336 | |||
334 | /* | 337 | /* |
335 | * The following attributes are currently not supported by the NFSv4 server: | 338 | * The following attributes are currently not supported by the NFSv4 server: |
336 | * ARCHIVE (deprecated anyway) | 339 | * ARCHIVE (deprecated anyway) |
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 815dd589d4db..d209c630a4a1 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h | |||
@@ -95,6 +95,8 @@ struct svc_serv { | |||
95 | struct module * sv_module; /* optional module to count when | 95 | struct module * sv_module; /* optional module to count when |
96 | * adding threads */ | 96 | * adding threads */ |
97 | svc_thread_fn sv_function; /* main function for threads */ | 97 | svc_thread_fn sv_function; /* main function for threads */ |
98 | unsigned int sv_drc_max_pages; /* Total pages for DRC */ | ||
99 | unsigned int sv_drc_pages_used;/* DRC pages used */ | ||
98 | }; | 100 | }; |
99 | 101 | ||
100 | /* | 102 | /* |