public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Suresh Jayaraman <sjayaraman@suse.de>
Cc: David Howells <dhowells@redhat.com>,
	Linux NFS mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [RFC][PATCH] nfs: don't assume fscache_acquire_cookie will always succeed
Date: Wed, 20 Jan 2010 16:35:06 -0500	[thread overview]
Message-ID: <1264023306.7799.9.camel@localhost> (raw)
In-Reply-To: <4B56F565.7080104@suse.de>

On Wed, 2010-01-20 at 17:51 +0530, Suresh Jayaraman wrote: 
> We seem to be assuming fscache_acquire_cookie will always succeed and will
> obtain a valid cookie. But, under low memory conditions kmem_cache_alloc
> could fail and that would leave nfsi->fscache being set to NULL.
> 
> This could lead to a possibility of a page with PG_fscache flag set but
> cookie not set(i.e. NULL). This inconsistency could trigger a kernel BUG in
> nfs_fscache_release_page() and other places as we do BUG_ON(!cookie), I think.
> 
> I'm aware that there are other places where we would need such checks, but
> wanted to validate this patch before getting on to them.
> 
> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
> ---
> 
>  fs/nfs/client.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/nfs/client.c b/fs/nfs/client.c
> index ee77713..7776e8a 100644
> --- a/fs/nfs/client.c
> +++ b/fs/nfs/client.c
> @@ -155,6 +155,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
>  		clp->cl_machine_cred = cred;
>  
>  	nfs_fscache_get_client_cookie(clp);
> +	if (!clp->fscache)
> +		goto error_cleanup;
>  
>  	return clp;
>  

That looks like it will always fail when mounting without -ofscache
and/or compiling without CONFIG_NFS_FSCACHE.

It seems like a better idea to have nfs_fscache_get_client_cookie()
explicitly set clp->fscache to ERR_PTR(-ENOMEM) value if the
fscache_acquire_cookie fails.

Cheers
  Trond

  reply	other threads:[~2010-01-20 21:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20 12:21 [RFC][PATCH] nfs: don't assume fscache_acquire_cookie will always succeed Suresh Jayaraman
2010-01-20 21:35 ` Trond Myklebust [this message]
2010-01-21 11:07 ` David Howells
2010-01-21 11:41   ` Suresh Jayaraman
2010-01-22 12:52   ` Suresh Jayaraman
2010-01-23  3:48     ` David Howells

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=1264023306.7799.9.camel@localhost \
    --to=trond.myklebust@netapp.com \
    --cc=dhowells@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=sjayaraman@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox