patch-2.1.107 linux/fs/buffer.c

Next file: linux/fs/coda/Makefile
Previous file: linux/fs/binfmt_elf.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.106/linux/fs/buffer.c linux/fs/buffer.c
@@ -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;
 }
 
@@ -1308,7 +1311,7 @@
 	if (!async)
 		return NULL;
 
-	/* Uhhuh. We're _really_ low on memory. Now we just
+	/* We're _really_ low on memory. Now we just
 	 * wait for old buffer heads to become free due to
 	 * finishing IO.  Since this is an async request and
 	 * the reserve list is empty, we're sure there are 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov