From: "Doug Graham" <dgraham@nortel.com>
To: linux-mtd@lists.infradead.org
Subject: mtdblock caching and syncing
Date: Thu, 9 Apr 2009 10:15:56 -0400 [thread overview]
Message-ID: <20090409141556.GG15952@nortel.com> (raw)
Hello,
I'm running a 2.6.24 kernel, but I've looked over the latest kernel
sources, and I don't see a fix for this (although I could have missed
something).
The problem is that a sync() or fsync() on an mtdblock device does not
actually get the data all the way to the flash device. The mtdblock
layer maintains its own cache of a single erase-unit (256KB in my case).
If I open /dev/mtdblock0 for writing, write some stuff to it, then call
fsync() but do not close the device, up to one erase-unit's worth of
data may still be buffered in memory. This data is only flushed when
the device is actually closed (by mtdblock_release). I think that
this violates the intended semantics of sync and fsync. I shouldn't be
required to do a close() to force the data to the device.
Another scenario is to open an mtdblock device, write to it, then call
close() without calling fsync(). In this case, the data may not yet be
flushed to the mtdblock layer by the time close() is called, so nothing
gets written to flash during the close(). That's all reasonable so far,
but if I then type "sync" from the shell (or wait for 30 seconds for
pdflush to do its thing), all buffered data *should* be flushed to the
actual device. As it stands now, the sync will flush data as far as
the mtdblock layer, but that data may then get buffered in the mtdblock
layer forever. It only gets flushed to the device on a close(), and if
nobody calls close(), it stays there forever.
I think this is fairly serious bug in a flash-based system, where there
are frequently times that you want to make sure that data has actually
made it all the way to the device. I think that a sync() or fsync()
really ought to somehow propagate all the way down to the mtdblock layer
so that mtdblock can flush its buffer.
Thoughts? Suggestions? Patches?
Thanks,
Doug.
next reply other threads:[~2009-04-09 14:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-09 14:15 Doug Graham [this message]
2009-04-09 14:51 ` mtdblock caching and syncing Josh Boyer
2009-04-09 16:02 ` Doug Graham
2009-04-09 17:16 ` Josh Boyer
2009-04-09 18:07 ` Jamie Lokier
2009-04-09 19:24 ` Doug Graham
2009-04-23 18:21 ` Miles Nordin
2009-04-24 15:35 ` Jamie Lokier
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=20090409141556.GG15952@nortel.com \
--to=dgraham@nortel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.