Linux NFS development
 help / color / mirror / Atom feed
From: Bruce Fields <bfields@fieldses.org>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org,
	Weston Andros Adamson <dros@netapp.com>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 2/3] NFS: Ensure that we free the rpc_task after read and write cleanups are done
Date: Fri, 4 Jan 2013 13:29:58 -0500	[thread overview]
Message-ID: <20130104182958.GA13471@fieldses.org> (raw)
In-Reply-To: <1357323302-12944-2-git-send-email-Trond.Myklebust@netapp.com>

On Fri, Jan 04, 2013 at 01:15:01PM -0500, Trond Myklebust wrote:
> This patch ensures that we free the rpc_task after the cleanup callbacks
> are done in order to avoid a deadlock problem that can be triggered if
> the callback needs to wait for another workqueue item to complete.

Makes sense to me!

(Dumb question: so read and write data are the only two cases where the
calldata embeds an rpc task?  Why is that?)

--b.

> 
> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> Cc: Weston Andros Adamson <dros@netapp.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Bruce Fields <bfields@fieldses.org>
> Cc: stable@vger.kernel.org [>= 3.5]
> ---
>  fs/nfs/read.c  | 10 +++++++---
>  fs/nfs/write.c | 10 +++++++---
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/nfs/read.c b/fs/nfs/read.c
> index b6bdb18..a5e5d98 100644
> --- a/fs/nfs/read.c
> +++ b/fs/nfs/read.c
> @@ -91,12 +91,16 @@ void nfs_readdata_release(struct nfs_read_data *rdata)
>  	put_nfs_open_context(rdata->args.context);
>  	if (rdata->pages.pagevec != rdata->pages.page_array)
>  		kfree(rdata->pages.pagevec);
> -	if (rdata != &read_header->rpc_data)
> -		kfree(rdata);
> -	else
> +	if (rdata == &read_header->rpc_data) {
>  		rdata->header = NULL;
> +		rdata = NULL;
> +	}
>  	if (atomic_dec_and_test(&hdr->refcnt))
>  		hdr->completion_ops->completion(hdr);
> +	/* Note: we only free the rpc_task after callbacks are done.
> +	 * See the comment in rpc_free_task() for why
> +	 */
> +	kfree(rdata);
>  }
>  EXPORT_SYMBOL_GPL(nfs_readdata_release);
>  
> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> index b673be3..c483cc5 100644
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -126,12 +126,16 @@ void nfs_writedata_release(struct nfs_write_data *wdata)
>  	put_nfs_open_context(wdata->args.context);
>  	if (wdata->pages.pagevec != wdata->pages.page_array)
>  		kfree(wdata->pages.pagevec);
> -	if (wdata != &write_header->rpc_data)
> -		kfree(wdata);
> -	else
> +	if (wdata == &write_header->rpc_data) {
>  		wdata->header = NULL;
> +		wdata = NULL;
> +	}
>  	if (atomic_dec_and_test(&hdr->refcnt))
>  		hdr->completion_ops->completion(hdr);
> +	/* Note: we only free the rpc_task after callbacks are done.
> +	 * See the comment in rpc_free_task() for why
> +	 */
> +	kfree(wdata);
>  }
>  EXPORT_SYMBOL_GPL(nfs_writedata_release);
>  
> -- 
> 1.7.11.7
> 

  parent reply	other threads:[~2013-01-04 18:30 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 15:33 nfsd oops on Linus' current tree Dave Jones
2012-12-21 18:08 ` J. Bruce Fields
2012-12-21 18:40   ` Myklebust, Trond
2012-12-21 23:08     ` J. Bruce Fields
2012-12-21 23:15       ` Myklebust, Trond
2012-12-21 23:26         ` J. Bruce Fields
2012-12-21 23:36           ` Myklebust, Trond
2012-12-21 23:45             ` J. Bruce Fields
2013-01-03 16:28               ` Adamson, Dros
2013-01-03 20:11                 ` J. Bruce Fields
2013-01-03 20:27                   ` Adamson, Dros
2013-01-03 20:52                     ` J. Bruce Fields
2013-01-03 22:15                       ` Tejun Heo
2013-01-03 22:08                   ` Tejun Heo
2013-01-03 22:12                     ` Myklebust, Trond
2013-01-03 22:26                       ` Tejun Heo
2013-01-03 22:34                         ` Tejun Heo
2013-01-03 23:11                         ` Myklebust, Trond
     [not found]                         ` <1357254692.55285.33.camel@lade.trondhjem.org>
2013-01-03 23:26                           ` Myklebust, Trond
2013-01-04 17:11                             ` Adamson, Dros
2013-01-04 18:15                               ` [PATCH 1/3] SUNRPC: Ensure that we free the rpc_task after cleanups are done Trond Myklebust
2013-01-04 18:15                                 ` [PATCH 2/3] NFS: Ensure that we free the rpc_task after read and write " Trond Myklebust
2013-01-04 18:15                                   ` [PATCH 3/3] SUNRPC: Partial revert of commit 168e4b39d1afb79a7e3ea6c3bb246b4c82c6bdb9 Trond Myklebust
2013-01-04 18:29                                   ` Bruce Fields [this message]
2013-01-04 18:52                                     ` [PATCH 2/3] NFS: Ensure that we free the rpc_task after read and write cleanups are done Myklebust, Trond
2013-01-04 19:12                                       ` Bruce Fields
2013-01-07 17:47                                 ` [PATCH 1/3] SUNRPC: Ensure that we free the rpc_task after " Tejun Heo
2013-01-07 17:54                                   ` Myklebust, Trond
2013-01-03 22:03                 ` nfsd oops on Linus' current tree Tejun Heo
2013-01-03 23:08                   ` J. Bruce Fields
2012-12-22  0:48   ` [PATCH] Revert "nfsd: warn on odd reply state in nfsd_vfs_read" J. Bruce Fields

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=20130104182958.GA13471@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Trond.Myklebust@netapp.com \
    --cc=dros@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tj@kernel.org \
    /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