All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Mi Jinlong <mijinlong@cn.fujitsu.com>
Cc: "J. Bruce Fields" <bfields@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/2] nfsd: cleanup setting of default max_block_size
Date: Wed, 1 Feb 2012 16:46:56 -0500	[thread overview]
Message-ID: <20120201214656.GA19075@fieldses.org> (raw)
In-Reply-To: <4F273FD4.3020005@cn.fujitsu.com>

On Tue, Jan 31, 2012 at 09:11:48AM +0800, Mi Jinlong wrote:
> 
> 
> J. Bruce Fields 写道:
> > From: "J. Bruce Fields" <bfields@redhat.com>
> > 
> > Move calculation of the default into a helper function.
> > 
> > Get rid of an unused variable "err" while we're there.
> > 
> > Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> > ---
> >  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 eda7d7e..2ad5ffe 100644
> > --- a/fs/nfsd/nfssvc.c
> > +++ b/fs/nfsd/nfssvc.c
> > @@ -307,33 +307,37 @@ static void set_max_drc(void)
> >  	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 target;
> > +	unsigned long bytes;
> > +
> > +	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;
> 
>   Should use target = i.totalram << (PAGE_SHIFT - 12);
> 
>   target = i.totalram << PAGE_SHIFT; and 
>   target <<= 12;
>   means target = i.totalram << (PAGE_SHIFT + 12);

Yes, thanks for catching that.

Also, splitting up the calculation as I did above risks overflow at the
first step.

I'll fix that....

--b.

  reply	other threads:[~2012-02-01 21:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 22:42 [PATCH 1/2] nfsd: cleanup setting of default max_block_size J. Bruce Fields
2012-01-30 22:42 ` [PATCH 2/2] nfsd: fix default iosize calculation on 32bit J. Bruce Fields
2012-01-30 22:47   ` J. Bruce Fields
2012-01-31  1:11 ` [PATCH 1/2] nfsd: cleanup setting of default max_block_size Mi Jinlong
2012-02-01 21:46   ` J. Bruce Fields [this message]
2012-02-03 20:49     ` J. Bruce Fields
2012-02-03 16:24       ` Mi Jinlong
2012-02-04  2:16         ` J. Bruce Fields
2012-02-04 12:14           ` Mi Jinlong

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=20120201214656.GA19075@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mijinlong@cn.fujitsu.com \
    /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.