--------------------- PatchSet 858 Date: 2002/06/13 16:15:37 Author: sct Log: 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. Members: fs/jbd/commit.c:1.46.2.5->1.46.2.6 [ext3-1_0-branch] fs/jbd/transaction.c:1.64.2.12->1.64.2.13 [ext3-1_0-branch] --- linux-ext3-2.4merge/fs/jbd/transaction.c.=K0014=.orig Sat Aug 17 20:23:22 2002 +++ linux-ext3-2.4merge/fs/jbd/transaction.c Sat Aug 17 20:23:22 2002 @@ -1840,6 +1840,7 @@ * running transaction if that is set, but nothing * else. */ JBUFFER_TRACE(jh, "on committing transaction"); + set_bit(BH_Freed, &bh->b_state); if (jh->b_next_transaction) { J_ASSERT(jh->b_next_transaction == journal->j_running_transaction); --- linux-ext3-2.4merge/fs/jbd/commit.c.=K0014=.orig Sat Aug 17 20:23:21 2002 +++ linux-ext3-2.4merge/fs/jbd/commit.c Sat Aug 17 20:23:21 2002 @@ -663,6 +663,20 @@ * 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_state(bh, Freed)) { + clear_bit(BH_Freed, &bh->b_state); + clear_bit(BH_JBDDirty, &bh->b_state); + } + if (buffer_jdirty(bh)) { JBUFFER_TRACE(jh, "add to new checkpointing trans"); __journal_insert_checkpoint(jh, commit_transaction);