Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit ddf4b773 authored by Joseph Qi's avatar Joseph Qi Committed by Linus Torvalds
Browse files

ocfs2: fix a deadlock when commit trans

commit 6f1b2285 introduces a regression which can deadlock as
follows:

  Task1:                              Task2:
  jbd2_journal_commit_transaction     ocfs2_test_bg_bit_allocatable
  spin_lock(&jh->b_state_lock)        jbd_lock_bh_journal_head
  __jbd2_journal_remove_checkpoint    spin_lock(&jh->b_state_lock)
  jbd2_journal_put_journal_head
  jbd_lock_bh_journal_head

Task1 and Task2 lock bh->b_state and jh->b_state_lock in different
order, which finally result in a deadlock.

So use jbd2_journal_[grab|put]_journal_head instead in
ocfs2_test_bg_bit_allocatable() to fix it.

Link: https://lkml.kernel.org/r/20220121071205.100648-3-joseph.qi@linux.alibaba.com
Fixes: 6f1b2285

 ("ocfs2: fix race between searching chunks and release journal_head from buffer_head")
Signed-off-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Reported-by: default avatarGautham Ananthakrishna <gautham.ananthakrishna@oracle.com>
Tested-by: default avatarGautham Ananthakrishna <gautham.ananthakrishna@oracle.com>
Rep...
parent 4cd1103d
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment