[linux] 01/01: jbd2: protect all log tail updates with j_checkpoint_mutex (regression in 3.2.71)

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Fri Oct 2 03:14:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch wheezy
in repository linux.

commit e9311468e52d50ca74d01b03c4c987d14cbc30e9
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Fri Oct 2 04:11:07 2015 +0100

    jbd2: protect all log tail updates with j_checkpoint_mutex (regression in 3.2.71)
---
 debian/changelog                                   |   2 +
 ...-log-tail-updates-with-j_checkpoint_mutex.patch | 128 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 3 files changed, 131 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 60f47fa..55c6e69 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 linux (3.2.71-2) UNRELEASED; urgency=medium
 
   * Ignore ABI changes in drivers/net/wireless/* (fixes FTBFS on i386)
+  * jbd2: protect all log tail updates with j_checkpoint_mutex
+    (regression in 3.2.71)
 
  -- Ben Hutchings <ben at decadent.org.uk>  Sun, 27 Sep 2015 14:29:02 +0100
 
diff --git a/debian/patches/jbd2-protect-all-log-tail-updates-with-j_checkpoint_mutex.patch b/debian/patches/jbd2-protect-all-log-tail-updates-with-j_checkpoint_mutex.patch
new file mode 100644
index 0000000..1e1dfc9
--- /dev/null
+++ b/debian/patches/jbd2-protect-all-log-tail-updates-with-j_checkpoint_mutex.patch
@@ -0,0 +1,128 @@
+From: Jan Kara <jack at suse.cz>
+Date: Tue, 13 Mar 2012 15:43:04 -0400
+Subject: 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 <jack at suse.cz>
+Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
+[bwh: Backported to 3.2:
+ - Adjust context
+ - Add unlock on the error path in jbd2_journal_flush()]
+Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
+---
+ fs/jbd2/commit.c  |  2 ++
+ fs/jbd2/journal.c | 19 ++++++++++++++++---
+ 2 files changed, 18 insertions(+), 3 deletions(-)
+
+--- a/fs/jbd2/commit.c
++++ b/fs/jbd2/commit.c
+@@ -340,6 +340,7 @@ void jbd2_journal_commit_transaction(jou
+ 	/* 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(jou
+ 						journal->j_tail_sequence,
+ 						journal->j_tail,
+ 						WRITE_SYNC);
++		mutex_unlock(&journal->j_checkpoint_mutex);
+ 	} else {
+ 		jbd_debug(3, "superblock not updated\n");
+ 	}
+--- a/fs/jbd2/journal.c
++++ b/fs/jbd2/journal.c
+@@ -1242,6 +1242,8 @@ static int journal_reset(journal_t *jour
+ 			journal->j_errno);
+ 		journal->j_flags |= JBD2_FLUSHED;
+ 	} else {
++		/* Lock here to make assertions happy... */
++		mutex_lock(&journal->j_checkpoint_mutex);
+ 		/*
+ 		 * Update log tail information. We use WRITE_FUA since new
+ 		 * transaction will start reusing journal space and so we
+@@ -1252,6 +1254,7 @@ static int journal_reset(journal_t *jour
+ 						journal->j_tail_sequence,
+ 						journal->j_tail,
+ 						WRITE_FUA);
++		mutex_unlock(&journal->j_checkpoint_mutex);
+ 	}
+ 	return jbd2_journal_start_thread(journal);
+ }
+@@ -1314,6 +1317,7 @@ int jbd2_journal_update_sb_log_tail(jour
+ 	journal_superblock_t *sb = journal->j_superblock;
+ 	int ret;
+ 
++	BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
+ 	jbd_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
+ 		  tail_block, tail_tid);
+ 
+@@ -1344,6 +1348,7 @@ static void jbd2_mark_journal_empty(jour
+ {
+ 	journal_superblock_t *sb = journal->j_superblock;
+ 
++	BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
+ 	read_lock(&journal->j_state_lock);
+ 	jbd_debug(1, "JBD2: Marking journal as empty (seq %d)\n",
+ 		  journal->j_tail_sequence);
+@@ -1577,9 +1582,11 @@ int jbd2_journal_destroy(journal_t *jour
+ 	spin_unlock(&journal->j_list_lock);
+ 
+ 	if (journal->j_sb_buffer) {
+-		if (!is_journal_aborted(journal))
++		if (!is_journal_aborted(journal)) {
++			mutex_lock(&journal->j_checkpoint_mutex);
+ 			jbd2_mark_journal_empty(journal);
+-		else
++			mutex_unlock(&journal->j_checkpoint_mutex);
++		} else
+ 			err = -EIO;
+ 		brelse(journal->j_sb_buffer);
+ 	}
+@@ -1828,10 +1835,13 @@ int jbd2_journal_flush(journal_t *journa
+ 	if (is_journal_aborted(journal))
+ 		return -EIO;
+ 
++	mutex_lock(&journal->j_checkpoint_mutex);
+ 	if (!err) {
+ 		err = jbd2_cleanup_journal_tail(journal);
+-		if (err < 0)
++		if (err < 0) {
++			mutex_unlock(&journal->j_checkpoint_mutex);
+ 			goto out;
++		}
+ 		err = 0;
+ 	}
+ 
+@@ -1841,6 +1851,7 @@ int jbd2_journal_flush(journal_t *journa
+ 	 * commits of data to the journal will restore the current
+ 	 * s_start value. */
+ 	jbd2_mark_journal_empty(journal);
++	mutex_unlock(&journal->j_checkpoint_mutex);
+ 	write_lock(&journal->j_state_lock);
+ 	J_ASSERT(!journal->j_running_transaction);
+ 	J_ASSERT(!journal->j_committing_transaction);
+@@ -1882,8 +1893,12 @@ int jbd2_journal_wipe(journal_t *journal
+ 		write ? "Clearing" : "Ignoring");
+ 
+ 	err = jbd2_journal_skip_recovery(journal);
+-	if (write)
++	if (write) {
++		/* Lock to make assertions happy... */
++		mutex_lock(&journal->j_checkpoint_mutex);
+ 		jbd2_mark_journal_empty(journal);
++		mutex_unlock(&journal->j_checkpoint_mutex);
++	}
+ 
+  no_recovery:
+ 	return err;
diff --git a/debian/patches/series b/debian/patches/series
index bf60bbb..443080f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1161,3 +1161,4 @@ bugfix/all/rds-verify-the-underlying-transport-exists-before-cr.patch
 debian/revert-libata-ignore-spurious-phy-event-on-lpm-polic.patch
 debian/usb-avoid-abi-change-in-3.2.69.patch
 debian/bh-avoid-abi-change-in-3.2.71.patch
+jbd2-protect-all-log-tail-updates-with-j_checkpoint_mutex.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list