1*219b2ee8SDavid du Colombier.SH 2*219b2ee8SDavid du ColombierBuffer Cache 3*219b2ee8SDavid du Colombier.PP 4*219b2ee8SDavid du ColombierWhen the file server is 5*219b2ee8SDavid du Colombierbooted, 6*219b2ee8SDavid du Colombierall of the unused memory is allocated to 7*219b2ee8SDavid du Colombiera block buffer pool. 8*219b2ee8SDavid du ColombierThere are two major operations on the buffer 9*219b2ee8SDavid du Colombierpool. 10*219b2ee8SDavid du Colombier.CW Getbuf 11*219b2ee8SDavid du Colombierwill find the buffer associated with a 12*219b2ee8SDavid du Colombierparticular block on a particular device. 13*219b2ee8SDavid du ColombierThe returned buffer is locked so that the 14*219b2ee8SDavid du Colombiercaller has exclusive use. 15*219b2ee8SDavid du ColombierIf the requested buffer is not in the pool, 16*219b2ee8SDavid du Colombiersome other buffer will be relabeled and 17*219b2ee8SDavid du Colombierthe data will be read from the requested device. 18*219b2ee8SDavid du Colombier.CW Putbuf 19*219b2ee8SDavid du Colombierwill unlock a buffer and 20*219b2ee8SDavid du Colombierif the contents are marked as modified, 21*219b2ee8SDavid du Colombierthe buffer will be written to the device before 22*219b2ee8SDavid du Colombierthe buffer is relabeled. 23*219b2ee8SDavid du ColombierIf there is some special mapping 24*219b2ee8SDavid du Colombieror CPU cache flushing 25*219b2ee8SDavid du Colombierthat must occur in order for the physical I/O 26*219b2ee8SDavid du Colombierdevice to access the buffers, 27*219b2ee8SDavid du Colombierthis is done between 28*219b2ee8SDavid du Colombier.CW getbuf 29*219b2ee8SDavid du Colombierand 30*219b2ee8SDavid du Colombier.CW putbuf . 31*219b2ee8SDavid du ColombierThe contents of a buffer is never touched 32*219b2ee8SDavid du Colombierexcept while it is locked between 33*219b2ee8SDavid du Colombier.CW getbuf 34*219b2ee8SDavid du Colombierand 35*219b2ee8SDavid du Colombier.CW putbuf 36*219b2ee8SDavid du Colombiercalls. 37*219b2ee8SDavid du Colombier.PP 38*219b2ee8SDavid du ColombierThe 39*219b2ee8SDavid du Colombierfile system server processes 40*219b2ee8SDavid du Colombierprevent deadlock in the buffers by 41*219b2ee8SDavid du Colombieralways locking parent and child 42*219b2ee8SDavid du Colombierdirectory entries in that order. 43*219b2ee8SDavid du ColombierSince the entire directory structure 44*219b2ee8SDavid du Colombieris a hierarchy, 45*219b2ee8SDavid du Colombierthis makes the locking well-ordered, 46*219b2ee8SDavid du Colombierpreventing deadlock. 47*219b2ee8SDavid du ColombierThe major problem in the locking strategy is 48*219b2ee8SDavid du Colombierthat locks are at a block level and there are many 49*219b2ee8SDavid du Colombierdirectory entries in a single block. 50*219b2ee8SDavid du ColombierThere are unnecessary lock conflicts 51*219b2ee8SDavid du Colombierin the directory blocks. 52*219b2ee8SDavid du ColombierWhen one of these directory blocks is tied up 53*219b2ee8SDavid du Colombieraccessing the very slow WORM, 54*219b2ee8SDavid du Colombierthen all I/O to dozens of unrelated directories 55*219b2ee8SDavid du Colombieris blocked. 56