Commit 87b0fc7d authored by J. Bruce Fields's avatar J. Bruce Fields

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: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 9f912ceb
...@@ -307,33 +307,37 @@ static void set_max_drc(void) ...@@ -307,33 +307,37 @@ static void set_max_drc(void)
dprintk("%s nfsd_drc_max_mem %u \n", __func__, nfsd_drc_max_mem); dprintk("%s nfsd_drc_max_mem %u \n", __func__, nfsd_drc_max_mem);
} }
int nfsd_create_serv(void) static int nfsd_get_default_max_blksize(void)
{ {
int err = 0; struct sysinfo i;
unsigned long long target;
unsigned long ret;
si_meminfo(&i);
target = i.totalram << PAGE_SHIFT;
/*
* Aim for 1/4096 of memory per thread This gives 1MB on 4Gig
* machines, but only uses 32K on 128M machines. Bottom out at
* 8K on 32M and smaller. Of course, this is only a default.
*/
target >>= 12;
ret = NFSSVC_MAXBLKSIZE;
while (ret > target && ret >= 8*1024*2)
ret /= 2;
return ret;
}
int nfsd_create_serv(void)
{
WARN_ON(!mutex_is_locked(&nfsd_mutex)); WARN_ON(!mutex_is_locked(&nfsd_mutex));
if (nfsd_serv) { if (nfsd_serv) {
svc_get(nfsd_serv); svc_get(nfsd_serv);
return 0; return 0;
} }
if (nfsd_max_blksize == 0) { if (nfsd_max_blksize == 0)
/* choose a suitable default */ nfsd_max_blksize = nfsd_get_default_max_blksize();
struct sysinfo i;
si_meminfo(&i);
/* Aim for 1/4096 of memory per thread
* This gives 1MB on 4Gig machines
* But only uses 32K on 128M machines.
* Bottom out at 8K on 32M and smaller.
* Of course, this is only a default.
*/
nfsd_max_blksize = NFSSVC_MAXBLKSIZE;
i.totalram <<= PAGE_SHIFT - 12;
while (nfsd_max_blksize > i.totalram &&
nfsd_max_blksize >= 8*1024*2)
nfsd_max_blksize /= 2;
}
nfsd_reset_versions(); nfsd_reset_versions();
nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
nfsd_last_thread, nfsd, THIS_MODULE); nfsd_last_thread, nfsd, THIS_MODULE);
if (nfsd_serv == NULL) if (nfsd_serv == NULL)
...@@ -341,7 +345,7 @@ int nfsd_create_serv(void) ...@@ -341,7 +345,7 @@ int nfsd_create_serv(void)
set_max_drc(); set_max_drc();
do_gettimeofday(&nfssvc_boot); /* record boot time */ do_gettimeofday(&nfssvc_boot); /* record boot time */
return err; return 0;
} }
int nfsd_nrpools(void) int nfsd_nrpools(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment