[PATCH] Fix hanging close for /dev/mtd

Joakim Tjernlund joakim.tjernlund at transmode.se
Wed Jun 13 16:25:54 EDT 2007


 

> -----Original Message-----
> From: Jörn Engel [mailto:joern at logfs.org] 
> Sent: den 13 juni 2007 19:59
> To: Joakim Tjernlund
> Cc: Jörn Engel; Linux MTD mailing list; David Woodhouse
> Subject: Re: [PATCH] Fix hanging close for /dev/mtd
> 
> 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.

Yes, I see that. Then it will enable writes/erases again.

> 
> 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.

Still don't get what sync will do for you in mtdchar context. All
mtd writes are synchronous and will be in flash without sync. So
what extra function does it get you on NOR flashes?

David, you are most welcome to explain this on the list also and
comment on my latest patches.

 Jocke




More information about the linux-mtd mailing list