We need to check that buffer is still journalled _after_ taking the right
locks.



 fs/jbd/transaction.c |    8 ++++++++
 1 files changed, 8 insertions(+)

diff -puN fs/jbd/transaction.c~jbd-520-journal_unmap_buffer-race fs/jbd/transaction.c
--- 25/fs/jbd/transaction.c~jbd-520-journal_unmap_buffer-race	2003-05-26 05:20:42.000000000 -0700
+++ 25-akpm/fs/jbd/transaction.c	2003-05-26 05:24:32.000000000 -0700
@@ -1764,6 +1764,14 @@ static int journal_unmap_buffer(journal_
 	spin_lock(&journal->j_state_lock);
 	jbd_lock_bh_state(bh);
 	spin_lock(&journal->j_list_lock);
+
+	/*
+	 * Now we have the locks, check again to see whether kjournald has
+	 * taken the buffer off the transaction.
+	 */
+	if (!buffer_jbd(bh))
+		goto zap_buffer;
+
 	jh = bh2jh(bh);
 	transaction = jh->b_transaction;
 	if (transaction == NULL) {

_