Re: [PATCH] ocfs2: fix deadlock in dio write orphan cleanup path
From: Matthew Wilcox
Date: Sat Jun 20 2026 - 14:00:09 EST
On Sat, Jun 20, 2026 at 01:38:02PM +0530, Deepanshu Kartikey wrote:
> PREEMPT_RT's rtmutex PI chain walker detected a lock dependency
> cycle in a single thread:
>
> ocfs2_file_write_iter()
> inode_lock(file_inode) [Lock A]
> ocfs2_dio_end_io_write()
> ocfs2_inode_lock() [Lock B]
> ocfs2_del_inode_from_orphan()
> inode_lock(orphan_dir) [Lock D] <- cycle detected!
This seems like a false positive. You can't call write_iter() on
a directory, and orphan_dir is always a directory.
I would suggest that the easiest way to make this warning go away is to
replace inode_lock(orphan_dir) with inode_lock_nested(orphan_dir,
I_MUTEX_NONDIR2). It's a bit quirky because, well, orphan2 is a
directory. We could add a seventh lock class to
inode_i_mutex_lock_class, but that feels a bit excessive.