Skip to content

Commit 229309c

Browse files
jankaratytso
authored andcommitted
jbd2: Fix forever sleeping process in do_get_write_access()
In do_get_write_access() we wait on BH_Unshadow bit for buffer to get from shadow state. The waking code in journal_commit_transaction() has a bug because it does not issue a memory barrier after the buffer is moved from the shadow state and before wake_up_bit() is called. Thus a waitqueue check can happen before the buffer is actually moved from the shadow state and waiting process may never be woken. Fix the problem by issuing proper barrier. Reported-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 667eff3 commit 229309c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎fs/jbd2/commit.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,13 @@ void jbd2_journal_commit_transaction(journal_t *journal)
760760
required. */
761761
JBUFFER_TRACE(jh, "file as BJ_Forget");
762762
jbd2_journal_file_buffer(jh, commit_transaction, BJ_Forget);
763-
/* Wake up any transactions which were waiting for this
764-
IO to complete */
763+
/*
764+
* Wake up any transactions which were waiting for this IO to
765+
* complete. The barrier must be here so that changes by
766+
* jbd2_journal_file_buffer() take effect before wake_up_bit()
767+
* does the waitqueue check.
768+
*/
769+
smp_mb();
765770
wake_up_bit(&bh->b_state, BH_Unshadow);
766771
JBUFFER_TRACE(jh, "brelse shadowed buffer");
767772
__brelse(bh);

0 commit comments

Comments
 (0)