diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-01-30 16:18:35 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-02-03 15:32:41 -0500 |
commit | 87b0fc7deb5feccf93b022f6a976e8441152dbb2 (patch) | |
tree | c263e3d504cb2d31ef8c91658da056485d014bc3 /fs/nfsd/nfssvc.c | |
parent | 9f912ceb7ed1df1ed98ad2c28995dd66529a690a (diff) |
nfsd: cleanup setting of default max_block_size
Move calculation of the default into a helper function.
Get rid of an unused variable "err" while we're there.
Thanks to Mi Jinlong for catching an arithmetic error in a previous
version.
Cc: Mi Jinlong <mijinlong@cn.fujitsu.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r-- | fs/nfsd/nfssvc.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index eda7d7e55e05..e9eb408ae2a8 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -307,33 +307,37 @@ static void set_max_drc(void) | |||
307 | dprintk("%s nfsd_drc_max_mem %u \n", __func__, nfsd_drc_max_mem); | 307 | dprintk("%s nfsd_drc_max_mem %u \n", __func__, nfsd_drc_max_mem); |
308 | } | 308 | } |
309 | 309 | ||
310 | int nfsd_create_serv(void) | 310 | static int nfsd_get_default_max_blksize(void) |
311 | { | 311 | { |
312 | int err = 0; | 312 | struct sysinfo i; |
313 | unsigned long long target; | ||
314 | unsigned long ret; | ||
315 | |||
316 | si_meminfo(&i); | ||
317 | target = i.totalram << PAGE_SHIFT; | ||
318 | /* | ||
319 | * Aim for 1/4096 of memory per thread This gives 1MB on 4Gig | ||
320 | * machines, but only uses 32K on 128M machines. Bottom out at | ||
321 | * 8K on 32M and smaller. Of course, this is only a default. | ||
322 | */ | ||
323 | target >>= 12; | ||
324 | |||
325 | ret = NFSSVC_MAXBLKSIZE; | ||
326 | while (ret > target && ret >= 8*1024*2) | ||
327 | ret /= 2; | ||
328 | return ret; | ||
329 | } | ||
313 | 330 | ||
331 | int nfsd_create_serv(void) | ||
332 | { | ||
314 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); | 333 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); |
315 | if (nfsd_serv) { | 334 | if (nfsd_serv) { |
316 | svc_get(nfsd_serv); | 335 | svc_get(nfsd_serv); |
317 | return 0; | 336 | return 0; |
318 | } | 337 | } |
319 | if (nfsd_max_blksize == 0) { | 338 | if (nfsd_max_blksize == 0) |
320 | /* choose a suitable default */ | 339 | nfsd_max_blksize = nfsd_get_default_max_blksize(); |
321 | struct sysinfo i; | ||
322 | si_meminfo(&i); | ||
323 | /* Aim for 1/4096 of memory per thread | ||
324 | * This gives 1MB on 4Gig machines | ||
325 | * But only uses 32K on 128M machines. | ||
326 | * Bottom out at 8K on 32M and smaller. | ||
327 | * Of course, this is only a default. | ||
328 | */ | ||
329 | nfsd_max_blksize = NFSSVC_MAXBLKSIZE; | ||
330 | i.totalram <<= PAGE_SHIFT - 12; | ||
331 | while (nfsd_max_blksize > i.totalram && | ||
332 | nfsd_max_blksize >= 8*1024*2) | ||
333 | nfsd_max_blksize /= 2; | ||
334 | } | ||
335 | nfsd_reset_versions(); | 340 | nfsd_reset_versions(); |
336 | |||
337 | nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, | 341 | nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, |
338 | nfsd_last_thread, nfsd, THIS_MODULE); | 342 | nfsd_last_thread, nfsd, THIS_MODULE); |
339 | if (nfsd_serv == NULL) | 343 | if (nfsd_serv == NULL) |
@@ -341,7 +345,7 @@ int nfsd_create_serv(void) | |||
341 | 345 | ||
342 | set_max_drc(); | 346 | set_max_drc(); |
343 | do_gettimeofday(&nfssvc_boot); /* record boot time */ | 347 | do_gettimeofday(&nfssvc_boot); /* record boot time */ |
344 | return err; | 348 | return 0; |
345 | } | 349 | } |
346 | 350 | ||
347 | int nfsd_nrpools(void) | 351 | int nfsd_nrpools(void) |