minor patch for 2.1.104 fs/buffer.c

Bill Hawes (whawes@transmeta.com)
Sat, 06 Jun 1998 11:30:12 -0700


This is a multi-part message in MIME format.
--------------323E1967BF382DB5FF49DF49
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The attached patch adds a warning if bforget() is called for a buffer
that's still in use. The caller is supposed to check that bh_count == 1
before calling it, but this warning will catch any misuse or races. (As
the "trying to free free buffer" does occasionally.)

I've also made a minor change to bread() to move an "impossible" message
out of line so the code doesn't have to skip over it (or read it into
the icache.)

Regards,
Bill

--------------323E1967BF382DB5FF49DF49
Content-Type: text/plain; charset=us-ascii; name="buffer_104-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="buffer_104-patch"

--- linux-2.1.104/fs/buffer.c.old Fri Jun 5 16:33:12 1998
+++ linux-2.1.104/fs/buffer.c Fri Jun 5 16:56:24 1998
@@ -1053,10 +1053,13 @@
wait_on_buffer(buf);
mark_buffer_clean(buf);
clear_bit(BH_Protected, &buf->b_state);
- buf->b_count--;
remove_from_hash_queue(buf);
buf->b_dev = NODEV;
refile_buffer(buf);
+ if (!--buf->b_count)
+ return;
+ printk("VFS: forgot an in-use buffer! (count=%d)\n",
+ buf->b_count);
}

/*
@@ -1065,19 +1068,19 @@
*/
struct buffer_head * bread(kdev_t dev, int block, int size)
{
- struct buffer_head * bh;
+ struct buffer_head * bh = getblk(dev, block, size);

- if (!(bh = getblk(dev, block, size))) {
- printk("VFS: bread: impossible error\n");
+ if (bh) {
+ if (buffer_uptodate(bh))
+ return bh;
+ ll_rw_block(READ, 1, &bh);
+ wait_on_buffer(bh);
+ if (buffer_uptodate(bh))
+ return bh;
+ brelse(bh);
return NULL;
}
- if (buffer_uptodate(bh))
- return bh;
- ll_rw_block(READ, 1, &bh);
- wait_on_buffer(bh);
- if (buffer_uptodate(bh))
- return bh;
- brelse(bh);
+ printk("VFS: bread: impossible error\n");
return NULL;
}

--------------323E1967BF382DB5FF49DF49--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu