JFFS2 & NAND failure
Artem B. Bityuckiy
dedekind at yandex.ru
Mon Apr 4 08:58:16 EDT 2005
Estelle HAMMACHE wrote:
> Hi everyone,
>
> it seems there is a problem with jffs2_wbuf_recover and
> the wbuf_sem...
>
> jffs2_flash_writev
> ** down_write(&c->wbuf_sem); !!!
> ** __jffs2_flush_wbuf
> **** jffs2_wbuf_recover
> ****** jffs2_block_refile
> ******** nextblock = NULL;
> ****** jffs2_reserve_space_gc
> ******** jffs2_do_reserve_space
> ********** jffs2_erase_pending_blocks
> ************ jffs2_mark_erased_block
> ************** jffs2_flash_read
> **************** down_read(&c->wbuf_sem); !!!
>
> I believe that when checking a newly erased block, the
> wbuf should not be used anyway, so this is probably easy to
> correct. Is it ok to create a jffs2_flash_read_nobuf function
> and call it only from jffs2_mark_erased_block ?
>
Hello Estelle,
I've found that JFFS2 has wbuf problems on SMP again. The reason are the
changes which were made to fix the deadlock you've spotted.
The wbuf_sem rwsem doesn't help if it is locked after you've read flash
because by the time you copy data from wbuf it might have been chaneged.
I.e:
/* A part of our data is in wbuf at this point */
mtd->read_ecc(...)
/* At this point another CPU fills wbuf and flushes it, so in contains
the wrong data */
down_read(&c->wbuf_sem)
memcpy(buf, c->wbuf, len)
up_read(&c->wbuf_sem)
I'd prefer not to use jffs2_flash_read() in jffs2_mark_erased_block()
but to directly read flash since it wbuf anyway must not correspond to a
newly erased block.
Please, look at the attached patch.
--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: wbuf_sem-1.diff
Url: http://lists.infradead.org/pipermail/linux-mtd/attachments/20050404/7fab643a/attachment.pl
More information about the linux-mtd
mailing list