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



 25-akpm/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	Thu Jun  5 15:14:33 2003
+++ 25-akpm/fs/jbd/transaction.c	Thu Jun  5 15:14:33 2003
@@ -1756,6 +1756,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) {

_