
From: Alex Tomas <bzzz@tmi.comex.ru>

fsync_super() calls ->sync_fs() just after ->write_super().  But
write_super() will start a commit.  In this case, ext3_sync_fs() will not
itself start a commit, and it hence forgets to wait on the commit which
ext3_write_super() started.

Fix that up by making journal_start_commit() return the transaction ID of
any currently-running transaction.



 fs/jbd/journal.c |    7 +++++++
 1 files changed, 7 insertions(+)

diff -puN fs/jbd/journal.c~ext3_sync_fs-fix fs/jbd/journal.c
--- 25/fs/jbd/journal.c~ext3_sync_fs-fix	2003-07-07 12:47:32.000000000 -0700
+++ 25-akpm/fs/jbd/journal.c	2003-07-07 12:48:20.000000000 -0700
@@ -484,6 +484,13 @@ int journal_start_commit(journal_t *jour
 		ret = __log_start_commit(journal, tid);
 		if (ret && ptid)
 			*ptid = tid;
+	} else if (journal->j_committing_transaction && ptid) {
+		/*
+		 * If ext3_write_super() recently started a commit, then we
+		 * have to wait for completion of that transaction
+		 */
+		*ptid = journal->j_committing_transaction->t_tid;
+		ret = 1;
 	}
 	spin_unlock(&journal->j_state_lock);
 	return ret;

_
