From: "David L. Parsley" <parsley@linuxjedi.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: "Adam J. Richter" <adam@yggdrasil.com>,
parsley@roanoke.edu, linux-kernel@vger.kernel.org
Subject: [PATCH] one-liner fix for bforget() honoring BH_Protected; was: Re: Patch (repost): cramfs memory corruption fix
Date: Wed, 10 Jan 2001 18:30:50 -0500 [thread overview]
Message-ID: <3A5CF0AA.1AC1E753@linuxjedi.org> (raw)
In-Reply-To: <Pine.LNX.4.10.10101071938540.28661-100000@penguin.transmeta.com>
[-- Attachment #1: Type: text/plain, Size: 986 bytes --]
Linus Torvalds wrote:
>
> On Sat, 6 Jan 2001, Adam J. Richter wrote:
> >
> > This sounds like a bug that I posted a fix for a long time ago.
> > cramfs calls bforget on the superblock area, destroying that block of
> > the ramdisk, even when the ramdisk does not contain a cramfs file system.
> > Normally, bforget is called on block that really can be trashed,
> > such as blocks release by truncate or unlink.
>
> I'd really prefer just not letting bforget() touch BH_Protected buffers.
> bforget() is also used by other things than unlink/truncate: it's used by
> various partition codes etc, and it's used by the raid logic.
Yup, I backed out Adam's one-liner in favor of the attached one-liner.
Tested on 2.4.0, but should patch cleanly to just about anything. ;-)
BTW Linus - you were of course right on the cramfs wanting 4096
blocksize... but without this fix, that doesn't matter much. ;-)
regards,
David
--
David L. Parsley
Network Administrator
Roanoke College
[-- Attachment #2: bforgetfix.diff --]
[-- Type: text/plain, Size: 684 bytes --]
--- linux.linus/fs/buffer.c Wed Jan 3 23:45:26 2001
+++ linux/fs/buffer.c Wed Jan 10 15:49:36 2001
@@ -1145,13 +1145,15 @@
* 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
+ * - it is marked BH_Protected
*/
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_dec_and_test(&buf->b_count) || buffer_locked(buf))
+ if (!atomic_dec_and_test(&buf->b_count) || buffer_locked(buf) ||
+ buffer_protected(buf))
goto in_use;
__hash_unlink(buf);
remove_inode_queue(buf);
next prev parent reply other threads:[~2001-01-10 23:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-07 6:41 Patch (repost): cramfs memory corruption fix Adam J. Richter
2001-01-07 13:53 ` Alan Cox
2001-01-07 19:26 ` Linus Torvalds
2001-01-07 19:42 ` Alan Cox
2001-01-07 19:56 ` Linus Torvalds
2001-01-07 21:11 ` Rik van Riel
2001-01-07 21:20 ` Alan Cox
2001-01-08 6:56 ` Eric W. Biederman
2001-01-07 21:54 ` Chris Wedgwood
2001-01-08 13:37 ` Christoph Rohland
2001-01-08 14:19 ` Christoph Hellwig
2001-01-08 14:43 ` Christoph Rohland
2001-01-08 14:42 ` Alan Cox
2001-01-08 14:49 ` Christoph Rohland
2001-01-07 20:39 ` David L. Parsley
2001-01-08 18:27 ` Linus Torvalds
2001-01-08 3:46 ` Linus Torvalds
2001-01-08 13:11 ` David Woodhouse
2001-01-08 12:30 ` Shane Nay
2001-01-08 14:34 ` David Woodhouse
2001-01-10 23:30 ` David L. Parsley [this message]
2001-01-11 4:23 ` [PATCH] one-liner fix for bforget() honoring BH_Protected; was: " Linus Torvalds
2001-01-11 3:08 Adam J. Richter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3A5CF0AA.1AC1E753@linuxjedi.org \
--to=parsley@linuxjedi.org \
--cc=adam@yggdrasil.com \
--cc=linux-kernel@vger.kernel.org \
--cc=parsley@roanoke.edu \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).