mmap on jffs2

David Woodhouse dwmw2 at infradead.org
Wed Apr 23 03:30:25 EDT 2003


On Tue, 2003-04-22 at 10:33, Jörn Engel wrote:
> AFAIK (someone please correct me) jffs2 does not support mmap. I don't
> remember any technical reason, so it seems as if noone cared enough to
> implement it.

We support readonly mmap. What we don't support is shared writable mmap,
where any time you change a byte in your mapped version, you end up
writing the _whole_ page out to flash, because we can't tell how dirty
the page is.

This is for three reasons -- firstly it's hard to ensure that we'll
actually have enough space on the flash to write out a page when it's
dirty. Secondly it's _very_ hard to make sure we've allocated all the
memory in advance that we'll need for node information, because the
writepage() function would get called under memory pressure and we
mustn't reenter the allocation routines, and thirdly if you're writing
to a flash file system you really ought to be paying more attention and
limiting your writes.

I suggest you do what Berkeley DB does -- mmap the file readonly for
direct access, but do writes with a write() system call. It does that on
all file systems anyway, for reasons of reliability.

> You can do the work yourself, pay someone to do it or wait and hope
> that someone else does it. As always.

It's a _lot_ of work, for little perceivable gain.

-- 
dwmw2





More information about the linux-mtd mailing list