From: Jan Kara Date: Tue, 13 Mar 2012 19:43:04 +0000 (-0400) Subject: jbd2: protect all log tail updates with j_checkpoint_mutex X-Git-Tag: v3.2.72~106 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f63bfd0051575b4487f2e17b44e2cc4eb39384b;p=pandora-kernel.git jbd2: protect all log tail updates with j_checkpoint_mutex commit a78bb11d7acd525623c6a0c2ff4e213d527573fa upstream. There are some log tail updates that are not protected by j_checkpoint_mutex. Some of these are harmless because they happen during startup or shutdown but updates in jbd2_journal_commit_transaction() and jbd2_journal_flush() can really race with other log tail updates (e.g. someone doing jbd2_journal_flush() with someone running jbd2_cleanup_journal_tail()). So protect all log tail updates with j_checkpoint_mutex. Signed-off-by: Jan Kara Signed-off-by: "Theodore Ts'o" [bwh: Backported to 3.2: - Adjust context - Add unlock on the error path in jbd2_journal_flush()] Signed-off-by: Ben Hutchings Cc: Bartosz Kwitniewski --- diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index bccb60533f93..b6c3c14052f8 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -340,6 +340,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) /* Do we need to erase the effects of a prior jbd2_journal_flush? */ if (journal->j_flags & JBD2_FLUSHED) { jbd_debug(3, "super block updated\n"); + mutex_lock(&journal->j_checkpoint_mutex); /* * We hold j_checkpoint_mutex so tail cannot change under us. * We don't need any special data guarantees for writing sb @@ -350,6 +351,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) journal->j_tail_sequence, journal->j_tail, WRITE_SYNC); + mutex_unlock(&journal->j_checkpoint_mutex); } else { jbd_debug(3, "superblock not updated\n"); } Reading git-diff-tree failed