From owner-freebsd-hackers Fri Nov 16 15:51:17 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from snipe.prod.itd.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by hub.freebsd.org (Postfix) with ESMTP id D956D37B416 for ; Fri, 16 Nov 2001 15:51:12 -0800 (PST) Received: from dialup-209.244.106.83.dial1.sanjose1.level3.net ([209.244.106.83] helo=mindspring.com) by snipe.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 164slG-0007Ka-00; Fri, 16 Nov 2001 15:51:06 -0800 Message-ID: <3BF5A69B.E8CFC37F@mindspring.com> Date: Fri, 16 Nov 2001 15:51:55 -0800 From: Terry Lambert Reply-To: tlambert2@mindspring.com X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Martin Kaeske Cc: freebsd-hackers@freebsd.org Subject: Re: BSD buffer management References: <20011116111306.A14218@walnut.hh59.local> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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