public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] JFFS2: fix deadlock on error path
@ 2007-03-13 12:19 Artem Bityutskiy
  2007-03-17 10:48 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Bityutskiy @ 2007-03-13 12:19 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-mtd

From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Subject: [PATCH] JFFS2: fix deadlock on error path

When the MTD driver returns write failure, the following deadlock
occures:

We are in __jffs2_flush_wbuf(), we hold &c->wbuf_sem. Write failure.
jffs2_wbuf_recover()->jffs2_reserve_space_gc()->jffs2_do_reserve_space()
->jffs2_erase_pending_blocks()->jffs2_flash_read()

and it tries to lock &c->wbuf_sem again. Deadlock.

Reported-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 fs/jffs2/erase.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index ad01210..6b1f7be 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -333,7 +333,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
 
 		*bad_offset = ofs;
 
-		ret = jffs2_flash_read(c, ofs, readlen, &retlen, ebuf);
+		ret = c->mtd->read(c->mtd, ofs, readlen, &retlen, ebuf);
 		if (ret) {
 			printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret);
 			goto fail;
-- 
1.4.4.2

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] JFFS2: fix deadlock on error path
  2007-03-13 12:19 [PATCH] JFFS2: fix deadlock on error path Artem Bityutskiy
@ 2007-03-17 10:48 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2007-03-17 10:48 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-mtd

On Tue, 2007-03-13 at 14:19 +0200, Artem Bityutskiy wrote:
> From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
> Subject: [PATCH] JFFS2: fix deadlock on error path
> 
> When the MTD driver returns write failure, the following deadlock
> occures:
> 
> We are in __jffs2_flush_wbuf(), we hold &c->wbuf_sem. Write failure.
> jffs2_wbuf_recover()->jffs2_reserve_space_gc()->jffs2_do_reserve_space()
> ->jffs2_erase_pending_blocks()->jffs2_flash_read()
> 
> and it tries to lock &c->wbuf_sem again. Deadlock.
> 
> Reported-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

David,

please, send this patch to Linus as it is critical enough.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-17 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-13 12:19 [PATCH] JFFS2: fix deadlock on error path Artem Bityutskiy
2007-03-17 10:48 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox