LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-17-2011, 05:02 PM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
sparse file vs. ramfs


It seems that ramfs will handle sparse files just fine if all you do is write (or not as the case may be) the file data. But as soon as the sparse file is to be read, even the "non-existant" blocks that were never written to (and would not be allocated any space on a filesystem that supports sparse files), will come to occupy space once read. But once the file is unlinked completely, the space is no longer utilized.

So it seems that ramfs does "support" a sparse file in that there is enough of a data structure (which is essentially the system cache, since it's not a real filesystem) to know which blocks occupy space and which do not. It can can free them (it does when the file is unlinked).

My concern is why does it need to retain a cached block that was never written, but does get read? I understand that the mechanism is basically waiting for a backing store (that will never be ready). But this can still be purged because it does that when the file is unlinked. Then all the blocks are no longer structured in the cache (the data may still be residual in RAM, but nothing has it noted as needing to be written).

IMHO, what it should do, if the block was never written, but does get read, is fill in the buffer of binary zeros for the read operation, then discard the block again so it continues to not occupy space.

I'm wondering how much of ordinary buffer cache for real file systems is taking up RAM, at least temporarily, just because a buffer of zeros was created for a process that read a sparse block of a file.

Try creating a fully sparse file in ramfs (e.g. use the truncate command on a zero length file), and check "du" on it. Then read it and do "du" on it again. Just be sure the size you truncate it to is well smaller than your physical RAM size or you could have a nice little "oops".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with the ramfs................ sundar007 Linux - Embedded & Single-board computer 8 06-29-2010 09:09 AM
How to remove some blocks from a sparse file hpsmouse Programming 10 08-16-2009 08:32 AM
make bootable CD from hard disk image and mount root file system as ramfs Mr.J Linux - Embedded & Single-board computer 1 08-19-2008 07:29 AM
ramfs anyone? alaios Linux - General 0 10-21-2004 02:18 PM
ramfs alaios Linux - General 0 10-12-2004 12:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration