2011-01-24 12:51:44 "sync" not honored with ext2/vfat on mtdblock?
Andrew Kohlsmith (CANADA)
Message: 97644
I'm trying to set up some persistent storage on the NOR flash on our system. It's a 2009R1.1-RC4 based system running the 2.6.28-10-ADI-2009R1.1 kernel. The MTD partition is only 512kB.
mkfs.ext2 -m0 /dev/mtdblock1 returns no errors, and I'm using "-o sync" to mount the filesystem with synchronous access.
(I've originally tried with the vfat filesystem, but it has the same behaviour.)
The filesystem works fine, /proc/mounts reflects that "sync" is in effect, but if I do not umount the filesystem before rebooting (or an unexpected reboot occurs), the changes made are not seen after the reboot. If I issue a sync command manually I see the same effect; I must umount the filesystem in order to have the changes persistent.
This is counter to my experience on desktop systems, even desktop systems using USB flash drives or MMC adapters. Looking at the ext2 code there is also a 'dirsync' flag for synchronous metadata access, but this flag does not seem to show any different behaviour when used.
Is this an expected behaviour? What is the recommended way to create a small persistent filesystem on an mtd device that does not have to be explicitly unmounted to have changes kept? This seems like it'd be a solved problem for any embedded system, but so far the solution has eluded me.
QuoteReplyEditDelete
2011-01-24 14:35:51 Re: "sync" not honored with ext2/vfat on mtdblock?
Mike Frysinger (UNITED STATES)
Message: 97648
i would suspect that the fs doesnt matter and that the "sync" option largely does not work with flash filesystems. i'd have to dig into it to find out ...
however, why exactly are you trying to use ext2/vfat on a flash device ? those, by design, are terrible at handling flash. they have no wear leveling nor handle power loss. why not use a proper jffs2 ?
QuoteReplyEditDelete
2011-01-24 15:17:10 Re: "sync" not honored with ext2/vfat on mtdblock?
Andrew Kohlsmith (CANADA)
Message: 97650
It'd mean building in the jffs2 tools for handling what is a mostly RO file system. Actually that's pretty much my solution; mount it RO and remount RW for the "once in a blue moon" writes (which only come through a defined network API).
I'll certainly take a look at JFFS2, it just seemed like overkill for this specific application.
QuoteReplyEditDelete
2011-01-24 15:21:50 Re: "sync" not honored with ext2/vfat on mtdblock?
Mike Frysinger (UNITED STATES)
Message: 97651
you dont need any mtd-utils at runtime. i'm fairly certain you can simply mount the mtd as jffs2 and the fs will take care of recovering into a sane state. or at least erase the whole device and then mount it blank as jffs2. the flash_eraseall tool is trivially small, and i think busybox has an implementation.
QuoteReplyEditDelete