Skip to contentSkip to conversation

fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents()

BUG Jia-Ju Bai 2 participants 3 messages Dec 10, 2021 – Dec 14, 2021 OCFS2

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

Hello,

My static analysis tool reports a possible ABBA deadlock in the ocfs2 module in Linux 5.10:

ocfs2_dio_end_io_write() down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A) ocfs2_del_inode_from_orphan() inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)

ocfs2_move_extents()
  inode_lock(inode); --> Line 916 (Lock B) down_write(&OCFS2_I(inode)->ip_alloc_sem); --> Line 936 (Lock A)

When ocfs2_dio_end_io_write() and ocfs2_move_extents() are concurrently executed, the deadlocks can occur.

I am not quite sure whether this possible deadlock is real and how to fix it if it is real. Any feedback would be appreciated, thanks :)

Best wishes,
Jia-Ju Bai

maintainer
#1 lore raw

Hi,

Thanks for the report. But I don't think this is a possible deadlock in practice. Please see my comments below.

Quoted 8 lines · Jia-Ju Bai

Hello,

My static analysis tool reports a possible ABBA deadlock in the ocfs2 module in Linux 5.10:

ocfs2_dio_end_io_write() down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A) ocfs2_del_inode_from_orphan() inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)

Just as the variable name indicates, it is orphan dir inode, which is a system file (something hidden inside the filesystem) and not visible for end user.

Quoted 3 lines

ocfs2_move_extents()
  inode_lock(inode); --> Line 916 (Lock B)

This is called from a ioctl from user, it a normal file inode.

Thanks,
Joseph

Quoted 12 lines

  down_write(&OCFS2_I(inode)->ip_alloc_sem); --> Line 936 (Lock A)

When ocfs2_dio_end_io_write() and ocfs2_move_extents() are concurrently executed, the deadlocks can occur.

I am not quite sure whether this possible deadlock is real and how to fix it if it is real. Any feedback would be appreciated, thanks :)

Best wishes,
Jia-Ju Bai

author
#2 lore raw
Quoted 14 lines · Joseph Qi

Hi,

Thanks for the report. But I don't think this is a possible deadlock in practice. Please see my comments below.

Quoted 8 lines · Jia-Ju Bai

Hello,

My static analysis tool reports a possible ABBA deadlock in the ocfs2 module in Linux 5.10:

ocfs2_dio_end_io_write()
  down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A) ocfs2_del_inode_from_orphan() inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)

Quoted 7 lines

Just as the variable name indicates, it is orphan dir inode, which is a system file (something hidden inside the filesystem) and not visible for end user.

Quoted 2 lines

ocfs2_move_extents()
  inode_lock(inode); --> Line 916 (Lock B)

This is called from a ioctl from user, it a normal file inode.

Okay, thanks for the explanation :)

Best wishes,
Jia-Ju Bai