patch-1.3.36 linux/fs/buffer.c
Next file: linux/fs/ext2/truncate.c
Previous file: linux/fs/binfmt_elf.c
Back to the patch index
Back to the overall index
- Lines: 78
- Date:
Mon Oct 23 10:00:31 1995
- Orig file:
v1.3.35/linux/fs/buffer.c
- Orig date:
Fri Oct 13 14:44:44 1995
diff -u --recursive --new-file v1.3.35/linux/fs/buffer.c linux/fs/buffer.c
@@ -769,10 +769,14 @@
}
-void refile_buffer(struct buffer_head * buf){
+void refile_buffer(struct buffer_head * buf)
+{
int dispose;
- if(buf->b_dev == B_FREE)
- panic("Attempt to refile free buffer\n");
+
+ if(buf->b_dev == B_FREE) {
+ printk("Attempt to refile free buffer\n");
+ return;
+ }
if (buf->b_dirt)
dispose = BUF_DIRTY;
else if (mem_map[MAP_NR((unsigned long) buf->b_data)].count > 1)
@@ -800,6 +804,9 @@
}
}
+/*
+ * Release a buffer head
+ */
void brelse(struct buffer_head * buf)
{
if (!buf)
@@ -811,23 +818,35 @@
refile_buffer(buf);
if (buf->b_count) {
- if (--buf->b_count)
- return;
- wake_up(&buffer_wait);
- if (buf->b_reuse) {
- buf->b_reuse = 0;
- if (!buf->b_lock && !buf->b_dirt &&
- !buf->b_wait && buf->b_uptodate) {
- if(buf->b_dev == B_FREE)
- panic("brelse: Wrong list");
- remove_from_queues(buf);
- buf->b_dev = B_FREE;
- put_last_free(buf);
- }
- }
+ if (!--buf->b_count)
+ wake_up(&buffer_wait);
return;
}
printk("VFS: brelse: Trying to free free buffer\n");
+}
+
+/*
+ * bforget() is like brelse(), except is throws the buffer away
+ */
+void bforget(struct buffer_head * buf)
+{
+ if (!buf)
+ return;
+ wait_on_buffer(buf);
+ if (buf->b_count != 1) {
+ printk("Aieee... bforget(): count = %d\n", buf->b_count);
+ return;
+ }
+ if (mem_map[MAP_NR(buf->b_data)].count != 1) {
+ printk("Aieee... bforget(): shared buffer\n");
+ return;
+ }
+ mark_buffer_clean(buf);
+ buf->b_count = 0;
+ remove_from_queues(buf);
+ buf->b_dev = B_FREE;
+ put_last_free(buf);
+ wake_up(&buffer_wait);
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this