Date: Fri, 16 Nov 2001 15:51:55 -0800 From: Terry Lambert <tlambert2@mindspring.com> To: Martin Kaeske <Martin.Kaeske@II.Stud.TU-Ilmenau.DE> Cc: freebsd-hackers@freebsd.org Subject: Re: BSD buffer management Message-ID: <3BF5A69B.E8CFC37F@mindspring.com> References: <20011116111306.A14218@walnut.hh59.local>
next in thread | previous in thread | raw e-mail | index | archive | help
Martin Kaeske wrote: > > Hello > Because i want to learn more about the BSD-kernel i bought > the book "The Design and Implementation of the 4.4BSD Operating > System" [McKusick, et.al.]. Now i come across the topic > "Buffer Management" and i have a question: Is it possible > that a call to bread() can result in a buffer covering > more than one disk-block? If this is true how does the kernel > ensures that there are no disk-blocks in more than one buffer > (as the kernel does when files are shortened or removed)? > Is it possible that its the callers (caller of bread()) task > to keep track of overlapping buffers? And breads size argument > is 'just' for flexibility and the caller has to ensure integrity. The book discusses a kernel where the VM and buffer cache coherency are explicit. In FreeBSD, there is a unified VM and buffer cache. The buffer cache is a write-through cache of the disk contents. It is the job of the VM system to keep the buffer cache (the place that the `bread' redults are from) coherent with the VM (the place that the `bread' results are read to). In a unified VM and buffer cache, there is no duplication of data, so multiple VM instances of buffer cache data, and therefore the "more than one buffer" problem you are referring to doesn't exist. There are seperate coherency problems going to a user space program. The way they are handled is using an explicit coherency protocol (regions are locked and read before their contents are referred to, and the reference occurs before the lock is released, and regions are locked before they are written), OR using an implicit cache coherency protocol (the memory is mapped into the process address space with a mapping that points to identical backing objects in all processes with a mapping established). In the most general case, VM objects are references to vnode objects, so the buffers that are being referenced are hung off the in core copies of the vnode (this ignores swap, which is handled differently, but not that differently). If you are interested in the real dirt, look in /syc/vm/*_pager.c. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BF5A69B.E8CFC37F>