public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Lewin A.R.W. Edwards" <larwe@larwe.com>
To: "Grant Edwards" <grante@visi.com>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] Re: Simple flash filesystem?
Date: Tue, 06 Feb 2001 08:21:00 -0000	[thread overview]
Message-ID: <4.3.2.7.2.20010206111140.00a85360@larwe.com> (raw)
In-Reply-To: <20010206160547.B184E7A814@visi.com>

Hi Grant,

>The filesystem will basically contain web pages and Java applets.

I figured this. So you're dealing with numerous small filelets which will 
mostly be smaller than the block size, and it is not unreasonable to 
reserve at least one block for directory information.

How about this for a solution: Reserve one block (64K) as a directory 
block. Keep that whole block in RAM at all times. Inside it, have a number 
of structures like this:

32bits pointer to file data or NULL if no file exists
32bits file size in bytes
asciiz variable length filename (\0 for non-file)

Keep the directory sorted by file pointer.

When you want to create a new file, you can follow this algorithm:

* if there is a free block (64K), allocate part of it for the file, erase 
that block and write the file to the start of it, and update the directory.
* if there is no completely free block, search for a block that has free 
space in its tail big enough to accommodate your file. Read that block into 
RAM, append your new file into the tail, and erase/writeback the block.

The same algorithm can be used to replace an existing file - simply change 
the existing file's pointer in the directory to indicate that it's no 
longer in use, then follow the steps above.

Depending on how power-failure-tolerant you need this to be, you can get a 
big performance improvement on writes because your directory is all in RAM 
and you only need to commit it back to flash periodically.

This does not perform any explicit wear leveling, obviously, and it also 
doesn't make the most efficient use of space (note the lack of support for 
noncontiguous allocation!). But I think this system might do well for your 
application where you're mostly dealing with tiny files that are not going 
to be rewritten frequently.

>I may just forget about writing individual files and force the user
>to download an entire ROM filesystem everytime anything changes. That
>would be way simpler, but a little slower.

I wanted to do this for one of our products, but I was shouted down 
(legitimately, I think) on the grounds that end-users want to be able to 
read/write randomly. So the project is sitting on the back-burner right now ;)

=== Lewin A.R.W. Edwards (Embedded Engineer)
Work: http://www.digi-frame.com/
Personal: http://www.zws.com/ and http://www.larwe.com/

"Und setzet ihr nicht das Leben ein,
Nie wird euch das Leben gewonnen sein."

  reply	other threads:[~2001-02-06  8:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-05 14:10 [ECOS] " Grant Edwards
2001-02-05 14:29 ` Lewin A.R.W. Edwards
2001-02-06  8:05   ` [ECOS] " Grant Edwards
2001-02-06  8:21     ` Lewin A.R.W. Edwards [this message]
2001-02-06  8:43       ` Grant Edwards
2001-02-06  9:20     ` Wilson Kwan
2001-02-06  9:28       ` Grant Edwards
     [not found] <981465384.28425.ezmlm@sources.redhat.com>
2001-02-06 12:30 ` Kristian Otnes
2001-02-06 12:50   ` Grant Edwards
2001-02-06 12:54     ` Lewin A.R.W. Edwards
2001-02-06 13:03       ` Grant Edwards

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=4.3.2.7.2.20010206111140.00a85360@larwe.com \
    --to=larwe@larwe.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=grante@visi.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).