Ok, this started by me wanting to speed up a Samba DC I have at work. Samba docs pointed me to /proc/sys/vm/bdflush. So in the course of trying how to figure out what I wanted to do I spent lots of time looking at LOTS of documentation on bdflush and what it does and does not do. I got tired of not being able to make sense of all the loose documentation, thus I made my own by combining what I found. So wiht out further ado...
What is bdflush any way. Well what I can tell from this point it is settings on how much data, how often, and how much at a time and the likes can be buffered and flushed. This will make a big difference in boxen preformance. Let's start by seeing what the kernel documentation has to say about bdflush. The following is taken directly form linux-2.4.4/Documentation/sysctl/vm.txt
==============================================================
bdflush:
This file controls the operation of the bdflush kernel
daemon. The source code to this struct can be found in
linux/fs/buffer.c. It currently contains 9 integer values,
of which 6 are actually used by the kernel.
From linux/fs/buffer.c:
--------------------------------------------------------------
union bdflush_param{
struct {
int nfract; /* Percentage of buffer cache dirty to
activate bdflush */
int ndirty; /* Maximum number of dirty blocks to
write out per wake-cycle */
int nrefill; /* Number of clean buffers to try to
obtain each time we call refill */
int nref_dirt; /* Dirty buffer threshold for activating
bdflush when trying to refill buffers. */
int dummy1; /* unused */
int age_buffer; /* Time for normal buffer to age before
we flush it */
int age_super; /* Time for superblock to age before we
flush it */
int dummy2; /* unused */
int dummy3; /* unused */
} b_un;
unsigned int data[N_PARAM];
} bdf_prm = {{40, 500, 64, 256, 15, 30*HZ, 5*HZ, 1884, 2}};
--------------------------------------------------------------
The first parameter governs the maximum number of dirty
buffers in the buffer cache. Dirty means that the contents
of the buffer still have to be written to disk (as opposed
to a clean buffer, which can just be forgotten about).
Setting this to a high value means that Linux can delay disk
writes for a long time, but it also means that it will have
to do a lot of I/O at once when memory becomes short. A low
value will spread out disk I/O more evenly.
The second parameter (ndirty) gives the maximum number of
dirty buffers that bdflush can write to the disk in one time.
A high value will mean delayed, bursty I/O, while a small
value can lead to memory shortage when bdflush isn't woken
up often enough...
The third parameter (nrefill) is the number of buffers that
bdflush will add to the list of free buffers when
refill_freelist() is called. It is necessary to allocate free
buffers beforehand, since the buffers often are of a different
size than memory pages and some bookkeeping needs to be done
beforehand. The higher the number, the more memory will be
wasted and the less often refill_freelist() will need to run.
When refill_freelist() comes across more than nref_dirt dirty
buffers, it will wake up bdflush.
Finally, the age_buffer and age_super parameters govern the
maximum time Linux waits before writing out a dirty buffer
to disk. The value is expressed in jiffies (clockticks), the
number of jiffies per second is 100, except on Alpha machines
(1024). Age_buffer is the maximum age for data blocks, while
age_super is for filesystem metadata.
==============================================================
Below are the paramaters of bdflush, in my own terms. (variable names of the elements in /proc/sys/vm/bdflush)
nfract ndirty nrefill nref_dirt dummy1 age_buffer age_super dummy2 dummy3