From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 2/19] ext3 corruption fix
Date: Sun, 16 Jun 2002 23:51:12 -0700 [thread overview]
Message-ID: <3D0D86E0.15A3C5E2@zip.com.au> (raw)
Stephen and Neil Brown recently worked this out. It's a
rare situation which only affects data=journal mode.
Fix problem in data=journal mode where writeback could be left pending on a
journaled, deleted disk block. If that block then gets reallocated, we can
end up with an alias in which the old data can be written back to disk over
the new. Thanks to Neil Brown for spotting this and coming up with the
initial fix.
--- 2.5.22/fs/jbd/transaction.c~nb-fix Sun Jun 16 22:50:16 2002
+++ 2.5.22-akpm/fs/jbd/transaction.c Sun Jun 16 23:22:45 2002
@@ -1861,6 +1861,7 @@ static int journal_unmap_buffer(journal_
* running transaction if that is set, but nothing
* else. */
JBUFFER_TRACE(jh, "on committing transaction");
+ set_buffer_freed(bh);
if (jh->b_next_transaction) {
J_ASSERT(jh->b_next_transaction ==
journal->j_running_transaction);
--- 2.5.22/fs/jbd/commit.c~nb-fix Sun Jun 16 22:50:16 2002
+++ 2.5.22-akpm/fs/jbd/commit.c Sun Jun 16 22:50:16 2002
@@ -659,6 +659,20 @@ skip_commit:
* there's no point in keeping a checkpoint record for
* it. */
bh = jh2bh(jh);
+
+ /* A buffer which has been freed while still being
+ * journaled by a previous transaction may end up still
+ * being dirty here, but we want to avoid writing back
+ * that buffer in the future now that the last use has
+ * been committed. That's not only a performance gain,
+ * it also stops aliasing problems if the buffer is left
+ * behind for writeback and gets reallocated for another
+ * use in a different page. */
+ if (buffer_freed(bh)) {
+ clear_buffer_freed(bh);
+ clear_buffer_jbddirty(bh);
+ }
+
if (buffer_jdirty(bh)) {
JBUFFER_TRACE(jh, "add to new checkpointing trans");
__journal_insert_checkpoint(jh, commit_transaction);
--- 2.5.22/include/linux/jbd.h~nb-fix Sun Jun 16 22:50:16 2002
+++ 2.5.22-akpm/include/linux/jbd.h Sun Jun 16 22:50:16 2002
@@ -238,6 +238,7 @@ enum jbd_state_bits {
BUFFER_FNS(JBD, jbd)
BUFFER_FNS(JBDDirty, jbddirty)
TAS_BUFFER_FNS(JBDDirty, jbddirty)
+BUFFER_FNS(Freed, freed)
static inline struct buffer_head *jh2bh(struct journal_head *jh)
{
-
reply other threads:[~2002-06-17 6:47 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=3D0D86E0.15A3C5E2@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