public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@logfs.org>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: "David Woodhouse" <dwmw2@infradead.org>,
	"Jörn Engel" <joern@logfs.org>,
	"Linux MTD mailing list" <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] Fix hanging close for /dev/mtd
Date: Wed, 13 Jun 2007 19:58:32 +0200	[thread overview]
Message-ID: <20070613175831.GC24502@lazybastard.org> (raw)
In-Reply-To: <1181754991.30670.325.camel@gentoo-jocke.transmode.se>

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

  reply	other threads:[~2007-06-13 18:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-13  9:53 [PATCH] Fix hanging close for /dev/mtd Joakim Tjernlund
2007-06-13 11:44 ` Josh Boyer
2007-06-13 11:48   ` Joakim Tjernlund
2007-06-13 11:50     ` Joakim Tjernlund
2007-06-13 11:54     ` Jörn Engel
2007-06-13 13:29       ` Joakim Tjernlund
2007-06-13 14:29         ` Jörn Engel
2007-06-13 17:16           ` Joakim Tjernlund
2007-06-13 17:58             ` Jörn Engel [this message]
2007-06-13 20:25               ` Joakim Tjernlund
2007-06-13 12:31     ` Josh Boyer
2007-06-13 13:25       ` Joakim Tjernlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070613175831.GC24502@lazybastard.org \
    --to=joern@logfs.org \
    --cc=dwmw2@infradead.org \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox