From: Boaz Harrosh <bharrosh@panasas.com>
To: Idan Kedar <idank@tonian.com>
Cc: <linux-fsdevel@vger.kernel.org>, <osd-dev@open-osd.org>,
<solo@tonian.com>, <bhalevy@tonian.com>, <ilya@tonian.com>
Subject: Re: [PATCH] exofs: clean up the correct page collection on write error
Date: Fri, 30 Nov 2012 16:10:40 +0200 [thread overview]
Message-ID: <50B8BE60.6090009@panasas.com> (raw)
In-Reply-To: <1353941346-20598-1-git-send-email-idank@tonian.com>
On 11/26/2012 04:49 PM, Idan Kedar wrote:
> if ore_write() fails, we would unlock the pages of pcol, which is now
> empty, rather than pcol_copy which owns the pages when ore_write() is
> called. this means that no pages will actually be unlocked
> (pcol.nr_pages == 0) and the writing process (more accurately, the
> syncing process) will hang waiting for a writeback notification that
> never comes.
>
> moreover, if ore_write() fails, pcol_free() is called for pcol, whereas
> pcol_copy is the object owning the ore_io_state, thus leaking the
> ore_io_state.
>
> Signed-off-by: Idan Kedar <idank@tonian.com>
Thanks Idan, good catch.
I have simplified your patch a bit, see below. But basically it
is all the same. Please check me out
> ---
> fs/exofs/inode.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
> index b561810..5106213 100644
> --- a/fs/exofs/inode.c
> +++ b/fs/exofs/inode.c
> @@ -628,7 +628,7 @@ static int write_exec(struct page_collect *pcol)
> {
> struct exofs_i_info *oi = exofs_i(pcol->inode);
> struct ore_io_state *ios;
> - struct page_collect *pcol_copy = NULL;
> + struct page_collect *pcol_copy = NULL, *active_pcol = pcol;
> int ret;
>
> if (!pcol->pages)
> @@ -658,6 +658,7 @@ static int write_exec(struct page_collect *pcol)
>
> /* pages ownership was passed to pcol_copy */
> _pcol_reset(pcol);
> + active_pcol = pcol_copy;
>
> ret = _maybe_not_all_in_one_io(ios, pcol_copy, pcol);
> if (unlikely(ret))
> @@ -676,8 +677,8 @@ static int write_exec(struct page_collect *pcol)
> return 0;
>
> err:
> - _unlock_pcol_pages(pcol, ret, WRITE);
> - pcol_free(pcol);
> + _unlock_pcol_pages(active_pcol, ret, WRITE);
> + pcol_free(active_pcol);
> kfree(pcol_copy);
>
> return ret;
From: Idan Kedar <idank@tonian.com>
Subject: [PATCH] exofs: clean up the correct page collection on write error
if ore_write() fails, we would unlock the pages of pcol, which is now
empty, rather than pcol_copy which owns the pages when ore_write() is
called. this means that no pages will actually be unlocked
(pcol.nr_pages == 0) and the writing process (more accurately, the
syncing process) will hang waiting for a writeback notification that
never comes.
moreover, if ore_write() fails, pcol_free() is called for pcol, whereas
pcol_copy is the object owning the ore_io_state, thus leaking the
ore_io_state.
[Boaz]
I have simplified Idan's original patch a bit, everything else still
holds
Signed-off-by: Idan Kedar <idank@tonian.com>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
fs/exofs/inode.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 19dcc7b..8d82624 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -676,8 +676,10 @@ static int write_exec(struct page_collect *pcol)
return 0;
err:
- _unlock_pcol_pages(pcol, ret, WRITE);
- pcol_free(pcol);
+ if (!pcol_copy) /* Failed before ownership transfer */
+ pcol_copy = pcol;
+ _unlock_pcol_pages(pcol_copy, ret, WRITE);
+ pcol_free(pcol_copy);
kfree(pcol_copy);
return ret;
--
1.7.10.2.677.gb6bc67f
next prev parent reply other threads:[~2012-11-30 14:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 14:49 [PATCH] exofs: clean up the correct page collection on write error Idan Kedar
2012-11-30 14:10 ` Boaz Harrosh [this message]
2012-11-30 14:15 ` Boaz Harrosh
2012-11-30 14:26 ` [PATCH] exofs: don't leak io_state and pages on read error Boaz Harrosh
2012-11-30 14:28 ` [PATCH] exofs: Remove dead code in read_exec Boaz Harrosh
2012-12-02 9:57 ` [PATCH] exofs: clean up the correct page collection on write error Idan Kedar
2012-12-02 12:58 ` Boaz Harrosh
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=50B8BE60.6090009@panasas.com \
--to=bharrosh@panasas.com \
--cc=bhalevy@tonian.com \
--cc=idank@tonian.com \
--cc=ilya@tonian.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=osd-dev@open-osd.org \
--cc=solo@tonian.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.