From patchwork Tue Jan 15 22:21:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3.5.y.z, extended, stable] Patch "NFS: Ensure that we free the rpc_task after read and write" has been added to staging queue Date: Tue, 15 Jan 2013 12:21:36 -0000 From: Herton Ronaldo Krzesinski X-Patchwork-Id: 212337 Message-Id: <1358288496-31237-1-git-send-email-herton.krzesinski@canonical.com> To: Trond Myklebust Cc: Tejun Heo , Bruce Fields , kernel-team@lists.ubuntu.com, Weston Andros Adamson This is a note to let you know that I have just added a patch titled NFS: Ensure that we free the rpc_task after read and write to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree which can be found at: http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 3.5.y.z tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Herton ------ >From ea322d29d86d9afec9a7ceca850396e69d6cc6ea Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Fri, 4 Jan 2013 12:47:04 -0500 Subject: [PATCH] NFS: Ensure that we free the rpc_task after read and write cleanups are done commit 6db6dd7d3fd8f7c765dabc376493d6791ab28bd6 upstream. 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. Signed-off-by: Trond Myklebust Cc: Weston Andros Adamson Cc: Tejun Heo Cc: Bruce Fields [ herton: adjust context ] Signed-off-by: Herton Ronaldo Krzesinski --- fs/nfs/read.c | 10 +++++++--- fs/nfs/write.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) -- 1.7.9.5 diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 86ced78..b151ad5 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); } static diff --git a/fs/nfs/write.c b/fs/nfs/write.c index bce88ac..a440deb 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -124,12 +124,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); } static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)