Re: bforget and protected buffers

Chuck Lever (cel@monkey.org)
Tue, 27 Apr 1999 12:01:06 -0400 (EDT)


see the buffer_busy macro defined later in fs/buffer.c for use by
try_to_free_buffers(). this will prevent protected ramdisk buffers from
being reclaimed, although they can still appear on the free list if
someone decides to add bforget() calls to the ramdisk logic... presumably
if ramdisk decides to bforget a buffer, it doesn't care about it's
contents.

now, if you add this to bforget():

buf->b_state = 0;

that defeats the buffer_busy check in try_to_free_buffers(), so maybe the
check should be made explicitly in bforget() if you add this line.

On Tue, 27 Apr 1999, Andrea Arcangeli wrote:
> Shound't we also check if the buffer was protected before put it on the
> freelist? Once a buffer is on the freelist it can be reclycled at any time
> from getblk and the protected bit would go away... (I think the ramdisk
> driver can go in troubles then...).
>
> Here a fix against 2.2.6:
>
> Index: linux/fs//buffer.c
> ===================================================================
> RCS file: /var/cvs/linux/fs/buffer.c,v
> retrieving revision 1.1.1.8
> diff -u -r1.1.1.8 buffer.c
> --- linux/fs/buffer.c 1999/03/29 21:38:51 1.1.1.8
> +++ linux/fs/buffer.c 1999/04/27 13:13:40
> @@ -849,7 +849,7 @@
> */
> void __bforget(struct buffer_head * buf)
> {
> - if (buf->b_count != 1 || buffer_locked(buf)) {
> + if (buf->b_count != 1 || buffer_locked(buf) || buffer_protected(buf)) {
> __brelse(buf);
> return;
> }

- Chuck Lever

--
corporate:	<chuckl@netscape.com>
personal:	<chucklever@netscape.net> or <cel@monkey.org>

The Linux Scalability project: http://www.citi.umich.edu/projects/linux-scalability/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/