Re: "Need information on block layer buffer cache behavior"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On 20:26 Thu 22 Jul     , Murali N wrote:
> Hi,
> 
> I have a storage media, where I need to write the data to. Right now,
> I am using the vfs_write calls to write the data on the media. I am
> not explicitly syncing the data on to the device in my driver file. I
> am expecting the VFS to take care of syncing this data on to the
> storage media. In this scenario, If I try to copy big files(~GB's of
> data), What is the expected behavior from the VFS. Does kernel
> allocate large cache buffers (or) does it use fixed cache buffers and
> manipulate on these fixed buffers (or) does it go on increasing the
> buffer caches based on the amount of data to be written on the storage
> media.?

I am not very involved in the vfs layer. AFAIK, the exact behaviour depends a
lot on the filesystem used. For example ext3 does very little write caching.
The reason is mainly that the file system does not support delayed allocation
and thus every journal commit (which happens every 5 seconds) flushes
everything to disk. This is not the case with e.g. ext4, which caches more
aggressively. However, there are still limits. For example, there is a limit
of 20% memory which can be used for caching before processes are put to sleep.
You can find the tuneables in /proc/sys/vm/ . For more info about these knobs,
look at Documentation/sysctl/vm.txt .

Be aware that the write caches can sometimes be very big and in extreme cases
it might take minutes until written data actually hits the disk. If you want
to make sure that the data is written before you show the user "done", you
should call fsync(). However this system call can be quite slow, especially
on ext3, which flushes data very quickly. This has lead many people to
"forget" about fsync. This makes big write caches very dangerous...

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux