Skip to content

Commit 6fa7aa5

Browse files
htejuningomolnar
authored andcommitted
fs/jbd2, locking/mutex, sched/wait: Use mutex_lock_io() for journal->j_checkpoint_mutex
When an ext4 fs is bogged down by a lot of metadata IOs (in the reported case, it was deletion of millions of files, but any massive amount of journal writes would do), after the journal is filled up, tasks which try to access the filesystem and aren't currently performing the journal writes end up waiting in __jbd2_log_wait_for_space() for journal->j_checkpoint_mutex. Because those mutex sleeps aren't marked as iowait, this condition can lead to misleadingly low iowait and /proc/stat:procs_blocked. While iowait propagation is far from strict, this condition can be triggered fairly easily and annotating these sleeps correctly helps initial diagnosis quite a bit. Use the new mutex_lock_io() for journal->j_checkpoint_mutex so that these sleeps are properly marked as iowait. Reported-by: Mingbo Wan <mingbo@fb.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andreas Dilger <adilger.kernel@dilger.ca> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jan Kara <jack@suse.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: kernel-team@fb.com Link: http://lkml.kernel.org/r/1477673892-28940-5-git-send-email-tj@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 1460cb6 commit 6fa7aa5

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/jbd2/commit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
393393
/* Do we need to erase the effects of a prior jbd2_journal_flush? */
394394
if (journal->j_flags & JBD2_FLUSHED) {
395395
jbd_debug(3, "super block updated\n");
396-
mutex_lock(&journal->j_checkpoint_mutex);
396+
mutex_lock_io(&journal->j_checkpoint_mutex);
397397
/*
398398
* We hold j_checkpoint_mutex so tail cannot change under us.
399399
* We don't need any special data guarantees for writing sb

‎fs/jbd2/journal.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
944944
*/
945945
void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
946946
{
947-
mutex_lock(&journal->j_checkpoint_mutex);
947+
mutex_lock_io(&journal->j_checkpoint_mutex);
948948
if (tid_gt(tid, journal->j_tail_sequence))
949949
__jbd2_update_log_tail(journal, tid, block);
950950
mutex_unlock(&journal->j_checkpoint_mutex);
@@ -1304,7 +1304,7 @@ static int journal_reset(journal_t *journal)
13041304
journal->j_flags |= JBD2_FLUSHED;
13051305
} else {
13061306
/* Lock here to make assertions happy... */
1307-
mutex_lock(&journal->j_checkpoint_mutex);
1307+
mutex_lock_io(&journal->j_checkpoint_mutex);
13081308
/*
13091309
* Update log tail information. We use REQ_FUA since new
13101310
* transaction will start reusing journal space and so we
@@ -1691,7 +1691,7 @@ int jbd2_journal_destroy(journal_t *journal)
16911691
spin_lock(&journal->j_list_lock);
16921692
while (journal->j_checkpoint_transactions != NULL) {
16931693
spin_unlock(&journal->j_list_lock);
1694-
mutex_lock(&journal->j_checkpoint_mutex);
1694+
mutex_lock_io(&journal->j_checkpoint_mutex);
16951695
err = jbd2_log_do_checkpoint(journal);
16961696
mutex_unlock(&journal->j_checkpoint_mutex);
16971697
/*
@@ -1713,7 +1713,7 @@ int jbd2_journal_destroy(journal_t *journal)
17131713

17141714
if (journal->j_sb_buffer) {
17151715
if (!is_journal_aborted(journal)) {
1716-
mutex_lock(&journal->j_checkpoint_mutex);
1716+
mutex_lock_io(&journal->j_checkpoint_mutex);
17171717

17181718
write_lock(&journal->j_state_lock);
17191719
journal->j_tail_sequence =
@@ -1955,7 +1955,7 @@ int jbd2_journal_flush(journal_t *journal)
19551955
spin_lock(&journal->j_list_lock);
19561956
while (!err && journal->j_checkpoint_transactions != NULL) {
19571957
spin_unlock(&journal->j_list_lock);
1958-
mutex_lock(&journal->j_checkpoint_mutex);
1958+
mutex_lock_io(&journal->j_checkpoint_mutex);
19591959
err = jbd2_log_do_checkpoint(journal);
19601960
mutex_unlock(&journal->j_checkpoint_mutex);
19611961
spin_lock(&journal->j_list_lock);
@@ -1965,7 +1965,7 @@ int jbd2_journal_flush(journal_t *journal)
19651965
if (is_journal_aborted(journal))
19661966
return -EIO;
19671967

1968-
mutex_lock(&journal->j_checkpoint_mutex);
1968+
mutex_lock_io(&journal->j_checkpoint_mutex);
19691969
if (!err) {
19701970
err = jbd2_cleanup_journal_tail(journal);
19711971
if (err < 0) {

0 commit comments

Comments
 (0)