Commit 0c74aabb authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ext3: fix buffer dirtying

This is a forward-port from 2.4.  One of Stephen's recent fixes.  I
managed to merge up only half of it.  Here is the rest.  It should fix
the asserton failure reported by Robert Macaulay
<robert_macaulay@dell.com>

"There was a race window in buffer refiling where we could temporarily
 expose the journal's internal BH_JBDDirect flag as BH_Dirty, which is
 visible to the rest of the VFS.  That doesn't affect the journaling,
 because we hold journal_head locks while the buffer is in this
 transient state, but bdflush can see the buffer and write it out
 unexpectedly, causing ext3 to find the buffer in an unexpected state
 later."

 The fix simply keeps the dirty bits clear during the internal buffer
 processing, restoring the state to the private BH_JBDDirect once
 refiling is complete."
parent dd2f1160
......@@ -2042,23 +2042,30 @@ void journal_file_buffer(struct journal_head *jh,
void __journal_refile_buffer(struct journal_head *jh)
{
int was_dirty;
assert_spin_locked(&journal_datalist_lock);
#ifdef __SMP__
J_ASSERT_JH(jh, current->lock_depth >= 0);
#endif
__journal_unfile_buffer(jh);
J_ASSERT_JH(jh, kernel_locked());
/* If the buffer is now unused, just drop it. If it has been
modified by a later transaction, add it to the new
transaction's metadata list. */
/* If the buffer is now unused, just drop it. */
if (jh->b_next_transaction == NULL) {
__journal_unfile_buffer(jh);
jh->b_transaction = NULL;
return;
}
/* It has been modified by a later transaction: add it to the
* new transaction's metadata list. */
was_dirty = test_clear_buffer_jbddirty(jh2bh(jh));
__journal_unfile_buffer(jh);
jh->b_transaction = jh->b_next_transaction;
jh->b_next_transaction = NULL;
__journal_file_buffer(jh, jh->b_transaction, BJ_Metadata);
J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING);
if (jh->b_transaction != NULL) {
__journal_file_buffer(jh, jh->b_transaction, BJ_Metadata);
J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING);
}
if (was_dirty)
set_buffer_jbddirty(jh2bh(jh));
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment