* JFFS2: Return values of jffs2_block_check_erase error paths
@ 2008-03-12 19:29 Anders Grafström
2008-04-10 20:07 ` Anders Grafström
0 siblings, 1 reply; 3+ messages in thread
From: Anders Grafström @ 2008-03-12 19:29 UTC (permalink / raw)
To: linux-mtd
It looks the error paths in jffs2_block_check_erase() have wrong return values.
A block that failed to be erased never gets marked as bad.
Any comments on this patch?
Anders
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index a1db918..23e9dd6 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -350,9 +350,11 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
break;
} while(--retlen);
c->mtd->unpoint(c->mtd, ebuf, jeb->offset, c->sector_size);
- if (retlen)
+ if (retlen) {
printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
*wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf));
+ return -EIO;
+ }
return 0;
}
do_flash_read:
@@ -373,10 +375,12 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
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);
+ ret = -EIO;
goto fail;
}
if (retlen != readlen) {
printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen);
+ ret = -EIO;
goto fail;
}
for (i=0; i<readlen; i += sizeof(unsigned long)) {
@@ -385,6 +389,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
if (*datum + 1) {
*bad_offset += i;
printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset);
+ ret = -EIO;
goto fail;
}
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: JFFS2: Return values of jffs2_block_check_erase error paths
2008-03-12 19:29 JFFS2: Return values of jffs2_block_check_erase error paths Anders Grafström
@ 2008-04-10 20:07 ` Anders Grafström
2008-04-10 21:03 ` Joakim Tjernlund
0 siblings, 1 reply; 3+ messages in thread
From: Anders Grafström @ 2008-04-10 20:07 UTC (permalink / raw)
To: linux-mtd
Anders Grafström wrote:
> It looks like the error paths in jffs2_block_check_erase() have wrong return values.
> A block that failed to be erased never gets marked as bad.
>
> Any comments on this patch?
>
> Anders
>
>
> diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
> index a1db918..23e9dd6 100644
> --- a/fs/jffs2/erase.c
> +++ b/fs/jffs2/erase.c
> @@ -350,9 +350,11 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
> break;
> } while(--retlen);
> c->mtd->unpoint(c->mtd, ebuf, jeb->offset, c->sector_size);
> - if (retlen)
> + if (retlen) {
> printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
> *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf));
> + return -EIO;
> + }
> return 0;
> }
> do_flash_read:
> @@ -373,10 +375,12 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
> 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);
> + ret = -EIO;
> goto fail;
> }
> if (retlen != readlen) {
> printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen);
> + ret = -EIO;
> goto fail;
> }
> for (i=0; i<readlen; i += sizeof(unsigned long)) {
> @@ -385,6 +389,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
> if (*datum + 1) {
> *bad_offset += i;
> printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset);
> + ret = -EIO;
> goto fail;
> }
> }
Nobody looked at this?
This issue caused a corrupt file system.
/Anders
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: JFFS2: Return values of jffs2_block_check_erase error paths
2008-04-10 20:07 ` Anders Grafström
@ 2008-04-10 21:03 ` Joakim Tjernlund
0 siblings, 0 replies; 3+ messages in thread
From: Joakim Tjernlund @ 2008-04-10 21:03 UTC (permalink / raw)
To: 'Anders Grafström', linux-mtd
> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf
> Of Anders Grafström
> Sent: den 10 april 2008 22:08
> To: linux-mtd@lists.infradead.org
> Subject: Re: JFFS2: Return values of jffs2_block_check_erase error paths
>
> Anders Grafström wrote:
> > It looks like the error paths in jffs2_block_check_erase() have wrong return values.
> > A block that failed to be erased never gets marked as bad.
> >
> > Any comments on this patch?
> >
> > Anders
> >
> >
> > diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
> > index a1db918..23e9dd6 100644
> > --- a/fs/jffs2/erase.c
[SNIP]
>
>
> Nobody looked at this?
> This issue caused a corrupt file system.
>
> /Anders
Looks good to me, but I think you should add your own signoff, write a
proper commit message and send it to Linus/Andrew as David appears busy.
Signed-off-by: Joakim Tjernlund <Joakim.Tjenrlund@transmode.se>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-10 21:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-12 19:29 JFFS2: Return values of jffs2_block_check_erase error paths Anders Grafström
2008-04-10 20:07 ` Anders Grafström
2008-04-10 21:03 ` Joakim Tjernlund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox