Messages in this thread | | | Date | Sat, 20 Mar 1999 12:53:36 -0800 (PST) | From | Linus Torvalds <> | Subject | Re: [patch] fix for buffer hash leakage |
| |
On Sat, 20 Mar 1999, Linus Torvalds wrote: > > Stephen, would you mind thinking about this for five minutes? I wonder if > it shouldn't look something like this:
Having thought about it for five minutes I convinced myself that the patch as Andrea had it was potentially horribly deadly, and could result in total disk corruption. Bad.
Just to give you an idea of why the old one was bad: - buffer with an active writeout is bforgot()'en - buffer is re-allocated to something else - the active writeout completes, and marks the buffer uptodate - the new user gets terminally confused because the contents of the buffer may be crap
It's _extremely_ unlikely, because we put the buffer at the end of the free list and it needs just about pessimal timings to happen anyway, but the unlikely bugs are the worst ones to fix later.
However, it is certainly true that the old bforget() was a piece of crap too. Here's my current one that looks "obviously correct" - can people who saw the performance problems with the original version please test this one out?
/* * bforget() is like brelse(), except it puts the buffer on the * free list if it can.. We can NOT free the buffer if: * - there are other users of it * - it is locked and thus can have active IO */ void __bforget(struct buffer_head * buf) { if (buf->b_count != 1 || buffer_locked(buf)) { __brelse(buf); return; } remove_from_queues(buf); put_last_free(buf); }
Can anybody see any downsides with this patch? Note that the likelihood of the if-statement triggering is pretty low, so I don't think performance should be any different from Andreas patch, but the above looks safe and "feels" right to me. I certainly know that I would have been extremely nervous to release a real kernel with the previous patch posted.
Linus
- 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/
| |