Home Forum Developers General discussions A different filesystem approach

JRPassphrase Registration Control

In order to register on this site, you must first submit the passphrase below.

TODO list for each hardware target can be found as sticky topic in the corresponding forum


Chewi
useravatar
User Info

A different filesystem approach

I initially discovered Switchfin from this page. It criticises Switchfin for wasting 20MB of RAM on creating a copy of the root filesystem, while BAPS uses the NAND directly. I, too, thought this approach seemed a little strange and I've been thinking about it for a while.

I gather that this was done to prevent wearing out the NAND but as Gilles has already pointed out here, only writes wear out the NAND. Configuration changes are written to the NAND anyway via /persistent so the only writes we are avoiding are the ones we don't need to keep, such as those in /var/run and /var/log. Why couldn't we just mount tmpfs instances over those directories?

This may not be enough though. It is important to have some way of reverting back to the default configuration, as is currently being done with /persistent/defaults.tgz. But this approach is horribly inefficient. You write a copy of defaults.tgz to the NAND even though it actually already exists elsewhere on the NAND. And then you extract all the files even though only a few might have actually changed. Additional old files are never deleted and may accumulate over time. Their presence may even cause unexpected problems. Finally, changes are restricted to files we have explicitly created symlinks for in /etc/rc.

I have some experience in a couple of different implementations of UnionFS and have found it to be extremely useful. I have since discovered mini_fo, a specialised implementation catering for embedded devices, written by the creators of U-Boot. It is much simpler than the official Linux kernel implementation but provides everything we need. Two branches, a read-only branch overlayed by a read-write branch.

The read-only branch would be the original copy of the filesystem on the NAND. The read-write branch would be a separate partition, much like /persistent is now. The difference is that only the changes would actually be written to the NAND and they could be done anywhere in a transparent fashion, negating the need for awkward symlinks. Reverting to the default configuration would simply involve deleting all the files on this partition, of which there probably wouldn't be many. You could even just delete a single file to revert the settings on a single GUI page, for example. Needless writes could still be avoided by mounting tmpfs where necessary.

I would really like the community to seriously consider this proposal. It would save a huge amount of RAM, result in fewer writes to the NAND, and would be easier to build, use and maintain. I honestly can't think of a down side! There might be a little pain for those with existing setups but this is still a young project and I'm sure the few users we have wouldn't mind in the name of progress, especially with so many positives.

Oh, and of course I'll do all the work. wink


Administrator has disabled public posting
Chewi
useravatar
User Info

Re: A different filesystem approach

I'm starting to find that the lack of RAM really isn't helping the stability of the system, especially given that uClinux takes some time to recover the memory used by programs that have terminated.

If I don't hear some opinions on this soon, I'll have to assume that you're all indifferent and don't care whether I make these big changes or not! tongue


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: A different filesystem approach

Hi Chewi

Sounds like an interesting idea, i will be willing to run some test.  however i wouldn't commit such a big change to the trunk maybe make a branch in the SVN.

Thanks
Jason


Administrator has disabled public posting
Andy
useravatar
User Info

Re: A different filesystem approach

Hi James,

Anything that can be done to improve the performance and stability of the platform is very welcome. Your suggested solution looks a very elegant way to free up some precious RAM.

If I understand correctly, changes are effectively cached in RAM and written to NAND as a background process. Isn't there a potential risk of files getting corrupted if the system is restarted or if power is removed before the NAND write process has completed? Perhaps there should be a 'shutdown' option in the GUI to perform an orderly shutdown to improve the integrity of the file system.

On a related subject the IP04 and IP08 systems have a SD CARD socket. Would your proposed changes to the file system also support a SD card?

I'm more than willing to assist with the testing.

Andy


Administrator has disabled public posting
Chewi
useravatar
User Info

Re: A different filesystem approach

I don't believe mini_fo does any caching in RAM. It simply overlays the two filesystems and applies any writes to the writeable branch.

In the same way that we will be able to mount tmpfs in the normal way where required, it will be possible to mount the SD card as well. mini_fo will not touch these.

Thank you for the support. I may wait till our funding comes through so it could be a few weeks before I start this. Or I may get impatient. We'll see. smile


Administrator has disabled public posting
admin
useravatar
User Info

Re: A different filesystem approach

Hi James,

Well the decision to put the rootfs in RAM was mainly from the performance perspective. We have measured that reading from SDRAM is 65% faster then reading from nand flash. Keep in mind that this may reflect directly on the total PBX performance.
At the time we have started Astfin 64MB was plenty.
Now indeed we are getting short of RAM for some configurations especially for BR4 Appliance with mISDN.

Your idea may be elegant for the cases we are lacking RAM.
I am curious about the performance impact. 

I am also interested to consider swapping (to nand flash) scheme for Switchfin.

Cheers
Dimitar


Administrator has disabled public posting
Chewi
useravatar
User Info

Re: A different filesystem approach

I figured it would be faster from RAM but not that much faster. I thought the NAND was supposed to be quite fast too. There may be additional caching measure we can take. I'll explore the options. Swapping to NAND seems like a bad idea but uClinux doesn't support swap anyway.


Administrator has disabled public posting
admin
useravatar
User Info

Re: A different filesystem approach

Hi James,

Well the nand flash is using 8 bit multiplexed address/data bus.
SDRAM is using dedicated address and 16 bit data bus with built in SDRAM hardware controller in the CPU.
So SDRAM is definitely faster. It is other question how this will impact the total performance in the scheme you suggest.

I am very curious on the results you will get smile
If the penalty is small I will be very happy to apply your patch in the Switchfin mainstream.

Cheers
Dimitar


Administrator has disabled public posting
Gilles
useravatar
User Info

Re: A different filesystem approach

Chewi wrote:

I'm starting to find that the lack of RAM really isn't helping the stability of the system, especially given that uClinux takes some time to recover the memory used by programs that have terminated.
It can be worse than that: Sometimes, killing/restarting the application is not enough for uClinux to recover all the RAM, and the only way to solve the fragmentation issue is to reboot the device.

admin wrote:

Well the decision to put the rootfs in RAM was mainly from the performance perspective. We have measured that reading from SDRAM is 65% faster then reading from nand flash.
Is that really important? What applications do people run where slow reads could be an issue, considering that applications are typically launched once at boot-time and just keep running until the device is rebooted?

Like everyone, I'm interesting in testing a UnionFS-based solution and save RAM, since 64MB isn't that much.


Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 2587  Total Topics: 299  Total Polls: 1  Total Posts: 1727  Dormant
User Info:   Newest User :  user2553   Members Online: 0   Guests Online: 155
Online  There are no members online
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked