[patch] bforget

Andrea Arcangeli (andrea@suse.de)
Fri, 3 Sep 1999 18:35:49 +0200 (CEST)


In bforget we can use the dec_and_test operation. The touch_buffer is
wrong there. We can scale better.

If it's true that the buffer is shared, it means it will be released. And
if it will be released with bforget from the other place too, then it make
no sense to have the buffer marked as young from the previous bforget.
When we want to forget the buffer in general we should _never_ mark it as
young.

patch against 2.3.16:

--- buffer.c.~1~ Thu Sep 2 10:14:10 1999
+++ linux/fs/buffer.c Fri Sep 3 17:42:43 1999
@@ -898,19 +898,21 @@
*/
void __bforget(struct buffer_head * buf)
{
+ /* grab the lru lock here to block bdflush. */
spin_lock(&lru_list_lock);
write_lock(&hash_table_lock);
- if (atomic_read(&buf->b_count) != 1 || buffer_locked(buf)) {
- touch_buffer(buf);
- atomic_dec(&buf->b_count);
- } else {
- atomic_set(&buf->b_count, 0);
- buf->b_state = 0;
- if (buf->b_pprev)
- __hash_unlink(buf);
- __remove_from_lru_list(buf, buf->b_list);
- put_last_free(buf);
- }
+ if (!atomic_dec_and_test(&buf->b_count) || buffer_locked(buf))
+ goto in_use;
+ if (buf->b_pprev)
+ __hash_unlink(buf);
+ write_unlock(&hash_table_lock);
+ __remove_from_lru_list(buf, buf->b_list);
+ spin_unlock(&lru_list_lock);
+ buf->b_state = 0;
+ put_last_free(buf);
+ return;
+
+ in_use:
write_unlock(&hash_table_lock);
spin_unlock(&lru_list_lock);
}

Andrea

-
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/