From: Philipp Rumpf <prumpf@uzix.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Finn Hakansson <finn@axis.com>,
"Rogelio M. Serrano Jr." <rogelio@evoserve.com>,
"mtd@infradead.org" <mtd@infradead.org>,
jffs-dev@axis.com
Subject: Re: jffs_file_write
Date: Tue, 25 Jul 2000 08:24:17 -0700 [thread overview]
Message-ID: <20000725082417.C15029@fruits.uzix.org> (raw)
In-Reply-To: <6960.964537931@cygnus.co.uk>
On Tue, Jul 25, 2000 at 04:12:11PM +0100, David Woodhouse wrote:
> OK. As long as we're aware of the possibility that a certain byte range
> could be changed _again_ in a different transaction.
>
> i.e. pwrite(fd, "aaaaaaaaa", 10, 0);
> pwrite(fd, "bbbbbbbbb", 10, 5);
>
> If you're not going to take a copy of data in the first write, but just
> keep it in the page cache and remember where it is, then you cannot write
> that transaction unless you combine it with the second one.
>
> That is - you _must_ combine the two into a single node write. It's not
> just an optimisation. If you were to write "aaaaabbbbb" to the beginning of
> the file and lose power before writing the rest of the 'bbbbb', I believe
> you're violating POSIX by having non-atomic write().
prepare_write can look like this:
if(try_to_abort_pending_conflicting_writes_fails()) {
sleep until the writes happened;
} else {
reschedule merged writes;
}
I'm not actually sure there's a POSIX requirement to do this - as long as
the fs doesn't crash the page cache will keep our view of it consistent.
BTW, the simplistic implementation would simply add
__u32 first_modified_byte;
__u32 last_modified_byte;
to jffs_file and keep track of only one range that has been modified - it
should work well enough for the common case (non-conflicting consecutive
writes) and we can easily detect the cases in which it doesn't work and
fall back to sleeping until the write are finished.
> So if you're going to write data to the flash directly from the page cache,
> you have to have some lock in place which prevents anything else from
> dirtying it during the mtd_write() call.
If all writes are done by one thread that shouldn't be necessary.
To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org
prev parent reply other threads:[~2000-07-25 15:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-21 23:41 jffs_file_write Rogelio M. Serrano Jr.
2000-07-24 15:09 ` jffs_file_write Finn Hakansson
2000-07-25 9:29 ` jffs_file_write David Woodhouse
2000-07-25 9:44 ` jffs_file_write Finn Hakansson
2000-07-25 10:01 ` jffs_file_write David Woodhouse
2000-07-25 10:11 ` jffs_file_write Finn Hakansson
2000-07-25 13:02 ` jffs_file_write Bjorn Wesen
2000-07-25 13:19 ` jffs_file_write David Woodhouse
2000-07-25 13:54 ` jffs_file_write David Woodhouse
2000-07-25 10:02 ` jffs_file_write Bjorn Wesen
2000-07-25 10:15 ` jffs_file_write David Woodhouse
2000-07-25 14:29 ` jffs_file_write Philipp Rumpf
2000-07-25 15:12 ` jffs_file_write David Woodhouse
2000-07-25 15:24 ` Philipp Rumpf [this message]
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=20000725082417.C15029@fruits.uzix.org \
--to=prumpf@uzix.org \
--cc=dwmw2@infradead.org \
--cc=finn@axis.com \
--cc=jffs-dev@axis.com \
--cc=mtd@infradead.org \
--cc=rogelio@evoserve.com \
/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