[PATCH 2/2] mtd: cfi: fix writebufsize initialization

Anatolij Gustschin agust at denx.de
Fri Feb 11 07:04:13 EST 2011

Hi Guillaume,

On Thu, 10 Feb 2011 16:13:31 +0100
Guillaume LECERF <glecerf at gmail.com> wrote:

> Hi Anatolij.
> 2011/2/10 Anatolij Gustschin <agust at denx.de>:
> > When initializing mtd->writebufsize, we must take into account
> > possible flash chip interleaving. Wrong writebufsize initialization
> > caused UBIFS recovery issues resulting in unmountable UBIFS file
> > system on NOR flash partitions.
> > -       mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize;
> > +       mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
> This is exactly what I told you (
> http://lists.infradead.org/pipermail/linux-mtd/2010-December/033559.html
> ).

Yes, this is true. But it couldn't have worked without further fixes
for UBI:

ubiattach -m 8 -d 0 /dev/ubi_ctrl
UBI: attaching mtd8 to ubi0
UBI: physical eraseblock size:   262144 bytes (256 KiB)
UBI: logical eraseblock size:    262016 bytes
UBI: smallest flash I/O unit:    128
UBI: sub-page size:              1
UBI: VID header offset:          64 (aligned 64)
UBI: data offset:                128
UBI error: validate_ec_hdr: bad VID header offset 128, expected 64
UBI error: validate_ec_hdr: bad EC header
Call Trace:
[c3fbbc40] [c0009220] show_stack+0xac/0x1d8 (unreliable)
[c3fbbc90] [c0009378] dump_stack+0x2c/0x44
[c3fbbca0] [c0257d90] ubi_io_read_ec_hdr+0x2d8/0x3b4
[c3fbbcd0] [c025b868] ubi_scan+0x1b4/0xc80
[c3fbbd50] [c02513d8] ubi_attach_mtd_dev+0x5e0/0xf1c
[c3fbbe50] [c0252194] ctrl_cdev_ioctl+0x164/0x234
[c3fbbe90] [c00c0bd4] vfs_ioctl+0x48/0xa8
[c3fbbea0] [c00c0e58] do_vfs_ioctl+0x98/0x704
[c3fbbf10] [c00c1514] sys_ioctl+0x50/0x84
[c3fbbf40] [c0013564] ret_from_syscall+0x0/0x38
--- Exception: c01 at 0xff38b10
    LR = 0xffec8a8
UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -22
ubiattach: error!: cannot attach mtd8
           error 22 (Invalid argument)

It works for me now when I use recent UBIFS patches from Artem
([PATCH v2 0/5] UBIFS: fix recovery on CFI NOR).

> Could you examine the (not compilable) patches I attached and merge
> them with your current patch ?

Currently we are seeing two other issues with UBIFS recovery after
power cuts, but these seem not to be caused by to big write buffer.
I'm looking for the reason for the observed corruptions now and
will look at your patches later.


More information about the linux-mtd mailing list