From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 3/10] Allow truncate to discard unmapped buffers
Date: Sun, 05 May 2002 13:54:28 -0700 [thread overview]
Message-ID: <3CD59C04.350E191B@zip.com.au> (raw)
The buffer state "uptodate, dirty, unmapped" is legal. It occurs when
a mapped page with attached buffers which is over a hole is dirtied.
So discard_buffer() needs to be able to discard those buffers as well;
otherwise the page ends up clean, with dirty buffers and is unfreeable.
=====================================
--- 2.5.13/fs/buffer.c~truncate-leak Sun May 5 13:32:00 2002
+++ 2.5.13-akpm/fs/buffer.c Sun May 5 13:32:37 2002
@@ -1091,17 +1091,15 @@ EXPORT_SYMBOL(set_bh_page);
/*
* Called when truncating a buffer on a page completely.
*/
-static void discard_buffer(struct buffer_head * bh)
+static /* inline */ void discard_buffer(struct buffer_head * bh)
{
- if (buffer_mapped(bh)) {
- clear_buffer_dirty(bh);
- lock_buffer(bh);
- bh->b_bdev = NULL;
- clear_buffer_mapped(bh);
- clear_buffer_req(bh);
- clear_buffer_new(bh);
- unlock_buffer(bh);
- }
+ lock_buffer(bh);
+ clear_buffer_dirty(bh);
+ bh->b_bdev = NULL;
+ clear_buffer_mapped(bh);
+ clear_buffer_req(bh);
+ clear_buffer_new(bh);
+ unlock_buffer(bh);
}
/**
--- 2.5.13/fs/jbd/transaction.c~truncate-leak Sun May 5 13:32:00 2002
+++ 2.5.13-akpm/fs/jbd/transaction.c Sun May 5 13:32:37 2002
@@ -1587,7 +1587,7 @@ static int __journal_try_to_free_buffer(
goto out;
}
- if (!buffer_uptodate(bh))
+ if (!buffer_uptodate(bh)) /* AKPM: why? */
goto out;
if (jh->b_next_transaction != 0)
@@ -1775,9 +1775,6 @@ static int journal_unmap_buffer(journal_
BUFFER_TRACE(bh, "entry");
- if (!buffer_mapped(bh))
- return 1;
-
/* It is safe to proceed here without the
* journal_datalist_spinlock because the buffers cannot be
* stolen by try_to_free_buffers as long as we are holding the
reply other threads:[~2002-05-05 20:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=3CD59C04.350E191B@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--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