Patchwork [JFFS2] Fix corruption when flash erase/write failure

login
register
mail settings
Submitter Joakim Tjernlund
Date May 28, 2009, 3:43 p.m.
Message ID <1243525439-32485-1-git-send-email-Joakim.Tjernlund@transmode.se>
Download mbox | patch
Permalink /patch/27797/
State New, archived
Headers show

Comments

Joakim Tjernlund - May 28, 2009, 3:43 p.m.
Erase errors such as:
"Newly-erased block contained word 0xa4ef223e at offset 0x0296a014"
and failure to write the clean marker,
moves the offending erase block to erasing list before calling
jffs2_erase_failed(). This is bad as jffs2_erase_failed() will
also move the block to the bad_list, but is now moving the
wrong block, causing FS corruption.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 fs/jffs2/erase.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
Joakim Tjernlund - May 29, 2009, 9:37 a.m.
I think this is 2.6.30 material, please comment soon(or send upstream)

 Jocke

Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote on 28/05/2009 17:43:59:
>
> Erase errors such as:
> "Newly-erased block contained word 0xa4ef223e at offset 0x0296a014"
> and failure to write the clean marker,
> moves the offending erase block to erasing list before calling
> jffs2_erase_failed(). This is bad as jffs2_erase_failed() will
> also move the block to the bad_list, but is now moving the
> wrong block, causing FS corruption.
>
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>  fs/jffs2/erase.c |    7 -------
>  1 files changed, 0 insertions(+), 7 deletions(-)
>
> diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
> index 51024ac..b082655 100644
> --- a/fs/jffs2/erase.c
> +++ b/fs/jffs2/erase.c
> @@ -488,13 +488,6 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
>     return;
>
>  filebad:
> -   mutex_lock(&c->erase_free_sem);
> -   spin_lock(&c->erase_completion_lock);
> -   /* Stick it on a list (any list) so erase_failed can take it
> -      right off again.  Silly, but shouldn't happen often. */
> -   list_move(&jeb->list, &c->erasing_list);
> -   spin_unlock(&c->erase_completion_lock);
> -   mutex_unlock(&c->erase_free_sem);
>     jffs2_erase_failed(c, jeb, bad_offset);
>     return;
>
> --
> 1.6.2.3
>

Patch

diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index 51024ac..b082655 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -488,13 +488,6 @@  static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
 	return;
 
 filebad:
-	mutex_lock(&c->erase_free_sem);
-	spin_lock(&c->erase_completion_lock);
-	/* Stick it on a list (any list) so erase_failed can take it
-	   right off again.  Silly, but shouldn't happen often. */
-	list_move(&jeb->list, &c->erasing_list);
-	spin_unlock(&c->erase_completion_lock);
-	mutex_unlock(&c->erase_free_sem);
 	jffs2_erase_failed(c, jeb, bad_offset);
 	return;