Mount failed after clean mount & umount test
Hi
I have a question about JFFS2
At OneNAND MTD debugging, there's some problem on JFFS2 mount & umount
I write script as following
#!/bin/sh
/mtd-utils/eraseall /dev/mtd4
mount -t jffs2 /dev/mtdblock4 /mnt
umount /mnt
mount -t jffs2 /dev/mtdblock4 /mnt
It printes following message
nr_free_blocks = 0, empty_block = 0, bad_blocks = 0, nr_blocks = 256 Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes empty_blocks 0, bad_blocks 0, c->nr_blocks 256
mount: Mounting /dev/mtdblock4 on /mnt failed: Input/output error
It always failed on OneNAND MTD but in below script there's no problem.
#!/bin/sh
/rfs-utils/eraseall /dev/mtd4
mount -t jffs2 /dev/mtdblock4 /mnt
# add dummy file on JFFS2 touch /mnt/jffs2_filesystem umount /mnt mount -t jffs2 /dev/mtdblock4 /mnt
What is the difference between? The only one dummy file is created.
Regards,
Kyungmin Park
Hello Kyungmin
Your problem might be the same OOB free region problem I met a month ago.
(Before EBH) JFFS2 tried to write 8-byte cleanmarker node into the first free region at OOB. If you had less than 8 byes, you could cut the length into 4 bytes. Then cleanmarker contained just JFFS2 magic and nodetype.
OneNAND has free byte regions of 2 and 3 bytes. One cannot fit the magic and nodetype together into either of them alone.
Currently the 3 byte regions seem also unusable since writing into them has a side effect of changing spare area HW ECC bytes from 0xFF to something else. As a result jffs2_check_oob_empty() will fail, since there are non 0xFF bytes outside the cleanmarker area.
I am myself using only 2 byte free regions where one can write without changingh any other bytes and jffs2_check_oob_empty() works. I have to also use separate patch for wbuf.c to make it able to write and read cleanmarker from multiple 2 byte fragments.
I am using at onenand_oob_64:
.oobfree = {
{14, 2}, {30, 2}, {46, 2}, {62, 2},
}Alternatively one could teach MTD to understand HW ECC bytes and separate which ECC bytes are for main area and which for spare area.
Below is also a oob write verify which I used to make sure the clean marker/EBH is written correctly.
Jarkko
---
Index: drivers/mtd/onenand/onenand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/onenand/onenand_base.c,v retrieving revision 1.15
mtd/onenand/onenand_base.c +43 -4
@@ -761,6 +761,36 @@ out:#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE /** +* onenand_verify_oob - [GENERIC] verify the oob contents after a write +* @param mtd MTD device structure +* @param buf the databuffer to verify +* @param to offset to read from +* @param len number of bytes to read and compare +* +*/ +static int onenand_verify_oob (struct mtd_info *mtd,const u_char *buf,loff_t to,int len) +{ +struct onenand_chip *this = mtd->priv; +char *readp = this->page_buf; +int column = to & (mtd->oobsize -1 ); +int status, i; + + this->command (mtd,ONENAND_CMD_READOOB , to, mtd->oobsize); +onenand_update_bufferram (mtd, to,0 ); + status = this->wait (mtd,FL_READING ); +if (status) +return status; + + this->read_bufferram (mtd,ONENAND_SPARERAM , readp, column, len); + +for (i =0 ; i < len; i++) +if (buf[i] !=0xFF && buf[i] != readp[i]) +return -EBADMSG ; + +return 0 ; +} + +/** * onenand_verify_page - [GENERIC] verify the chip contents after a write * @param mtd MTD device structure * @param buf the databuffer to verify
@@ -792,6 +822,7 @@ static int onenand_verify_page(struct mt }#else #define onenand_verify_page (...) (0) +#define onenand_verify_oob (...) (0)#endif #define NOTALIGNED (x) ((x & (mtd->oobblock - 1)) != 0)
@@ -911,7 +942,7 @@ static int onenand_write_oob(struct mtd_ size_t *retlen, const u_char *buf) { struct onenand_chip *this = mtd->priv; -int column, status; +int column, ret =0 ;int written =0 ;DEBUG (MTD_DEBUG_LEVEL3 ,"onenand_write_oob: to = 0x%08x, len = %i\n" , (unsigned int ) to, (int ) len);
@@ -943,9 +974,17 @@ static int onenand_write_oob(struct mtd_onenand_update_bufferram (mtd, to,0 ); - status = this->wait (mtd,FL_WRITING ); -if (status) + ret = this->wait (mtd,FL_WRITING ); +if (ret) { +DEBUG (MTD_DEBUG_LEVEL0 ,"onenand_write_oob: write filaed %d\n" , ret); goto out; + } + + ret =onenand_verify_oob (mtd, buf, to, thislen); +if (ret) { +DEBUG (MTD_DEBUG_LEVEL0 ,"onenand_write_oob: verify failed %d\n" , ret); + goto out; + } written += thislen;
@@ -962,7 +1001,7 @@ out: *retlen = written; -return 0 ; +return ret; }/**