[JFFS2] fix deadlock on error path
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 21 Mar 2007 09:07:05 +0000 (11:07 +0200)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 17 Apr 2007 17:53:51 +0000 (13:53 -0400)
When the MTD driver returns write failure, the following deadlock
occurs:

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>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
fs/jffs2/erase.c

index ad0121088dde3883ec964e6e90568b0abffe4733..6b1f7bee3653fb7aeea312caaea69d1eb7204a8e 100644 (file)
@@ -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;