[PATCH] Fix hanging close for /dev/mtd

Jörn Engel joern at logfs.org
Wed Jun 13 13:58:32 EDT 2007


On Wed, 13 June 2007 19:16:31 +0200, Joakim Tjernlund wrote:
> > 
> > I can see two sane alternatives.
> > 
> > /*
> >  * An MTD driver may return from mtd->write() calls before the data has
> >  * safely been written to the medium.  Any amount of dirty data may be
> >  * cached by either the driver or the device.  If a filesystem depends
> >  * on the data being safely on the medium, it has to explicitly call
> >  * mtd->sync().
> >  */
> > 
> > /*
> >  * Mtd->write() and mtd->erase() methods may only return if the data has
> >  * been safely written to the device.  Special care needs to be taken
> >  * for devices that support caching.
> >  */
> > 
> > My tendency is to favor the first variant. 
> 
>    Me too.
> 
> >  Block2mtd already implements
> > it.  And if we went for variant two, mtd->sync() would be pointless and
> > should get removed.
> > 
> > Now to the bug report:
> > JFFS2 must call mtd->sync() for its various sync routines.  If mounted
> > with -o sync or for files opened with O_SYNC, it has to call that after
> > every write.  If nothing else, it is currently broken on block2mtd.
> 
> Sure, but for NOR flash this sync can be a NOP, right?

Actually, no.  After dwmw2 explained things in irc, I finally understand
the original meaning of that method.  It is supposed to wait until any
erase suspend (or program suspend) has finished.  You can view erase
suspend as a form of caching and erase as a form of writing.

If we wanted to avoid the cost without paying in reliability, we could
add an argument to sync().  Sync(now) would have the current semantics.
Sync(five minutes ago) would require that any writes/erases started more
than five minutes ago must be safe.  It add quite a bit of complexity,
though.  Maybe not worth it.

Jörn

-- 
The wise man seeks everything in himself; the ignorant man tries to get
everything from somebody else.
-- unknown



More information about the linux-mtd mailing list