Number of inodes to
be held in memory. Inodes are cached globally (for UFS), not on a per-file
system basis.
A key variable in this situation is ufs_ninode. This
parameter is used to compute two key limits that affect the handling of inode
caching. A high watermark of ufs_ninode / 2 and a low water
mark of ufs_ninode / 4 are computed.
When the system is done with an inode, one of two things can happen:
The file referred to by the inode is no longer on the system
so the inode is deleted. After it is deleted, the space goes back into the
inode cache for use by another inode (which is read from disk or created for
a new file).
The file still exists but is no longer referenced by a running
process. The inode is then placed on the idle queue. Any referenced pages
are still in memory.
When inodes are idled, the kernel defers the idling process to a later
time. If a file system is a logging file system the kernel also defers deletion
of inodes. Two kernel threads do this. Each thread is responsible for one
of the queues.
When the deferred processing is done, the system drops the inode onto
either a delete or idle queue, each of which has a thread that can run to
process it. When the inode is placed on the queue, the queue occupancy is
checked against the low watermark. If it is in excess of the low watermark,
the thread associated with the queue is awakened. After it is awakened, the
thread runs through the queue and forces any pages associated with the inode
out to disk and frees the inode. The thread stops when it has removed 50%
of the inodes on the queue at the time it was awakened.
A second mechanism is in place if the idle thread is unable to keep
up with the load. When the system needs to find a vnode, it goes through the ufs_vget routine. The first thing vget does is check the length of the idle queue. If the length is
above the high watermark, then it pops two inodes off the idle queue and "idles"
them (flushes pages and frees inodes). It does this before
it gets an inode for its own use.
The system does attempt to optimize by placing inodes with no in-core
pages at the head of the idle list and inodes with pages at the end of the
idle list, but it does no other ordering of the list. Inodes are always removed
from the front of the idle queue.
The only time that inodes are removed from the queues as a whole is
when a sync, unmount, or remount occur.
For historical reasons, this parameter does not require the ufs: prefix.
|