xref: /plan9/sys/doc/fs/p5 (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1*219b2ee8SDavid du Colombier.SH
2*219b2ee8SDavid du ColombierThe read-ahead processes
3*219b2ee8SDavid du Colombier.PP
4*219b2ee8SDavid du ColombierThere are a set of file system processes,
5*219b2ee8SDavid du Colombier.CW rah ,
6*219b2ee8SDavid du Colombierthat wait for messages consisting of a device and block
7*219b2ee8SDavid du Colombieraddress.
8*219b2ee8SDavid du ColombierWhen a message comes in,
9*219b2ee8SDavid du Colombierthe process reads the specified block from the device.
10*219b2ee8SDavid du ColombierThis is done by calling
11*219b2ee8SDavid du Colombier.CW getbuf
12*219b2ee8SDavid du Colombierand
13*219b2ee8SDavid du Colombier.CW putbuf .
14*219b2ee8SDavid du ColombierThe purpose of this is the hope that these blocks
15*219b2ee8SDavid du Colombierwill be used later and that they will reside in the
16*219b2ee8SDavid du Colombierbuffer cache long enough not to be discarded before
17*219b2ee8SDavid du Colombierthey are used.
18*219b2ee8SDavid du Colombier.PP
19*219b2ee8SDavid du ColombierThe messages to the read-ahead processes are
20*219b2ee8SDavid du Colombiergenerated by the server processes.
21*219b2ee8SDavid du ColombierThe server processes maintain a relative block mark in every
22*219b2ee8SDavid du Colombieropen file.
23*219b2ee8SDavid du ColombierWhenever an open file reads that relative block,
24*219b2ee8SDavid du Colombierthe next 110 block addresses of the file are sent
25*219b2ee8SDavid du Colombierto the read-ahead processes and
26*219b2ee8SDavid du Colombierthe relative block mark is advanced by 100.
27*219b2ee8SDavid du ColombierThe initial relative block is set to 1.
28*219b2ee8SDavid du ColombierIf the file is opened and
29*219b2ee8SDavid du Colombieronly a few bytes are read,
30*219b2ee8SDavid du Colombierthen no anticipating reads are performed
31*219b2ee8SDavid du Colombiersince the relative block mark is set to 1
32*219b2ee8SDavid du Colombierand only block offset 0 is read.
33*219b2ee8SDavid du ColombierThis is to prevent some
34*219b2ee8SDavid du Colombierfairly common action such as
35*219b2ee8SDavid du Colombier.P1
36*219b2ee8SDavid du Colombier    file *
37*219b2ee8SDavid du Colombier.P2
38*219b2ee8SDavid du Colombierfrom swamping the file system with read-ahead
39*219b2ee8SDavid du Colombierrequests that will never be used.
40